This commit is contained in:
钱涛 2022-04-08 19:08:59 +08:00
parent 23adb455fd
commit 0b72b2e6cb
36 changed files with 2301 additions and 968 deletions

View File

@ -83,4 +83,14 @@ public class EmployBiz extends BaseBean {
sqlSession.close();
}
}
public DataCollectionEmployee getEmployeeById(Long employeeId) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
EmployMapper mapper = sqlSession.getMapper(EmployMapper.class);
return mapper.getEmployeeById(employeeId);
} finally {
sqlSession.close();
}
}
}

View File

@ -6,6 +6,7 @@ import com.engine.salary.mapper.TaxAgentMapper;
import org.apache.ibatis.session.SqlSession;
import weaver.conn.mybatis.MyBatisFactory;
import java.util.Collection;
import java.util.List;
public class TaxAgentBiz {
@ -20,7 +21,7 @@ public class TaxAgentBiz {
}
}
public List<TaxAgent> listByIds(List<Long> taxAgentIds) {
public List<TaxAgent> listByIds(Collection<Long> taxAgentIds) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
TaxAgentMapper taxAgentMapper = sqlSession.getMapper(TaxAgentMapper.class);
@ -29,4 +30,14 @@ public class TaxAgentBiz {
sqlSession.close();
}
}
public TaxAgent getById(Long taxAgentId) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
TaxAgentMapper taxAgentMapper = sqlSession.getMapper(TaxAgentMapper.class);
return taxAgentMapper.getById(taxAgentId);
} finally {
sqlSession.close();
}
}
}

View File

@ -49,4 +49,19 @@ public class DataCollectionEmployee {
//工号
private String workcode;
//性别
private String sex;
//邮件
private String email;
//电话
private String telephone;
//职称
private String jobcall;
//生日
private String birthday;
}

View File

@ -1,91 +1,89 @@
//package com.engine.salary.entity.salaryacct.bo;
//
//import com.weaver.framework.util.JsonUtil;
//import com.weaver.hrm.salary.entity.salaryformula.dto.SalaryFormulaEmployeeDTO;
//import com.weaver.hrm.salary.entity.salaryitem.po.SalaryItemPO;
//import com.weaver.hrm.salary.enums.SalaryRoundingModeEnum;
//import com.weaver.hrm.salary.enums.salaryitem.SalaryDataTypeEnum;
//import com.weaver.hrm.salary.util.SalaryDateUtil;
//import com.weaver.hrm.salary.util.SalaryEntityUtil;
//import com.weaver.hrm.salary.util.SalaryI18nUtil;
//import com.weaver.teams.api.user.Sex;
//import com.weaver.teams.domain.position.SimplePosition;
//import com.weaver.teams.domain.user.Grade;
//import com.weaver.teams.domain.user.SimpleEmployee;
//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;
//
///**
// * @description: 薪资核算公式变量
// * @author: xiajun
// * @modified By: xiajun
// * @date: Created in 12/8/21 3:40 PM
// * @version:v1.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(SimpleEmployee simpleEmployee) {
// if (simpleEmployee == null) {
// return Collections.emptyMap();
// }
// String sexName = Optional.ofNullable(simpleEmployee.getSex())
// .map(sex -> sex == Sex.male ? 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().getDescription())
// .departmentName(simpleEmployee.getDepartment().getName())
// .positionName(Optional.ofNullable(simpleEmployee.getPosition()).map(SimplePosition::getName).orElse(""))
// .gradeName(Optional.ofNullable(simpleEmployee.getGrade()).map(Grade::getName).orElse(""))
// .hireDate(SalaryDateUtil.getFormatLocalDate(simpleEmployee.getHiredate()))
// .birthday(SalaryDateUtil.getFormatLocalDate(simpleEmployee.getBirthdayDate()))
// .build();
// return JsonUtil.parseMap(JsonUtil.toJsonString(formulaEmployee), String.class);
// }
//}
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.SalaryDateUtil;
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())
.hireDate(SalaryDateUtil.getFormatLocalDate(simpleEmployee.getCompanystartdate()))
.birthday(simpleEmployee.getBirthday())
.build();
return JsonUtil.parseMap(JsonUtil.toJsonString(formulaEmployee), String.class);
}
}

View File

@ -1,392 +1,375 @@
//package com.engine.salary.entity.salaryacct.bo;
//
//import com.google.common.collect.Lists;
//import com.google.common.collect.Maps;
//import com.weaver.common.component.constant.WeaAlignEnum;
//import com.weaver.common.component.form.WeaForm;
//import com.weaver.common.component.form.item.WeaFormItem;
//import com.weaver.common.component.form.item.WeaFormItemType;
//import com.weaver.common.component.form.layout.WeaFormLayout;
//import com.weaver.common.component.table.WeaTable;
//import com.weaver.common.component.table.column.WeaTableColumn;
//import com.weaver.common.component.table.type.WeaTableTypeEnum;
//import com.weaver.common.distribution.genid.IdGenerator;
//import com.weaver.common.i18n.label.SystemEnv;
//import com.weaver.hrm.salary.annotation.SalaryFormulaVar;
//import com.weaver.hrm.salary.common.WeaTableColumnWapper;
//import com.weaver.hrm.salary.entity.salaryacct.dto.ConsolidatedTaxDetailDTO;
//import com.weaver.hrm.salary.entity.salaryacct.dto.SalaryAcctEmployeeInfoDTO;
//import com.weaver.hrm.salary.entity.salaryacct.dto.SalaryAcctResultDetailDTO;
//import com.weaver.hrm.salary.entity.salaryacct.param.SalaryAcctResultSaveParam;
//import com.weaver.hrm.salary.entity.salaryacct.po.*;
//import com.weaver.hrm.salary.entity.salaryarchive.po.TaxAgentPO;
//import com.weaver.hrm.salary.entity.salaryformula.dto.SalaryFormulaEmployeeDTO;
//import com.weaver.hrm.salary.entity.salaryitem.po.SalaryItemPO;
//import com.weaver.hrm.salary.entity.salarysob.dto.SalarySobEmpFieldDTO;
//import com.weaver.hrm.salary.entity.salarysob.dto.SalarySobItemAggregateDTO;
//import com.weaver.hrm.salary.entity.salarysob.dto.SalarySobItemDTO;
//import com.weaver.hrm.salary.entity.salarysob.dto.SalarySobItemGroupDTO;
//import com.weaver.hrm.salary.entity.salarysob.po.SalarySobEmpFieldPO;
//import com.weaver.hrm.salary.entity.salarysob.po.SalarySobItemPO;
//import com.weaver.hrm.salary.entity.salarysob.po.SalarySobPO;
//import com.weaver.hrm.salary.enums.salaryitem.SalaryDataTypeEnum;
//import com.weaver.hrm.salary.util.SalaryEntityUtil;
//import com.weaver.teams.domain.user.SimpleEmployee;
//import org.apache.commons.collections4.CollectionUtils;
//import org.apache.commons.lang3.StringUtils;
//import org.apache.commons.lang3.math.NumberUtils;
//import org.springframework.beans.BeanUtils;
//
//import java.lang.reflect.Field;
//import java.time.LocalDateTime;
//import java.util.*;
//import java.util.stream.Collectors;
//
///**
// * @description: 薪资核算结果
// * @author: xiajun
// * @modified By: xiajun
// * @date: Created in 12/6/21 7:05 PM
// * @version:v1.0
// */
//public class SalaryAcctResultBO {
//
// /**
// * 数据类型的后悔标识
// * 为了展示千分位薪资核算结果列表线上线下对比结果列表需要返回给前端列表字段的数据类型字段索引+后缀标识
// */
// private static final String DATA_TYPE_SUFFIX = "_type";
//
// /**
// * 构建薪资核算结果列表的表头
// *
// * @param salarySobItemAggregateDTO
// * @return
// */
// public static List<WeaTableColumn> buildTableColumns4ComparisonResult(SalarySobItemAggregateDTO salarySobItemAggregateDTO, Set<Long> excludeSalaryItemIds) {
// List<WeaTableColumn> columns = Lists.newArrayList();
// // 员工信息字段
// for (SalarySobEmpFieldDTO salarySobEmpFieldDTO : salarySobItemAggregateDTO.getEmpFields()) {
// columns.add(new WeaTableColumnWapper(salarySobEmpFieldDTO.getFieldName(), salarySobEmpFieldDTO.getFieldId(), "150",
// WeaAlignEnum.LEFT.getStringVal(), WeaAlignEnum.LEFT.getStringVal(), salarySobEmpFieldDTO.getFieldId()));
// }
// // 薪资项目分组下的薪资项目
// for (SalarySobItemGroupDTO salarySobItemGroupDTO : salarySobItemAggregateDTO.getItemGroups()) {
// if (CollectionUtils.isEmpty(salarySobItemGroupDTO.getItems())) {
// continue;
// }
// for (SalarySobItemDTO salarySobItemDTO : salarySobItemGroupDTO.getItems()) {
// if (excludeSalaryItemIds.contains(salarySobItemDTO.getSalaryItemId())) {
// continue;
// }
// columns.add(new WeaTableColumnWapper(salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId(), "150",
// WeaAlignEnum.LEFT.getStringVal(), WeaAlignEnum.LEFT.getStringVal(), "" + salarySobItemDTO.getSalaryItemId()));
// }
// }
// // 没有分类的薪资项目
// for (SalarySobItemDTO salarySobItemDTO : salarySobItemAggregateDTO.getItems()) {
// if (excludeSalaryItemIds.contains(salarySobItemDTO.getSalaryItemId())) {
// continue;
// }
// columns.add(new WeaTableColumnWapper(salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId(), "150",
// WeaAlignEnum.LEFT.getStringVal(), WeaAlignEnum.LEFT.getStringVal(), "" + salarySobItemDTO.getSalaryItemId()));
// }
// return columns;
// }
//
// /**
// * 构建薪资核算结果列表的表头
// *
// * @param salarySobItemAggregateDTO
// * @return
// */
// public static List<WeaTableColumn> buildTableColumns(SalarySobItemAggregateDTO salarySobItemAggregateDTO) {
// List<WeaTableColumn> columns = Lists.newArrayList();
// // 员工信息字段
// for (SalarySobEmpFieldDTO salarySobEmpFieldDTO : salarySobItemAggregateDTO.getEmpFields()) {
// columns.add(new WeaTableColumnWapper(salarySobEmpFieldDTO.getFieldName(), salarySobEmpFieldDTO.getFieldId(), "150",
// WeaAlignEnum.LEFT.getStringVal(), WeaAlignEnum.LEFT.getStringVal(), salarySobEmpFieldDTO.getFieldId()));
// }
// // 薪资项目分组下的薪资项目
// for (SalarySobItemGroupDTO salarySobItemGroupDTO : salarySobItemAggregateDTO.getItemGroups()) {
// if (CollectionUtils.isEmpty(salarySobItemGroupDTO.getItems())) {
// continue;
// }
// WeaTableColumnWapper weaTableColumnWapper = new WeaTableColumnWapper(salarySobItemGroupDTO.getName(),
// String.valueOf(salarySobItemGroupDTO.getId()), "150", WeaAlignEnum.LEFT.getStringVal(), String.valueOf(salarySobItemGroupDTO.getId()));
// List<WeaTableColumnWapper> childrenColumns = Lists.newArrayList();
// for (SalarySobItemDTO salarySobItemDTO : salarySobItemGroupDTO.getItems()) {
// childrenColumns.add(new WeaTableColumnWapper(salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId(), "150",
// WeaAlignEnum.LEFT.getStringVal(), WeaAlignEnum.LEFT.getStringVal(), "" + salarySobItemDTO.getSalaryItemId()));
// }
// weaTableColumnWapper.setChildren(childrenColumns);
// columns.add(weaTableColumnWapper);
// }
// // 没有分类的薪资项目
// for (SalarySobItemDTO salarySobItemDTO : salarySobItemAggregateDTO.getItems()) {
// columns.add(new WeaTableColumnWapper(salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId(), "150",
// WeaAlignEnum.LEFT.getStringVal(), WeaAlignEnum.LEFT.getStringVal(), "" + salarySobItemDTO.getSalaryItemId()));
// }
// return columns;
// }
//
// /**
// * 转船成薪资核算结果列表的表格数据
// *
// * @param salaryItems
// * @param salarySobEmpFields
// * @param simpleEmployees
// * @param salaryAcctEmployees
// * @param salaryAccountingResults
// * @param taxAgents
// * @param consolidatedTaxSalaryAcctEmpIds
// * @return
// */
// public static List<Map<String, Object>> buildTableData(List<SalaryItemPO> salaryItems,
// List<SalarySobEmpFieldPO> salarySobEmpFields,
// List<SimpleEmployee> simpleEmployees,
// List<SalaryAcctEmployeePO> salaryAcctEmployees,
// List<SalaryAcctResultPO> salaryAccountingResults,
// List<TaxAgentPO> taxAgents,
// Set<Long> consolidatedTaxSalaryAcctEmpIds,
// Map<Long, String> customParameters) {
// if (CollectionUtils.isEmpty(salaryAcctEmployees)) {
// return Collections.emptyList();
// }
// Map<Long, SimpleEmployee> employeeMap = SalaryEntityUtil.convert2Map(simpleEmployees, SimpleEmployee::getEmployeeId);
// Map<Long, List<SalaryAcctResultPO>> acctResultMap = SalaryEntityUtil.group2Map(salaryAccountingResults, SalaryAcctResultPO::getEmployeeId);
// Map<Long, String> taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getId, TaxAgentPO::getName);
// return salaryAcctEmployees.stream().map(e -> {
// Map<Long, Object> resultValueMap = SalaryEntityUtil.convert2Map(acctResultMap.getOrDefault(e.getEmployeeId(), Collections.emptyList()),
// SalaryAcctResultPO::getSalaryItemId, SalaryAcctResultPO::getResultValue);
// // 薪资项目的值
// Map<String, Object> map = SalaryEntityUtil.convert2Map(salaryItems, o -> "" + o.getId(), o -> resultValueMap.getOrDefault(o.getId(), StringUtils.EMPTY));
// // 薪资项目的字段类型前端依据这个判断是否需要展示千分位
// Map<String, String> dataTypeMap = SalaryEntityUtil.convert2Map(salaryItems, salaryItemPO -> salaryItemPO.getId() + DATA_TYPE_SUFFIX, SalaryItemPO::getDataType);
// map.putAll(dataTypeMap);
// // 人员信息字段的值
// Map<String, String> fieldValueMap = SalaryAcctFormulaBO.convert2FormulaEmployee(employeeMap.get(e.getEmployeeId()));
// for (SalarySobEmpFieldPO salarySobEmpField : salarySobEmpFields) {
// map.put(salarySobEmpField.getFieldCode(), fieldValueMap.get(salarySobEmpField.getFieldCode()));
// // 员工信息字段的字段类型
// map.put(salarySobEmpField.getFieldCode() + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue());
// }
// // 主键id
// map.put("id", e.getId());
// // 个税扣缴义务人
// String taxAgentName = taxAgentNameMap.getOrDefault(e.getTaxAgentId(), StringUtils.EMPTY);
// map.put("taxAgentName", taxAgentName);
// // 是否属于"合并计税"的标记
// map.put("consolidatedTaxation", StringUtils.isNotEmpty(taxAgentName) && consolidatedTaxSalaryAcctEmpIds.contains(e.getId()));
// // 个税扣缴义务人的字段类型
// map.put("taxAgentName" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue());
// // 公式详情
// map.put("customParameters", customParameters);
// return map;
// }).collect(Collectors.toList());
// }
//
// /**
// * 转转成薪资核算线下对比结果
// *
// * @param salaryItems
// * @param salarySobEmpFields
// * @param simpleEmployees
// * @param salaryAcctEmployees
// * @param salaryAcctResultPOS
// * @param excelAcctResultPOS
// * @param taxAgents
// * @param consolidatedTaxSalaryAcctEmpIds
// * @return
// */
// public static List<Map<String, Object>> buildComparisonTableData(List<SalaryItemPO> salaryItems,
// List<SalarySobEmpFieldPO> salarySobEmpFields,
// List<SimpleEmployee> simpleEmployees,
// List<SalaryAcctEmployeePO> salaryAcctEmployees,
// List<SalaryAcctResultPO> salaryAcctResultPOS,
// List<ExcelAcctResultPO> excelAcctResultPOS,
// List<TaxAgentPO> taxAgents,
// Map<Long, String> customParameters,
// Set<Long> consolidatedTaxSalaryAcctEmpIds,
// Set<Long> includeSalaryItemIds) {
// if (CollectionUtils.isEmpty(simpleEmployees)) {
// return Collections.emptyList();
// }
// Map<Long, List<ExcelAcctResultPO>> excelResultMap = SalaryEntityUtil.group2Map(excelAcctResultPOS, ExcelAcctResultPO::getSalaryAcctEmpId);
// Map<Long, List<SalaryAcctResultPO>> acctResultMap = SalaryEntityUtil.group2Map(salaryAcctResultPOS, SalaryAcctResultPO::getSalaryAcctEmpId);
// Map<Long, String> taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getId, TaxAgentPO::getName);
// Map<Long, SimpleEmployee> employeeMap = SalaryEntityUtil.convert2Map(simpleEmployees, SimpleEmployee::getEmployeeId);
// List<Map<String, Object>> resultList = Lists.newArrayListWithExpectedSize(salaryAcctEmployees.size());
// for (SalaryAcctEmployeePO salaryAcctEmployee : salaryAcctEmployees) {
// // 线下值和系统值之间是否存在差异
// boolean different = false;
// Map<String, Object> map = Maps.newHashMap();
// // 员工信息字段的值
// Map<String, String> fieldValueMap = SalaryAcctFormulaBO.convert2FormulaEmployee(employeeMap.get(salaryAcctEmployee.getEmployeeId()));
// for (SalarySobEmpFieldPO salarySobEmpField : salarySobEmpFields) {
// map.put(salarySobEmpField.getFieldCode(), fieldValueMap.get(salarySobEmpField.getFieldCode()));
// // 员工信息字段的字段类型
// map.put(salarySobEmpField.getFieldCode() + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue());
// }
// // 系统值
// Map<Long, String> acctResultValueMap = SalaryEntityUtil.convert2Map(acctResultMap.getOrDefault(salaryAcctEmployee.getId(), Collections.emptyList()),
// SalaryAcctResultPO::getSalaryItemId, SalaryAcctResultPO::getResultValue);
// // 线下值
// Map<Long, String> excelResultValueMap = SalaryEntityUtil.convert2Map(excelResultMap.getOrDefault(salaryAcctEmployee.getId(), Collections.emptyList()),
// ExcelAcctResultPO::getSalaryItemId, ExcelAcctResultPO::getResultValue);
// // 薪资项目字段的值
// for (SalaryItemPO salaryItem : salaryItems) {
// Map<String, Object> temp = Maps.newHashMap();
// // 系统值
// String acctResultValue = acctResultValueMap.get(salaryItem.getId());
// // 线下值
// String excelResultValue = excelResultValueMap.get(salaryItem.getId());
// temp.put("acctResultValue", acctResultValue);
// temp.put("excelResultValue", excelResultValue);
// map.put(String.valueOf(salaryItem.getId()), temp);
// // 薪资项目字段的字段类型
// map.put(salaryItem.getId() + DATA_TYPE_SUFFIX, salaryItem.getDataType());
// SalaryDataTypeEnum dataTypeEnum = SalaryDataTypeEnum.parseByValue(salaryItem.getDataType());
// if (dataTypeEnum == SalaryDataTypeEnum.STRING) {
// if (!StringUtils.equals(acctResultValue, excelResultValue)) {
// different = true;
// includeSalaryItemIds.add(salaryItem.getId());
// }
// } else {
// if (SalaryEntityUtil.empty2Zero(acctResultValue).compareTo(SalaryEntityUtil.empty2Zero(excelResultValue)) != 0) {
// different = true;
// includeSalaryItemIds.add(salaryItem.getId());
// }
// }
// }
// // 主键id
// map.put("id", salaryAcctEmployee.getId());
// // 个税扣缴义务人
// String taxAgentName = taxAgentNameMap.getOrDefault(salaryAcctEmployee.getTaxAgentId(), StringUtils.EMPTY);
// map.put("taxAgentName", taxAgentName);
// // 个税扣缴义务人的字段类型
// map.put("taxAgentName" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue());
// // 是否属于"合并计税"的标记
// map.put("consolidatedTaxation", StringUtils.isNotEmpty(taxAgentName) && consolidatedTaxSalaryAcctEmpIds.contains(salaryAcctEmployee.getId()));
// // 薪资项目的公式详情前端需要展示
// map.put("customParameters", customParameters);
// // 是否存在差异的标记
// map.put("different", different);
// resultList.add(map);
// }
// return resultList;
// }
//
// /**
// * 转换成薪资核算结果详情dto
// *
// * @param simpleEmployee
// * @param taxAgentPO
// * @param salaryAcctEmployee
// * @param salarySobEmpFields
// * @param salarySobItemPOS
// * @param salaryItems
// * @param salaryAcctResults
// * @return
// */
// public static SalaryAcctResultDetailDTO convert2DetailDTO(SimpleEmployee simpleEmployee,
// TaxAgentPO taxAgentPO,
// SalaryAcctEmployeePO salaryAcctEmployee,
// List<SalarySobEmpFieldPO> salarySobEmpFields,
// List<SalarySobItemPO> salarySobItemPOS,
// List<SalaryItemPO> salaryItems,
// List<SalaryAcctResultPO> salaryAcctResults) {
// // 员工信息字段
// Map<String, String> employeeFieldValueMap = SalaryAcctFormulaBO.convert2FormulaEmployee(simpleEmployee);
// // 个税扣缴义务人
// employeeFieldValueMap.put("taxAgentName", Optional.ofNullable(taxAgentPO).map(TaxAgentPO::getName).orElse(StringUtils.EMPTY));
// Map<String, String> employeeFieldNameMap = buildEmployeeFieldName();
// List<SalaryAcctEmployeeInfoDTO> employeeInfos = salarySobEmpFields.stream()
// .map(e -> SalaryAcctEmployeeInfoDTO.builder()
// .fieldName(employeeFieldNameMap.getOrDefault(e.getFieldCode(), StringUtils.EMPTY))
// .fieldValue(employeeFieldValueMap.getOrDefault(e.getFieldCode(), StringUtils.EMPTY))
// .build())
// .collect(Collectors.toList());
// // 薪资项目的值
// Map<Long, String> resultValueMap = SalaryEntityUtil.convert2Map(salaryAcctResults, SalaryAcctResultPO::getSalaryItemId, SalaryAcctResultPO::getResultValue);
// Map<Long, SalaryItemPO> salaryItemMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getId);
// // 公式项的值不根据salaryItemPO的valueType判断是因为薪资项目的valueType属性改变后并不会同步更新薪资账套中的薪资项目的formulaId字段
// List<SalaryAcctResultDetailDTO.SalaryAcctResultDetailItemDTO> formulaItems = salarySobItemPOS.stream()
// .filter(salarySobItemPO -> salarySobItemPO.getFormulaId() > 0)
// .map(salarySobItemPO -> convert2SalaryAcctResultDetailItemDTO(salarySobItemPO, salaryItemMap.get(salarySobItemPO.getSalaryItemId()), resultValueMap))
// .collect(Collectors.toList());
// // 输入/导入项目的值
// List<SalaryAcctResultDetailDTO.SalaryAcctResultDetailItemDTO> inputItems = salarySobItemPOS.stream()
// .filter(salarySobItemPO -> salarySobItemPO.getFormulaId() <= 0)
// .map(salarySobItemPO -> convert2SalaryAcctResultDetailItemDTO(salarySobItemPO, salaryItemMap.get(salarySobItemPO.getSalaryItemId()), resultValueMap))
// .collect(Collectors.toList());
// return SalaryAcctResultDetailDTO.builder()
// .id(salaryAcctEmployee.getId())
// .employeeId(salaryAcctEmployee.getEmployeeId())
// .employeeInfos(employeeInfos)
// .formulaItems(formulaItems)
// .inputItems(inputItems)
// .build();
// }
//
// /**
// * 转换成薪资核算结果详情dto
// *
// * @param salarySobItemPO
// * @param salaryItemPO
// * @param resultValueMap
// * @return
// */
// private static SalaryAcctResultDetailDTO.SalaryAcctResultDetailItemDTO convert2SalaryAcctResultDetailItemDTO(SalarySobItemPO salarySobItemPO,
// SalaryItemPO salaryItemPO,
// Map<Long, String> resultValueMap) {
// // 薪资项目的数据类型
// return SalaryAcctResultDetailDTO.SalaryAcctResultDetailItemDTO.builder()
// .salaryItemId(salarySobItemPO.getSalaryItemId())
// .salaryItemName(Optional.ofNullable(salaryItemPO).map(SalaryItemPO::getName).orElse(StringUtils.EMPTY))
// .resultValue(resultValueMap.getOrDefault(salarySobItemPO.getSalaryItemId(), StringUtils.EMPTY))
// .dataType(Optional.ofNullable(salaryItemPO).map(SalaryItemPO::getDataType).orElse(SalaryDataTypeEnum.NUMBER.getValue()))
// .build();
// }
//
// /**
// * 薪资核算结果保存参数转换成薪资核算结果po
// *
// * @param saveParam 前端保存参数
// * @param salaryAcctEmployee 薪资核算人员po
// * @param employeeId 当前登陆人员id
// * @param tenantKey 租户key
// * @return
// */
// public static List<SalaryAcctResultPO> convert2PO(SalaryAcctResultSaveParam saveParam,
// SalaryAcctEmployeePO salaryAcctEmployee,
// Long employeeId, String tenantKey) {
// if (CollectionUtils.isEmpty(saveParam.getItems())) {
// return Collections.emptyList();
// }
// LocalDateTime now = LocalDateTime.now();
// return saveParam.getItems().stream()
// .map(e -> SalaryAcctResultPO.builder()
package com.engine.salary.entity.salaryacct.bo;
import com.cloudstore.eccom.pc.table.WeaTableColumn;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salaryacct.dto.ConsolidatedTaxDetailDTO;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctEmployeeInfoDTO;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultDetailDTO;
import com.engine.salary.entity.salaryacct.param.SalaryAcctResultSaveParam;
import com.engine.salary.entity.salaryacct.po.*;
import com.engine.salary.entity.salaryformula.dto.SalaryFormulaEmployeeDTO;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.salarysob.dto.SalarySobEmpFieldDTO;
import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO;
import com.engine.salary.entity.salarysob.dto.SalarySobItemDTO;
import com.engine.salary.entity.salarysob.dto.SalarySobItemGroupDTO;
import com.engine.salary.entity.salarysob.po.SalarySobEmpFieldPO;
import com.engine.salary.entity.salarysob.po.SalarySobItemPO;
import com.engine.salary.entity.salarysob.po.SalarySobPO;
import com.engine.salary.entity.taxrate.TaxAgent;
import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum;
import com.engine.salary.util.SalaryEntityUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.beans.BeanUtils;
import java.lang.reflect.Field;
import java.util.*;
import java.util.stream.Collectors;
/**
* @description: 薪资核算结果
* @author: xiajun
* @modified By: xiajun
* @date: Created in 12/6/21 7:05 PM
* @version:v1.0
*/
public class SalaryAcctResultBO {
/**
* 数据类型的后悔标识
* 为了展示千分位薪资核算结果列表线上线下对比结果列表需要返回给前端列表字段的数据类型字段索引+后缀标识
*/
private static final String DATA_TYPE_SUFFIX = "_type";
/**
* 构建薪资核算结果列表的表头
*
* @param salarySobItemAggregateDTO
* @return
*/
public static List<WeaTableColumn> buildTableColumns4ComparisonResult(SalarySobItemAggregateDTO salarySobItemAggregateDTO, Set<Long> excludeSalaryItemIds) {
List<WeaTableColumn> columns = Lists.newArrayList();
// 员工信息字段
for (SalarySobEmpFieldDTO salarySobEmpFieldDTO : salarySobItemAggregateDTO.getEmpFields()) {
columns.add(new WeaTableColumn("150", salarySobEmpFieldDTO.getFieldName(), salarySobEmpFieldDTO.getFieldId()));
}
// 薪资项目分组下的薪资项目
for (SalarySobItemGroupDTO salarySobItemGroupDTO : salarySobItemAggregateDTO.getItemGroups()) {
if (CollectionUtils.isEmpty(salarySobItemGroupDTO.getItems())) {
continue;
}
for (SalarySobItemDTO salarySobItemDTO : salarySobItemGroupDTO.getItems()) {
if (excludeSalaryItemIds.contains(salarySobItemDTO.getSalaryItemId())) {
continue;
}
columns.add(new WeaTableColumn("150", salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId()));
}
}
// 没有分类的薪资项目
for (SalarySobItemDTO salarySobItemDTO : salarySobItemAggregateDTO.getItems()) {
if (excludeSalaryItemIds.contains(salarySobItemDTO.getSalaryItemId())) {
continue;
}
columns.add(new WeaTableColumn("150", salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId()));
}
return columns;
}
/**
* 构建薪资核算结果列表的表头
*
* @param salarySobItemAggregateDTO
* @return
*/
public static List<WeaTableColumn> buildTableColumns(SalarySobItemAggregateDTO salarySobItemAggregateDTO) {
List<WeaTableColumn> columns = Lists.newArrayList();
// 员工信息字段
for (SalarySobEmpFieldDTO salarySobEmpFieldDTO : salarySobItemAggregateDTO.getEmpFields()) {
columns.add(new WeaTableColumn("150", salarySobEmpFieldDTO.getFieldName(), salarySobEmpFieldDTO.getFieldId()));
}
// 薪资项目分组下的薪资项目
for (SalarySobItemGroupDTO salarySobItemGroupDTO : salarySobItemAggregateDTO.getItemGroups()) {
if (CollectionUtils.isEmpty(salarySobItemGroupDTO.getItems())) {
continue;
}
// Map<String, Object> group = Maps.newHashMap();
// group.put("groupName", salarySobItemGroupDTO.getName());
// group.put("groupId", String.valueOf(salarySobItemGroupDTO.getId()));
List<WeaTableColumn> childrenColumns = Lists.newArrayList();
for (SalarySobItemDTO salarySobItemDTO : salarySobItemGroupDTO.getItems()) {
columns.add(new WeaTableColumn("150", salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId()));
// childrenColumns.add(new WeaTableColumn("150", salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId()));
}
// group.put("list", childrenColumns);
}
// 没有分类的薪资项目
for (SalarySobItemDTO salarySobItemDTO : salarySobItemAggregateDTO.getItems()) {
columns.add(new WeaTableColumn("150", salarySobItemDTO.getName(), "" + salarySobItemDTO.getSalaryItemId()));
}
return columns;
}
/**
* 转船成薪资核算结果列表的表格数据
*
* @param salaryItems
* @param salarySobEmpFields
* @param simpleEmployees
* @param salaryAcctEmployees
* @param salaryAccountingResults
* @param taxAgents
* @param consolidatedTaxSalaryAcctEmpIds
* @return
*/
public static List<Map<String, Object>> buildTableData(List<SalaryItemPO> salaryItems,
List<SalarySobEmpFieldPO> salarySobEmpFields,
List<DataCollectionEmployee> simpleEmployees,
List<SalaryAcctEmployeePO> salaryAcctEmployees,
List<SalaryAcctResultPO> salaryAccountingResults,
List<TaxAgent> taxAgents,
Set<Long> consolidatedTaxSalaryAcctEmpIds,
Map<Long, String> customParameters) {
if (CollectionUtils.isEmpty(salaryAcctEmployees)) {
return Collections.emptyList();
}
Map<Long, DataCollectionEmployee> employeeMap = SalaryEntityUtil.convert2Map(simpleEmployees, DataCollectionEmployee::getEmployeeId);
Map<Long, List<SalaryAcctResultPO>> acctResultMap = SalaryEntityUtil.group2Map(salaryAccountingResults, SalaryAcctResultPO::getEmployeeId);
Map<Long, String> taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgent::getId, TaxAgent::getName);
return salaryAcctEmployees.stream().map(e -> {
Map<Long, Object> resultValueMap = SalaryEntityUtil.convert2Map(acctResultMap.getOrDefault(e.getEmployeeId(), Collections.emptyList()),
SalaryAcctResultPO::getSalaryItemId, SalaryAcctResultPO::getResultValue);
// 薪资项目的值
Map<String, Object> map = SalaryEntityUtil.convert2Map(salaryItems, o -> "" + o.getId(), o -> resultValueMap.getOrDefault(o.getId(), StringUtils.EMPTY));
// 薪资项目的字段类型前端依据这个判断是否需要展示千分位
Map<String, String> dataTypeMap = SalaryEntityUtil.convert2Map(salaryItems, salaryItemPO -> salaryItemPO.getId() + DATA_TYPE_SUFFIX, SalaryItemPO::getDataType);
map.putAll(dataTypeMap);
// 人员信息字段的值
Map<String, String> fieldValueMap = SalaryAcctFormulaBO.convert2FormulaEmployee(employeeMap.get(e.getEmployeeId()));
for (SalarySobEmpFieldPO salarySobEmpField : salarySobEmpFields) {
map.put(salarySobEmpField.getFieldCode(), fieldValueMap.get(salarySobEmpField.getFieldCode()));
// 员工信息字段的字段类型
map.put(salarySobEmpField.getFieldCode() + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue());
}
// 主键id
map.put("id", e.getId());
// 个税扣缴义务人
String taxAgentName = taxAgentNameMap.getOrDefault(e.getTaxAgentId(), StringUtils.EMPTY);
map.put("taxAgentName", taxAgentName);
// 是否属于"合并计税"的标记
map.put("consolidatedTaxation", StringUtils.isNotEmpty(taxAgentName) && consolidatedTaxSalaryAcctEmpIds.contains(e.getId()));
// 个税扣缴义务人的字段类型
map.put("taxAgentName" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue());
// 公式详情
map.put("customParameters", customParameters);
return map;
}).collect(Collectors.toList());
}
/**
* 转转成薪资核算线下对比结果
*
* @param salaryItems
* @param salarySobEmpFields
* @param simpleEmployees
* @param salaryAcctEmployees
* @param salaryAcctResultPOS
* @param excelAcctResultPOS
* @param taxAgents
* @param consolidatedTaxSalaryAcctEmpIds
* @return
*/
public static List<Map<String, Object>> buildComparisonTableData(List<SalaryItemPO> salaryItems,
List<SalarySobEmpFieldPO> salarySobEmpFields,
List<DataCollectionEmployee> simpleEmployees,
List<SalaryAcctEmployeePO> salaryAcctEmployees,
List<SalaryAcctResultPO> salaryAcctResultPOS,
List<ExcelAcctResultPO> excelAcctResultPOS,
List<TaxAgent> taxAgents,
Map<Long, String> customParameters,
Set<Long> consolidatedTaxSalaryAcctEmpIds,
Set<Long> includeSalaryItemIds) {
if (CollectionUtils.isEmpty(simpleEmployees)) {
return Collections.emptyList();
}
Map<Long, List<ExcelAcctResultPO>> excelResultMap = SalaryEntityUtil.group2Map(excelAcctResultPOS, ExcelAcctResultPO::getSalaryAcctEmpId);
Map<Long, List<SalaryAcctResultPO>> acctResultMap = SalaryEntityUtil.group2Map(salaryAcctResultPOS, SalaryAcctResultPO::getSalaryAcctEmpId);
Map<Long, String> taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgent::getId, TaxAgent::getName);
Map<Long, DataCollectionEmployee> employeeMap = SalaryEntityUtil.convert2Map(simpleEmployees, DataCollectionEmployee::getEmployeeId);
List<Map<String, Object>> resultList = Lists.newArrayListWithExpectedSize(salaryAcctEmployees.size());
for (SalaryAcctEmployeePO salaryAcctEmployee : salaryAcctEmployees) {
// 线下值和系统值之间是否存在差异
boolean different = false;
Map<String, Object> map = Maps.newHashMap();
// 员工信息字段的值
Map<String, String> fieldValueMap = SalaryAcctFormulaBO.convert2FormulaEmployee(employeeMap.get(salaryAcctEmployee.getEmployeeId()));
for (SalarySobEmpFieldPO salarySobEmpField : salarySobEmpFields) {
map.put(salarySobEmpField.getFieldCode(), fieldValueMap.get(salarySobEmpField.getFieldCode()));
// 员工信息字段的字段类型
map.put(salarySobEmpField.getFieldCode() + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue());
}
// 系统值
Map<Long, String> acctResultValueMap = SalaryEntityUtil.convert2Map(acctResultMap.getOrDefault(salaryAcctEmployee.getId(), Collections.emptyList()),
SalaryAcctResultPO::getSalaryItemId, SalaryAcctResultPO::getResultValue);
// 线下值
Map<Long, String> excelResultValueMap = SalaryEntityUtil.convert2Map(excelResultMap.getOrDefault(salaryAcctEmployee.getId(), Collections.emptyList()),
ExcelAcctResultPO::getSalaryItemId, ExcelAcctResultPO::getResultValue);
// 薪资项目字段的值
for (SalaryItemPO salaryItem : salaryItems) {
Map<String, Object> temp = Maps.newHashMap();
// 系统值
String acctResultValue = acctResultValueMap.get(salaryItem.getId());
// 线下值
String excelResultValue = excelResultValueMap.get(salaryItem.getId());
temp.put("acctResultValue", acctResultValue);
temp.put("excelResultValue", excelResultValue);
map.put(String.valueOf(salaryItem.getId()), temp);
// 薪资项目字段的字段类型
map.put(salaryItem.getId() + DATA_TYPE_SUFFIX, salaryItem.getDataType());
SalaryDataTypeEnum dataTypeEnum = SalaryDataTypeEnum.parseByValue(salaryItem.getDataType());
if (dataTypeEnum == SalaryDataTypeEnum.STRING) {
if (!StringUtils.equals(acctResultValue, excelResultValue)) {
different = true;
includeSalaryItemIds.add(salaryItem.getId());
}
} else {
if (SalaryEntityUtil.empty2Zero(acctResultValue).compareTo(SalaryEntityUtil.empty2Zero(excelResultValue)) != 0) {
different = true;
includeSalaryItemIds.add(salaryItem.getId());
}
}
}
// 主键id
map.put("id", salaryAcctEmployee.getId());
// 个税扣缴义务人
String taxAgentName = taxAgentNameMap.getOrDefault(salaryAcctEmployee.getTaxAgentId(), StringUtils.EMPTY);
map.put("taxAgentName", taxAgentName);
// 个税扣缴义务人的字段类型
map.put("taxAgentName" + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue());
// 是否属于"合并计税"的标记
map.put("consolidatedTaxation", StringUtils.isNotEmpty(taxAgentName) && consolidatedTaxSalaryAcctEmpIds.contains(salaryAcctEmployee.getId()));
// 薪资项目的公式详情前端需要展示
map.put("customParameters", customParameters);
// 是否存在差异的标记
map.put("different", different);
resultList.add(map);
}
return resultList;
}
/**
* 转换成薪资核算结果详情dto
*
* @param simpleEmployee
* @param taxAgentPO
* @param salaryAcctEmployee
* @param salarySobEmpFields
* @param salarySobItemPOS
* @param salaryItems
* @param salaryAcctResults
* @return
*/
public static SalaryAcctResultDetailDTO convert2DetailDTO(DataCollectionEmployee simpleEmployee,
TaxAgent taxAgentPO,
SalaryAcctEmployeePO salaryAcctEmployee,
List<SalarySobEmpFieldPO> salarySobEmpFields,
List<SalarySobItemPO> salarySobItemPOS,
List<SalaryItemPO> salaryItems,
List<SalaryAcctResultPO> salaryAcctResults) {
// 员工信息字段
Map<String, String> employeeFieldValueMap = SalaryAcctFormulaBO.convert2FormulaEmployee(simpleEmployee);
// 个税扣缴义务人
employeeFieldValueMap.put("taxAgentName", Optional.ofNullable(taxAgentPO).map(TaxAgent::getName).orElse(StringUtils.EMPTY));
Map<String, String> employeeFieldNameMap = buildEmployeeFieldName();
List<SalaryAcctEmployeeInfoDTO> employeeInfos = salarySobEmpFields.stream()
.map(e -> SalaryAcctEmployeeInfoDTO.builder()
.fieldName(employeeFieldNameMap.getOrDefault(e.getFieldCode(), StringUtils.EMPTY))
.fieldValue(employeeFieldValueMap.getOrDefault(e.getFieldCode(), StringUtils.EMPTY))
.build())
.collect(Collectors.toList());
// 薪资项目的值
Map<Long, String> resultValueMap = SalaryEntityUtil.convert2Map(salaryAcctResults, SalaryAcctResultPO::getSalaryItemId, SalaryAcctResultPO::getResultValue);
Map<Long, SalaryItemPO> salaryItemMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getId);
// 公式项的值不根据salaryItemPO的valueType判断是因为薪资项目的valueType属性改变后并不会同步更新薪资账套中的薪资项目的formulaId字段
List<SalaryAcctResultDetailDTO.SalaryAcctResultDetailItemDTO> formulaItems = salarySobItemPOS.stream()
.filter(salarySobItemPO -> salarySobItemPO.getFormulaId() > 0)
.map(salarySobItemPO -> convert2SalaryAcctResultDetailItemDTO(salarySobItemPO, salaryItemMap.get(salarySobItemPO.getSalaryItemId()), resultValueMap))
.collect(Collectors.toList());
// 输入/导入项目的值
List<SalaryAcctResultDetailDTO.SalaryAcctResultDetailItemDTO> inputItems = salarySobItemPOS.stream()
.filter(salarySobItemPO -> salarySobItemPO.getFormulaId() <= 0)
.map(salarySobItemPO -> convert2SalaryAcctResultDetailItemDTO(salarySobItemPO, salaryItemMap.get(salarySobItemPO.getSalaryItemId()), resultValueMap))
.collect(Collectors.toList());
return SalaryAcctResultDetailDTO.builder()
.id(salaryAcctEmployee.getId())
.employeeId(salaryAcctEmployee.getEmployeeId())
.employeeInfos(employeeInfos)
.formulaItems(formulaItems)
.inputItems(inputItems)
.build();
}
/**
* 转换成薪资核算结果详情dto
*
* @param salarySobItemPO
* @param salaryItemPO
* @param resultValueMap
* @return
*/
private static SalaryAcctResultDetailDTO.SalaryAcctResultDetailItemDTO convert2SalaryAcctResultDetailItemDTO(SalarySobItemPO salarySobItemPO,
SalaryItemPO salaryItemPO,
Map<Long, String> resultValueMap) {
// 薪资项目的数据类型
return SalaryAcctResultDetailDTO.SalaryAcctResultDetailItemDTO.builder()
.salaryItemId(salarySobItemPO.getSalaryItemId())
.salaryItemName(Optional.ofNullable(salaryItemPO).map(SalaryItemPO::getName).orElse(StringUtils.EMPTY))
.resultValue(resultValueMap.getOrDefault(salarySobItemPO.getSalaryItemId(), StringUtils.EMPTY))
.dataType(Optional.ofNullable(salaryItemPO).map(SalaryItemPO::getDataType).orElse(SalaryDataTypeEnum.NUMBER.getValue()))
.build();
}
/**
* 薪资核算结果保存参数转换成薪资核算结果po
*
* @param saveParam 前端保存参数
* @param salaryAcctEmployee 薪资核算人员po
* @param employeeId 当前登陆人员id
* @return
*/
public static List<SalaryAcctResultPO> convert2PO(SalaryAcctResultSaveParam saveParam,
SalaryAcctEmployeePO salaryAcctEmployee,
Long employeeId) {
if (CollectionUtils.isEmpty(saveParam.getItems())) {
return Collections.emptyList();
}
Date now = new Date();
return saveParam.getItems().stream()
.map(e -> SalaryAcctResultPO.builder()
// .id(IdGenerator.generate())
// .salarySobId(salaryAcctEmployee.getSalarySobId())
// .salaryItemId(e.getSalaryItemId())
// .salaryAcctRecordId(salaryAcctEmployee.getSalaryAcctRecordId())
// .salaryAcctEmpId(salaryAcctEmployee.getId())
// .employeeId(salaryAcctEmployee.getEmployeeId())
// .taxAgentId(salaryAcctEmployee.getTaxAgentId())
// .resultValue(e.getResultValue())
// .creator(employeeId)
// .createTime(now)
// .updateTime(now)
// .deleteType(NumberUtils.INTEGER_ZERO)
// .tenantKey(tenantKey)
// .build())
// .collect(Collectors.toList());
// }
//
// public static Map<String, String> buildEmployeeFieldName() {
// Field[] declaredFields = SalaryFormulaEmployeeDTO.class.getDeclaredFields();
// Map<String, String> employeeFieldNameMap = Maps.newHashMapWithExpectedSize(declaredFields.length);
.salarySobId(salaryAcctEmployee.getSalarySobId())
.salaryItemId(e.getSalaryItemId())
.salaryAcctRecordId(salaryAcctEmployee.getSalaryAcctRecordId())
.salaryAcctEmpId(salaryAcctEmployee.getId())
.employeeId(salaryAcctEmployee.getEmployeeId())
.taxAgentId(salaryAcctEmployee.getTaxAgentId())
.resultValue(e.getResultValue())
.creator(employeeId)
.createTime(now)
.updateTime(now)
.deleteType(NumberUtils.INTEGER_ZERO)
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.build())
.collect(Collectors.toList());
}
public static Map<String, String> buildEmployeeFieldName() {
Field[] declaredFields = SalaryFormulaEmployeeDTO.class.getDeclaredFields();
Map<String, String> employeeFieldNameMap = Maps.newHashMapWithExpectedSize(declaredFields.length);
// for (Field declaredField : declaredFields) {
// if (!declaredField.isAnnotationPresent(SalaryFormulaVar.class)) {
// continue;
@ -394,31 +377,31 @@
// SalaryFormulaVar annotation = declaredField.getAnnotation(SalaryFormulaVar.class);
// employeeFieldNameMap.put(declaredField.getName(), SystemEnv.getHtmlLabelName(annotation.labelId(), annotation.defaultLabel()));
// }
// return employeeFieldNameMap;
// }
//
// public static ConsolidatedTaxDetailDTO convert2ConsolidatedTaxDetailDTO(SimpleEmployee simpleEmployee,
// TaxAgentPO taxAgent,
// List<SalarySobEmpFieldPO> salarySobEmpFields,
// List<SalaryItemPO> salaryItems,
// List<SalaryAcctEmployeePO> salaryAcctEmployees,
// List<SalarySobPO> salarySobs,
// List<SalaryAcctRecordPO> salaryAcctRecords,
// List<SalaryAcctResultPO> salaryAcctResults) {
// return ConsolidatedTaxDetailDTO.builder()
return employeeFieldNameMap;
}
public static ConsolidatedTaxDetailDTO convert2ConsolidatedTaxDetailDTO(DataCollectionEmployee simpleEmployee,
TaxAgent taxAgent,
List<SalarySobEmpFieldPO> salarySobEmpFields,
List<SalaryItemPO> salaryItems,
List<SalaryAcctEmployeePO> salaryAcctEmployees,
List<SalarySobPO> salarySobs,
List<SalaryAcctRecordPO> salaryAcctRecords,
List<SalaryAcctResultPO> salaryAcctResults) {
return ConsolidatedTaxDetailDTO.builder()
// .employeeInfo(buildConsolidatedTaxationEmpInfo(simpleEmployee, taxAgent, salarySobEmpFields))
// .salaryAcctResult(buildConsolidatedTaxationAcctResult(salaryItems, salaryAcctEmployees, salarySobs, salaryAcctRecords, salaryAcctResults))
// .build();
// }
//
// /**
// * 合并计税详情-员工信息
// *
// * @param simpleEmployee
// * @param salarySobEmpFields
// * @return
// */
// private static WeaForm buildConsolidatedTaxationEmpInfo(SimpleEmployee simpleEmployee, TaxAgentPO taxAgent, List<SalarySobEmpFieldPO> salarySobEmpFields) {
.build();
}
/**
* 合并计税详情-员工信息
*
* @param simpleEmployee
* @param salarySobEmpFields
* @return
*/
// private static WeaForm buildConsolidatedTaxationEmpInfo(DataCollectionEmployee simpleEmployee, TaxAgent taxAgent, List<SalarySobEmpFieldPO> salarySobEmpFields) {
// Map<String, String> employeeFieldNameMap = buildEmployeeFieldName();
// Map<String, String> fieldValueMap = SalaryAcctFormulaBO.convert2FormulaEmployee(simpleEmployee);
// fieldValueMap.put("taxAgentName", taxAgent.getName());
@ -451,15 +434,15 @@
// weaForm.setLayout(layout);
// return weaForm;
// }
//
//
// /**
// * 合并计税详情-核算结果列表
// *
// * @param salaryItems
// * @param salaryAcctResults
// * @return
// */
/**
* 合并计税详情-核算结果列表
*
* @param salaryItems
* @param salaryAcctResults
* @return
*/
// private static WeaTable<Map<String, Object>> buildConsolidatedTaxationAcctResult(List<SalaryItemPO> salaryItems,
// List<SalaryAcctEmployeePO> salaryAcctEmployees,
// List<SalarySobPO> salarySobs,
@ -501,21 +484,21 @@
// weaTable.setDisplayData(data);
// return weaTable;
// }
//
// /**
// * 薪资核算结果临时存储转成薪资核算结果po
// *
// * @param temps
// * @return
// */
// public static List<SalaryAcctResultPO> convert2ResultPO(Collection<SalaryAcctResultTempPO> temps) {
// if (CollectionUtils.isEmpty(temps)) {
// return Collections.emptyList();
// }
// return temps.stream().map(e -> {
// SalaryAcctResultPO salaryAcctResult = new SalaryAcctResultPO();
// BeanUtils.copyProperties(e, salaryAcctResult);
// return salaryAcctResult;
// }).collect(Collectors.toList());
// }
//}
/**
* 薪资核算结果临时存储转成薪资核算结果po
*
* @param temps
* @return
*/
public static List<SalaryAcctResultPO> convert2ResultPO(Collection<SalaryAcctResultTempPO> temps) {
if (CollectionUtils.isEmpty(temps)) {
return Collections.emptyList();
}
return temps.stream().map(e -> {
SalaryAcctResultPO salaryAcctResult = new SalaryAcctResultPO();
BeanUtils.copyProperties(e, salaryAcctResult);
return salaryAcctResult;
}).collect(Collectors.toList());
}
}

View File

@ -27,13 +27,13 @@
//@ApiModel("核算结果列表")
//public class SalaryAccResultListDTO {
//
// @ApiModelProperty("动态表头")
// //动态表头")
// private List<WeaTableColumnWapper> columns;
//
// @ApiModelProperty("列表数据")
// //列表数据")
// private List<Map<String, Object>> data;
//
// @JsonSerialize(using = ToStringSerializer.class)
// @ApiModelProperty("列表总数")
// //列表总数")
// private Long total;
//}

View File

@ -19,6 +19,6 @@
//@AllArgsConstructor
//public class SalaryAcctDTO {
//
// @ApiModelProperty("是否正在核算")
// //是否正在核算")
// private boolean acctInProgress;
//}

View File

@ -15,9 +15,9 @@ import lombok.experimental.Accessors;
@Accessors(chain = true)
public class SalaryAcctEmployeeCountDTO {
// @ApiModelProperty("薪资核算记录id")
// //薪资核算记录id")
private Long salaryAcctRecordId;
// @ApiModelProperty("薪资核算人员的数量")
// //薪资核算人员的数量")
private Long countBySalaryAcctRecordId;
}

View File

@ -21,10 +21,10 @@
//@AllArgsConstructor
//public class SalaryAcctImportFieldDTO {
//
// @ApiModelProperty("公式项")
// //公式项")
// private Collection<ImportFieldDTO> formulaItems;
//
// @ApiModelProperty("输入项")
// //输入项")
// private Collection<ImportFieldDTO> inputItems;
//
// @Data
@ -33,10 +33,10 @@
// @AllArgsConstructor
// public static class ImportFieldDTO {
//
// @ApiModelProperty("薪资项目id")
// //薪资项目id")
// private Long salaryItemId;
//
// @ApiModelProperty("薪资项目名称")
// //薪资项目名称")
// private String salaryItemName;
// }
//}

View File

@ -31,10 +31,10 @@
//)
//public class SalaryCheckResultListDTO {
//
// @ApiModelProperty("主键id")
// //主键id")
// private Long id;
//
// @ApiModelProperty("校验规则id")
// //校验规则id")
// private Long checkRuleId;
//
// @SalaryTableColumn(
@ -42,7 +42,7 @@
// labelId = 92455,
// width = "30%"
// )
// @ApiModelProperty("异常所属规则名称")
// //异常所属规则名称")
// private String checkRuleName;
//
// @SalaryTableColumn(
@ -50,10 +50,10 @@
// labelId = 92456,
// width = "20%"
// )
// @ApiModelProperty("异常人数")
// //异常人数")
// private Long employeeSize;
//
// @ApiModelProperty("校验规则公式id")
// //校验规则公式id")
// private Long formulaId;
//
// @SalaryTableColumn(
@ -61,6 +61,6 @@
// labelId = 86126,
// width = "50%"
// )
// @ApiModelProperty("校验规则公式内容")
// //校验规则公式内容")
// private String formulaContent;
//}

View File

@ -24,10 +24,10 @@
//)
//public class SalaryCheckResultRecordListDTO {
//
// @ApiModelProperty("主键id")
// //主键id")
// private Long id;
//
// @ApiModelProperty("校验规则id")
// //校验规则id")
// private Long checkRuleId;
//
// @SalaryTableColumn(
@ -35,10 +35,10 @@
// labelId = 92455,
// width = "30%"
// )
// @ApiModelProperty("异常所属规则名称")
// //异常所属规则名称")
// private String checkRuleName;
//
// @ApiModelProperty("校验规则公式id")
// //校验规则公式id")
// private Long formulaId;
//
// @SalaryTableColumn(
@ -46,10 +46,10 @@
// labelId = 86126,
// width = "50%"
// )
// @ApiModelProperty("校验规则公式内容")
// //校验规则公式内容")
// private String formulaContent;
//
// @ApiModelProperty("人员id")
// //人员id")
// private Long employeeId;
//
// @SalaryTableColumn(
@ -57,6 +57,6 @@
// labelId = 85429,
// width = "20%"
// )
// @ApiModelProperty("人员姓名")
// //人员姓名")
// private String employeeName;
//}

View File

@ -24,9 +24,9 @@
//@AllArgsConstructor
//public class SalaryComparisonResultListDTO {
//
// @ApiModelProperty("列表的表头")
// //列表的表头")
// private List<WeaTableColumn> weaTableColumns;
//
// @ApiModelProperty("列表数据")
// //列表数据")
// private Page<Map<String, Object>> data;
//}

View File

@ -27,13 +27,13 @@
// /**
// * 不是employeeId而是salaryAcctEmpId
// */
// @ApiModelProperty("核算人员的id")
// //核算人员的id")
// private Collection<Long> ids;
//
// /**
// * 参数错误薪资核算记录ID不能为空
// */
// @NotNull(message = "LABEL:99845")
// @ApiModelProperty("薪资核算记录id")
// //薪资核算记录id")
// private Long salaryAcctRecordId;
//}

View File

@ -28,9 +28,9 @@
// * 薪资项目id不能为空
// */
// @NotEmpty(message = "LABEL:93297")
// @ApiModelProperty("薪资项目id")
// //薪资项目id")
// private Collection<Long> salaryItemIds;
//
// @ApiModelProperty("是否导出数据")
// //是否导出数据")
// private String importType;
//}

View File

@ -22,13 +22,13 @@
//@AllArgsConstructor
//public class SalaryCheckResultExportParam {
//
// @ApiModelProperty("指定导出的id")
// //指定导出的id")
// private Collection<Long> ids;
//
// /**
// * 参数错误薪资核算记录ID不能为空
// */
// @NotNull(message = "LABEL:99845")
// @ApiModelProperty("薪资核算记录的id")
// //薪资核算记录的id")
// private Long salaryAcctRecordId;
//}

View File

@ -28,6 +28,6 @@
// * 参数错误薪资核算记录ID不能为空
// */
// @NotNull(message = "LABEL:99845")
// @ApiModelProperty("薪资核算的id")
// //薪资核算的id")
// private Long salaryAcctRecordId;
//}

View File

@ -28,6 +28,6 @@
// * 核算异常的id不能为空
// */
// @NotNull(message = "LABEL:99849")
// @ApiModelProperty("校验结果id")
// //校验结果id")
// private Long checkResultId;
//}

View File

@ -19,6 +19,6 @@
// * 参数错误薪资核算记录ID不能为空
// */
// @NotNull(message = "LABEL:99845")
// @ApiModelProperty("薪资核算记录id")
// //薪资核算记录id")
// private Long salaryAcctRecordId;
//}

View File

@ -15,9 +15,9 @@
//@EqualsAndHashCode(callSuper = true)
//public class SalaryComparisonResultQueryParam extends SalaryAcctResultQueryParam {
//
// @ApiModelProperty("仅显示有差异的人员")
// //仅显示有差异的人员")
// private boolean onlyDiffEmployee;
//
// @ApiModelProperty("仅显示有差异的薪资项目")
// //仅显示有差异的薪资项目")
// private boolean onlyDiffSalaryItem;
//}

View File

@ -5,15 +5,17 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Date;
/**
* @description: 薪资核算结果
* @author: xiajun
* @modified By: xiajun
* @date: Created in 11/30/21 1:39 PM
* @version:v1.0
*/
* 薪资核算结果
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Data
@Builder
@NoArgsConstructor
@ -79,10 +81,16 @@ public class SalaryAcctResultPO {
/**
* 创建时间
*/
private LocalDateTime createTime;
private Date createTime;
/**
* 更新时间
*/
private LocalDateTime updateTime;
private Date updateTime;
//条件
private Collection<Long> ids;
private Collection<Long> salaryAcctRecordIds;
private Collection<Long> salaryAcctEmpIds;
private Collection<Long> employeeIds;
}

View File

@ -0,0 +1,32 @@
package com.engine.salary.entity.salaryformula.bo;
import com.engine.salary.entity.salaryformula.dto.ExpressFormulaDTO;
import com.weaver.excel.formula.api.entity.ExpressFormula;
import org.apache.commons.collections4.CollectionUtils;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
* @description: 薪酬管理公式
* @author: xiajun
* @modified By: xiajun
* @date: Created in 12/7/21 5:49 PM
* @version:v1.0
*/
public class SalaryFormulaBO {
public static List<ExpressFormulaDTO> convert2DTO(List<ExpressFormula> expressFormulas) {
if (CollectionUtils.isEmpty(expressFormulas)) {
return Collections.emptyList();
}
return expressFormulas.stream()
.map(e -> ExpressFormulaDTO.builder()
.id(e.getId())
.name(e.getName())
.formula(e.getFormula())
.build())
.collect(Collectors.toList());
}
}

View File

@ -0,0 +1,30 @@
package com.engine.salary.entity.salaryformula.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 薪酬管理公式
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ExpressFormulaDTO {
//公式idTaxAgent
private Long id;
//公式名称TaxAgent
private String name;
//公式表达式TaxAgent
private String formula;
}

View File

@ -0,0 +1,64 @@
package com.engine.salary.entity.salaryformula.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @description: 薪资公式计算器-员工基本信息
* @author: xiajun
* @modified By: xiajun
* @date: Created in 11/19/21 1:46 PM
* @version:v1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SalaryFormulaEmployeeDTO {
private Long employeeId;
//个税扣缴义务人", labelId = 86184, dataType = "string")
private String taxAgentName;
//姓名", labelId = 85429, dataType = "string")
private String username;
//邮件", labelId = 92919, dataType = "string")
private String email;
//手机", labelId = 98621, dataType = "string")
private String mobile;
//电话", labelId = 98620, dataType = "string")
private String telephone;
// //证件号码", labelId = 86318, dataType = "string")
// private String idNo;
//性别", labelId = 98622, dataType = "string")
private String sex;
//状态", labelId = 91075, dataType = "string")
private String status;
//部门", labelId = 86185, dataType = "string")
private String departmentName;
//岗位", labelId = 90633, dataType = "string")
private String positionName;
//职级", labelId = 98623, dataType = "string")
private String gradeName;
//入职日期", labelId = 86319, dataType = "string")
private String hireDate;
//出生日期", labelId = 98624, dataType = "string")
private String birthday;
// //首次参加工作日期", labelId = 98625, dataType = "string")
// private String firstWorkDate;
}

View File

@ -0,0 +1,70 @@
package com.engine.salary.entity.salaryformula.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* @description: 薪资公式计算器-个税税率表
* @author: xiajun
* @modified By: xiajun
* @date: Created in 11/30/21 5:03 PM
* @version:v1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SalaryFormulaTaxRateDTO {
/**
* 收入上限
*/
//收入上限", labelId = 84222, dataType = "number", fieldId = "income_upper_limit")
private BigDecimal incomeUpperLimit;
/**
* 收入下限不含
*/
//收入下限不含", labelId = 84218, dataType = "number", fieldId = "income_lower_limit")
private BigDecimal incomeLowerLimit;
/**
* 免税标准-固定值
*/
//免税标准固定值", labelId = 84223, dataType = "number", fieldId = "duty_free_value")
private BigDecimal dutyFreeValue;
/**
* 免税标准-比例
*/
//免税标准比例", labelId = 84224, dataType = "number", fieldId = "duty_free_rate")
private BigDecimal dutyFreeRate;
/**
* 应纳税所得额上限
*/
//应纳税所得额上限", labelId = 84226, dataType = "number", fieldId = "taxable_income_ul")
private BigDecimal taxableIncomeULimit;
/**
* 应纳税所得额下限不含
*/
//应纳税所得额下限", labelId = 84225, dataType = "number", fieldId = "taxable_income_ll")
private BigDecimal taxableIncomeLLimit;
/**
* 税率
*/
//税率", labelId = 84227, dataType = "number", fieldId = "tax_rate")
private BigDecimal taxRate;
/**
* 速算扣除数
*/
//速算扣除数", labelId = 84228, dataType = "number", fieldId = "tax_deduction")
private BigDecimal taxDeduction;
}

View File

@ -32,4 +32,6 @@ public interface EmployMapper {
* @return
*/
List<DataCollectionEmployee> listByParams(@Param("params") Collection<SalarySobRangeEmpQueryParam> queryParams);
DataCollectionEmployee getEmployeeById(Long employeeId);
}

View File

@ -126,4 +126,23 @@
</select>
<select id="getEmployeeById" resultType="com.engine.salary.entity.datacollection.DataCollectionEmployee">
select e.id as employeeId,
e.lastname as username,
e.status as status,
e.workcode as workcode,
d.departmentname as departmentName,
d.id as departmentId,
c.jobtitlename as jobtitleName,
e.companystartdate as companystartdate,
e.mobile as mobile,
b.dismissdate as dismissdate
from hrmresource e
left join hrmdepartment d on e.departmentid = d.id
left join hrmjobtitles c on e.jobtitle = c.id
left join bill_hrmdismiss b on e.id = b.resource_n
where e.status not in (7)
AND e.id = #{id}
</select>
</mapper>

View File

@ -0,0 +1,118 @@
package com.engine.salary.mapper.salaryacct;
import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
public interface SalaryAcctResultMapper {
/**
* 查询所有记录
*
* @return 返回集合没有返回空List
*/
List<SalaryAcctResultPO> listAll();
/**
* 条件查询
*
* @return 返回集合没有返回空List
*/
List<SalaryAcctResultPO> listSome(SalaryAcctResultPO salaryAcctResult);
/**
* 根据主键查询
*
* @param id 主键
* @return 返回记录没有返回null
*/
SalaryAcctResultPO getById(Long id);
/**
* 新增忽略null字段
*
* @param salaryAcctResult 新增的记录
* @return 返回影响行数
*/
int insertIgnoreNull(SalaryAcctResultPO salaryAcctResult);
/**
* 修改修改所有字段
*
* @param salaryAcctResult 修改的记录
* @return 返回影响行数
*/
int update(SalaryAcctResultPO salaryAcctResult);
/**
* 修改忽略null字段
*
* @param salaryAcctResult 修改的记录
* @return 返回影响行数
*/
int updateIgnoreNull(SalaryAcctResultPO salaryAcctResult);
/**
* 删除记录
*
* @param salaryAcctResult 待删除的记录
* @return 返回影响行数
*/
int delete(SalaryAcctResultPO salaryAcctResult);
/**
* 查询同一个薪资所属月内的所有核算结果
*
* @param salaryAcctRecordIds
* @param tenantKey
* @return
*/
List<SalaryAcctResultPO> listSameSalaryMonthResult(@Param("salaryAcctRecordIds") Collection<Long> salaryAcctRecordIds,
@Param("tenantKey") String tenantKey);
/**
* 批量新增
*
* @param salaryAccountingResults
*/
void batchInsert(@Param("collection") Collection<SalaryAcctResultPO> salaryAccountingResults);
/**
* 根据薪资核算id删除薪资核算结果
*
* @param salaryAcctRecordIds
* @param tenantKey
*/
void deleteBySalaryAcctRecordIds(@Param("salaryAcctRecordIds") Collection<Long> salaryAcctRecordIds);
/**
* 根据薪资核算id删除薪资核算结果
*
* @param salaryAcctEmpIds
* @param tenantKey
*/
void deleteBySalaryAcctEmpIds(@Param("salaryAcctEmpIds") Collection<Long> salaryAcctEmpIds);
/**
* 根据薪资核算id薪资项目id删除薪资核算结果
*
* @param salaryAcctEmpIds
* @param salaryItemIds
* @param tenantKey
*/
void deleteByAcctEmpIdsAndSalaryItemIds(@Param("salaryAcctEmpIds") Collection<Long> salaryAcctEmpIds,
@Param("salaryItemIds") Collection<Long> salaryItemIds);
/**
* 根据薪资核算id删除薪资核算结果
*
* @param ids
* @param tenantKey
*/
void deleteByIds(@Param("ids") Collection<Long> ids);
}

View File

@ -0,0 +1,444 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.engine.salary.mapper.salaryacct.SalaryAcctResultMapper">
<resultMap id="BaseResultMap" type="com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO">
<result column="id" property="id"/>
<result column="salary_sob_id" property="salarySobId"/>
<result column="salary_acct_emp_id" property="salaryAcctEmpId"/>
<result column="salary_acct_record_id" property="salaryAcctRecordId"/>
<result column="employee_id" property="employeeId"/>
<result column="tax_agent_id" property="taxAgentId"/>
<result column="salary_item_id" property="salaryItemId"/>
<result column="result_value" property="resultValue"/>
<result column="creator" property="creator"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="delete_type" property="deleteType"/>
<result column="tenant_key" property="tenantKey"/>
</resultMap>
<!-- 表字段 -->
<sql id="baseColumns">
t
.
id
, t.salary_sob_id
, t.salary_acct_emp_id
, t.salary_acct_record_id
, t.employee_id
, t.tax_agent_id
, t.salary_item_id
, t.result_value
, t.creator
, t.create_time
, t.update_time
, t.delete_type
, t.tenant_key
</sql>
<!-- 查询全部 -->
<select id="listAll" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM hrsa_salary_acct_result t
WHERE delete_type = 0
</select>
<!-- 根据主键获取单条记录 -->
<select id="getById" resultMap="BaseResultMap" parameterType="Long">
SELECT
<include refid="baseColumns"/>
FROM hrsa_salary_acct_result t
WHERE id = #{id} AND delete_type = 0
</select>
<!-- 条件查询 -->
<select id="listSome" resultMap="BaseResultMap"
parameterType="com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO">
SELECT
<include refid="baseColumns"/>
FROM hrsa_salary_acct_result t
WHERE delete_type = 0
<if test="id != null">
AND id = #{id}
</if>
<if test="salarySobId != null">
AND salary_sob_id = #{salarySobId}
</if>
<if test="salaryAcctEmpId != null">
AND salary_acct_emp_id = #{salaryAcctEmpId}
</if>
<if test="salaryAcctRecordId != null">
AND salary_acct_record_id = #{salaryAcctRecordId}
</if>
<if test="employeeId != null">
AND employee_id = #{employeeId}
</if>
<if test="taxAgentId != null">
AND tax_agent_id = #{taxAgentId}
</if>
<if test="salaryItemId != null">
AND salary_item_id = #{salaryItemId}
</if>
<if test="resultValue != null">
AND result_value = #{resultValue}
</if>
<if test="creator != null">
AND creator = #{creator}
</if>
<if test="createTime != null">
AND create_time = #{createTime}
</if>
<if test="updateTime != null">
AND update_time = #{updateTime}
</if>
<if test="deleteType != null">
AND delete_type = #{deleteType}
</if>
<if test="tenantKey != null">
AND tenant_key = #{tenantKey}
</if>
<if test="ids != null and ids.size()>0">
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</if>
<if test="salaryAcctRecordIds != null and salaryAcctRecordIds.size()>0">
AND salary_acct_record_id IN
<foreach collection="salaryAcctRecordIds" open="(" item="salaryAcctRecordId" separator="," close=")">
#{salaryAcctRecordId}
</foreach>
</if>
<if test="salaryAcctEmpIds != null and salaryAcctEmpIds.size()>0">
AND salary_acct_emp_id IN
<foreach collection="salaryAcctEmpIds" open="(" item="salaryAcctEmpId" separator="," close=")">
#{salaryAcctEmpId}
</foreach>
</if>
<if test="employeeIds != null and employeeIds.size()>0">
AND employee_id IN
<foreach collection="employeeIds" open="(" item="employeeId" separator="," close=")">
#{employeeId}
</foreach>
</if>
ORDER BY id DESC
</select>
<!-- 插入不为NULL的字段 -->
<insert id="insertIgnoreNull" parameterType="com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO"
keyProperty="id" keyColumn="id" useGeneratedKeys="true"
>
INSERT INTO hrsa_salary_acct_result
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="salarySobId != null">
salary_sob_id,
</if>
<if test="salaryAcctEmpId != null">
salary_acct_emp_id,
</if>
<if test="salaryAcctRecordId != null">
salary_acct_record_id,
</if>
<if test="employeeId != null">
employee_id,
</if>
<if test="taxAgentId != null">
tax_agent_id,
</if>
<if test="salaryItemId != null">
salary_item_id,
</if>
<if test="resultValue != null">
result_value,
</if>
<if test="creator != null">
creator,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="deleteType != null">
delete_type,
</if>
<if test="tenantKey != null">
tenant_key,
</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id},
</if>
<if test="salarySobId != null">
#{salarySobId},
</if>
<if test="salaryAcctEmpId != null">
#{salaryAcctEmpId},
</if>
<if test="salaryAcctRecordId != null">
#{salaryAcctRecordId},
</if>
<if test="employeeId != null">
#{employeeId},
</if>
<if test="taxAgentId != null">
#{taxAgentId},
</if>
<if test="salaryItemId != null">
#{salaryItemId},
</if>
<if test="resultValue != null">
#{resultValue},
</if>
<if test="creator != null">
#{creator},
</if>
<if test="createTime != null">
#{createTime},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
<if test="deleteType != null">
#{deleteType},
</if>
<if test="tenantKey != null">
#{tenantKey},
</if>
</trim>
</insert>
<!-- 更新,更新全部字段 -->
<update id="update" parameterType="com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO">
UPDATE hrsa_salary_acct_result
<set>
salary_sob_id=#{salarySobId},
salary_acct_emp_id=#{salaryAcctEmpId},
salary_acct_record_id=#{salaryAcctRecordId},
employee_id=#{employeeId},
tax_agent_id=#{taxAgentId},
salary_item_id=#{salaryItemId},
result_value=#{resultValue},
creator=#{creator},
create_time=#{createTime},
update_time=#{updateTime},
delete_type=#{deleteType},
tenant_key=#{tenantKey},
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<!-- 更新不为NULL的字段 -->
<update id="updateIgnoreNull" parameterType="com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO">
UPDATE hrsa_salary_acct_result
<set>
<if test="salarySobId != null">
salary_sob_id=#{salarySobId},
</if>
<if test="salaryAcctEmpId != null">
salary_acct_emp_id=#{salaryAcctEmpId},
</if>
<if test="salaryAcctRecordId != null">
salary_acct_record_id=#{salaryAcctRecordId},
</if>
<if test="employeeId != null">
employee_id=#{employeeId},
</if>
<if test="taxAgentId != null">
tax_agent_id=#{taxAgentId},
</if>
<if test="salaryItemId != null">
salary_item_id=#{salaryItemId},
</if>
<if test="resultValue != null">
result_value=#{resultValue},
</if>
<if test="creator != null">
creator=#{creator},
</if>
<if test="createTime != null">
create_time=#{createTime},
</if>
<if test="updateTime != null">
update_time=#{updateTime},
</if>
<if test="deleteType != null">
delete_type=#{deleteType},
</if>
<if test="tenantKey != null">
tenant_key=#{tenantKey},
</if>
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<!-- 根据主键删除记录 -->
<delete id="delete" parameterType="com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO">
UPDATE hrsa_salary_acct_result
SET delete_type=1
WHERE id = #{id}
AND delete_type = 0
</delete>
<resultMap id="SalaryAcctResultMap" type="com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO">
<id column="id" property="id"/>
<result column="salary_sob_id" property="salarySobId"/>
<result column="salary_acct_emp_id" property="salaryAcctEmpId"/>
<result column="salary_acct_record_id" property="salaryAcctRecordId"/>
<result column="employee_id" property="employeeId"/>
<result column="tax_agent_id" property="taxAgentId"/>
<result column="salary_item_id" property="salaryItemId"/>
<result column="result_value" property="resultValue"/>
<result column="creator" property="creator"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="tenant_key" property="tenantKey"/>
</resultMap>
<sql id="SalaryAcctResultColumn">
id
, salary_sob_id, salary_acct_emp_id, salary_acct_record_id, employee_id, tax_agent_id,
salary_item_id, result_value, creator, create_time, update_time,
delete_type, tenant_key
</sql>
<select id="listSameSalaryMonthResult" resultMap="SalaryAcctResultMap">
SELECT
<include refid="SalaryAcctResultColumn"/>
FROM hrsa_salary_acct_result
WHERE tenant_key = #{tenantKey} AND delete_type = 0
AND salary_acct_record_id IN
<foreach collection="salaryAcctRecordIds" open="(" item="salaryAcctRecordId" separator="," close=")">
#{salaryAcctRecordId}
</foreach>
AND salary_acct_emp_id IN
(
SELECT id FROM hrsa_salary_acct_emp emp
WHERE emp.tenant_key = #{tenantKey} AND emp.delete_type = 0
AND emp.salary_acct_record_id IN
<foreach collection="salaryAcctRecordIds" open="(" item="salaryAcctRecordId" separator="," close=")">
#{salaryAcctRecordId}
</foreach>
)
</select>
<insert id="batchInsert">
INSERT INTO hrsa_salary_acct_result(id, salary_sob_id, salary_acct_emp_id, salary_acct_record_id, employee_id,
tax_agent_id, salary_item_id, result_value, creator, create_time, update_time, delete_type, tenant_key)
VALUES
<foreach collection="collection" item="item" separator=",">
(
#{item.id},
#{item.salarySobId},
#{item.salaryAcctEmpId},
#{item.salaryAcctRecordId},
#{item.employeeId},
#{item.taxAgentId},
#{item.salaryItemId},
#{item.resultValue},
#{item.creator},
#{item.createTime},
#{item.updateTime},
#{item.deleteType},
#{item.tenantKey}
)
</foreach>
</insert>
<insert id="batchInsert" databaseId="oracle">
INSERT INTO hrsa_salary_acct_result(id, salary_sob_id, salary_acct_emp_id, salary_acct_record_id, employee_id,
tax_agent_id, salary_item_id, result_value, creator, create_time, update_time, delete_type, tenant_key)
<foreach collection="collection" item="item" separator="union all">
select
#{item.id},
#{item.salarySobId},
#{item.salaryAcctEmpId},
#{item.salaryAcctRecordId},
#{item.employeeId},
#{item.taxAgentId},
#{item.salaryItemId},
#{item.resultValue},
#{item.creator},
#{item.createTime},
#{item.updateTime},
#{item.deleteType},
#{item.tenantKey}
from dual
</foreach>
</insert>
<insert id="batchInsert" databaseId="sqlserver">
INSERT INTO hrsa_salary_acct_result(id, salary_sob_id, salary_acct_emp_id, salary_acct_record_id, employee_id,
tax_agent_id, salary_item_id, result_value, creator, create_time, update_time, delete_type, tenant_key)
VALUES
<foreach collection="collection" item="item" separator=",">
(
#{item.id},
#{item.salarySobId},
#{item.salaryAcctEmpId},
#{item.salaryAcctRecordId},
#{item.employeeId},
#{item.taxAgentId},
#{item.salaryItemId},
#{item.resultValue},
#{item.creator},
#{item.createTime},
#{item.updateTime},
#{item.deleteType},
#{item.tenantKey}
)
</foreach>
</insert>
<delete id="deleteBySalaryAcctRecordIds">
DELETE FROM hrsa_salary_acct_result
WHERE tenant_key = #{tenantKey} AND delete_type = 0
AND salary_acct_record_id IN
<foreach collection="salaryAcctRecordIds" open="(" item="salaryAcctRecordId" separator="," close=")">
#{salaryAcctRecordId}
</foreach>
</delete>
<delete id="deleteBySalaryAcctEmpIds">
DELETE FROM hrsa_salary_acct_result
WHERE tenant_key = #{tenantKey} AND delete_type = 0
AND salary_acct_emp_id IN
<foreach collection="salaryAcctEmpIds" open="(" item="salaryAcctEmpId" separator="," close=")">
#{salaryAcctEmpId}
</foreach>
</delete>
<delete id="deleteByAcctEmpIdsAndSalaryItemIds">
DELETE FROM hrsa_salary_acct_result
WHERE tenant_key = #{tenantKey} AND delete_type = 0
AND salary_acct_emp_id IN
<foreach collection="salaryAcctEmpIds" open="(" item="salaryAcctEmpId" separator="," close=")">
#{salaryAcctEmpId}
</foreach>
AND salary_item_id IN
<foreach collection="salaryItemIds" open="(" item="salaryItemId" separator="," close=")">
#{salaryItemId}
</foreach>
</delete>
<delete id="deleteByIds">
DELETE FROM hrsa_salary_acct_result
WHERE tenant_key = #{tenantKey} AND delete_type = 0
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -1,12 +1,11 @@
package com.engine.salary.service;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salaryacct.dto.ConsolidatedTaxDetailDTO;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultDetailDTO;
import com.engine.salary.entity.salaryacct.param.SalaryAcctCalculateParam;
import com.engine.salary.entity.salaryacct.param.SalaryAcctResultQueryParam;
import com.engine.salary.entity.salaryacct.param.SalaryAcctResultSaveParam;
import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO;
import com.engine.salary.util.page.PageInfo;
import java.util.Collection;
import java.util.List;
@ -69,7 +68,7 @@ public interface SalaryAcctResultService {
* @param queryParam 列表查询条件
* @return
*/
// Page<Map<String, Object>> listPageByParam(SalaryAcctResultQueryParam queryParam);
PageInfo<Map<String, Object>> listPageByParam(SalaryAcctResultQueryParam queryParam);
/**
* 根据薪资核算结果列表查询条件查询薪资核算结果
@ -91,9 +90,8 @@ public interface SalaryAcctResultService {
* 保存
*
* @param saveParam 保存参数
* @param employeeId 人员id
*/
void save(SalaryAcctResultSaveParam saveParam, Long employeeId);
void save(SalaryAcctResultSaveParam saveParam);
/**
* 批量保存
@ -124,11 +122,11 @@ public interface SalaryAcctResultService {
*/
void deleteBySalaryAcctRecordIds(Collection<Long> salaryAcctRecordIds);
/**
* 薪资核算
*
* @param calculateParam
* @param simpleEmployee
*/
void calculate(SalaryAcctCalculateParam calculateParam, DataCollectionEmployee simpleEmployee);
// /**
// * 薪资核算
// *
// * @param calculateParam
// * @param simpleEmployee
// */
// void calculate(SalaryAcctCalculateParam calculateParam, DataCollectionEmployee simpleEmployee);
}

View File

@ -37,4 +37,5 @@ public interface SalaryEmployeeService {
*/
List<DataCollectionEmployee> listByIds(List<Long> ids);
DataCollectionEmployee getEmployeeById(Long employeeId);
}

View File

@ -1,336 +1,293 @@
//package com.engine.salary.service.impl;
//
//import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
//import com.engine.core.impl.Service;
//import com.engine.salary.service.SalaryAcctResultService;
//import com.google.common.collect.Lists;
//import com.weaver.common.component.table.page.Page;
//import com.weaver.common.elog.dto.LoggerContext;
//import com.weaver.common.elog.util.LoggerTemplate;
//import com.weaver.common.hrm.service.HrmCommonEmployeeService;
//import com.weaver.common.threadPool.ThreadPoolUtil;
//import com.weaver.common.threadPool.constant.ModulePoolEnum;
//import com.weaver.common.threadPool.entity.LocalRunnable;
//import com.weaver.datasecurity.interceptor.DSTenantKeyThreadVar;
//import com.weaver.excel.formula.api.entity.ExpressFormula;
//import com.weaver.hrm.salary.common.LocalDateRange;
//import com.weaver.hrm.salary.dao.SalaryAcctResultMapper;
//import com.weaver.hrm.salary.entity.datacollection.dto.AttendQuoteFieldListDTO;
//import com.weaver.hrm.salary.entity.salaryacct.bo.SalaryAcctCalculateBO;
//import com.weaver.hrm.salary.entity.salaryacct.bo.SalaryAcctCalculatePriorityBO;
//import com.weaver.hrm.salary.entity.salaryacct.bo.SalaryAcctResultBO;
//import com.weaver.hrm.salary.entity.salaryacct.dto.ConsolidatedTaxDetailDTO;
//import com.weaver.hrm.salary.entity.salaryacct.dto.SalaryAcctProgressDTO;
//import com.weaver.hrm.salary.entity.salaryacct.dto.SalaryAcctResultDetailDTO;
//import com.weaver.hrm.salary.entity.salaryacct.param.*;
//import com.weaver.hrm.salary.entity.salaryacct.po.*;
//import com.weaver.hrm.salary.entity.salaryarchive.po.TaxAgentPO;
//import com.weaver.hrm.salary.entity.salaryitem.po.SalaryItemPO;
//import com.weaver.hrm.salary.entity.salarysob.dto.SalarySobCycleDTO;
//import com.weaver.hrm.salary.entity.salarysob.po.SalarySobAdjustRulePO;
//import com.weaver.hrm.salary.entity.salarysob.po.SalarySobEmpFieldPO;
//import com.weaver.hrm.salary.entity.salarysob.po.SalarySobItemPO;
//import com.weaver.hrm.salary.entity.salarysob.po.SalarySobPO;
//import com.weaver.hrm.salary.enums.OperateTypeEnum;
//import com.weaver.hrm.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum;
//import com.weaver.hrm.salary.enums.salarysob.IncomeCategoryEnum;
//import com.weaver.hrm.salary.exception.SalaryRunTimeException;
//import com.weaver.hrm.salary.service.*;
//import com.weaver.hrm.salary.util.SalaryDateUtil;
//import com.weaver.hrm.salary.util.SalaryEntityUtil;
//import com.weaver.hrm.salary.util.SalaryI18nUtil;
//import com.weaver.teams.domain.user.SimpleEmployee;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.collections4.CollectionUtils;
//import org.apache.commons.collections4.MapUtils;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.jdbc.datasource.DataSourceTransactionManager;
//import org.springframework.transaction.TransactionStatus;
//import org.springframework.transaction.support.DefaultTransactionDefinition;
//
//import java.math.BigDecimal;
//import java.util.*;
//import java.util.concurrent.BlockingDeque;
//import java.util.concurrent.CountDownLatch;
//import java.util.concurrent.LinkedBlockingDeque;
//import java.util.stream.Collectors;
//
///**
// * 薪资核算结果
// * <p>Copyright: Copyright (c) 2022</p>
// * <p>Company: 泛微软件</p>
// *
// * @author qiantao
// * @version 1.0
// **/
//@Slf4j
//public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctResultService {
//
// @Autowired
// private SalaryAcctResultMapper salaryAcctResultMapper;
// @Autowired
// private SalaryAcctEmployeeService salaryAcctEmployeeService;
// @Autowired
// private SalarySobItemService salarySobItemService;
// @Autowired
// private SalaryItemService salaryItemService;
// @Autowired
// private SalarySobEmpFieldService salarySobEmpFieldService;
// @Autowired
// private SalarySobService salarySobService;
// @Autowired
// private SalaryAcctRecordService salaryAcctRecordService;
// @Autowired
// private TaxAgentService taxAgentService;
// @Autowired
// private HrmCommonEmployeeService hrmCommonEmployeeService;
// @Autowired
// private SalaryFormulaService salaryFormulaService;
// @Autowired
// private SalarySobAdjustRuleService salarySobAdjustRuleService;
// @Autowired
package com.engine.salary.service.impl;
import com.engine.core.impl.Service;
import com.engine.salary.biz.TaxAgentBiz;
import com.engine.salary.common.LocalDateRange;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salaryacct.bo.SalaryAcctResultBO;
import com.engine.salary.entity.salaryacct.dto.ConsolidatedTaxDetailDTO;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultDetailDTO;
import com.engine.salary.entity.salaryacct.param.SalaryAcctEmployeeQueryParam;
import com.engine.salary.entity.salaryacct.param.SalaryAcctResultQueryParam;
import com.engine.salary.entity.salaryacct.param.SalaryAcctResultSaveParam;
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.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.salarysob.po.SalarySobEmpFieldPO;
import com.engine.salary.entity.salarysob.po.SalarySobItemPO;
import com.engine.salary.entity.salarysob.po.SalarySobPO;
import com.engine.salary.entity.taxrate.TaxAgent;
import com.engine.salary.enums.salarysob.IncomeCategoryEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.salaryacct.SalaryAcctResultMapper;
import com.engine.salary.service.*;
import com.engine.salary.util.SalaryDateUtil;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.page.PageInfo;
import com.weaver.excel.formula.api.entity.ExpressFormula;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import java.util.*;
import java.util.stream.Collectors;
/**
* 薪资核算结果
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Slf4j
public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctResultService {
private SalaryAcctResultMapper salaryAcctResultMapper;
private SalaryAcctEmployeeService salaryAcctEmployeeService;
private SalarySobItemService salarySobItemService;
private SalaryItemService salaryItemService;
private SalarySobEmpFieldService salarySobEmpFieldService;
private SalarySobService salarySobService;
private SalaryAcctRecordService salaryAcctRecordService;
private TaxAgentBiz taxAgentService;
private SalaryEmployeeService hrmCommonEmployeeService;
private SalaryFormulaService salaryFormulaService;
private SalarySobAdjustRuleService salarySobAdjustRuleService;
// private SalaryAcctCalculateService salaryAcctCalculateService;
// @Autowired
// private SalaryAcctProgressService salaryAcctProgressService;
// @Autowired
// private DataSourceTransactionManager dataSourceTransactionManager;
// @Autowired
private DataSourceTransactionManager dataSourceTransactionManager;
// private SalaryAcctResultTempService salaryAcctResultTempService;
// @Autowired
// private LoggerTemplate salaryAcctRecordLoggerTemplate;
// @Autowired
// private SIAccountService siAccountService;
// @Autowired
// private AttendQuoteFieldService attendQuoteFieldService;
// @Autowired
private AttendQuoteFieldService attendQuoteFieldService;
// private SalaryCheckResultService salaryCheckResultService;
//
// @Override
// public List<SalaryAcctResultPO> listBySalaryAcctRecordIds(Collection<Long> salaryAcctRecordIds, String tenantKey) {
// if (CollectionUtils.isEmpty(salaryAcctRecordIds)) {
// return Collections.emptyList();
// }
// return new LambdaQueryChainWrapper<>(salaryAcctResultMapper)
// .eq(SalaryAcctResultPO::getTenantKey, tenantKey)
// .eq(SalaryAcctResultPO::getDeleteType, 0)
// .in(SalaryAcctResultPO::getSalaryAcctRecordId, salaryAcctRecordIds)
// .list();
// }
//
// @Override
// public List<SalaryAcctResultPO> listBySalaryAcctEmployeeId(Long salaryAcctEmployeeId, String tenantKey) {
// return new LambdaQueryChainWrapper<>(salaryAcctResultMapper)
// .eq(SalaryAcctResultPO::getTenantKey, tenantKey)
// .eq(SalaryAcctResultPO::getDeleteType, 0)
// .eq(SalaryAcctResultPO::getSalaryAcctEmpId, salaryAcctEmployeeId)
// .list();
// }
//
// @Override
// public List<SalaryAcctResultPO> listBySalaryAcctEmployeeIds(Collection<Long> salaryAcctEmployeeIds, String tenantKey) {
// if (CollectionUtils.isEmpty(salaryAcctEmployeeIds)) {
// return Collections.emptyList();
// }
// return new LambdaQueryChainWrapper<>(salaryAcctResultMapper)
// .eq(SalaryAcctResultPO::getTenantKey, tenantKey)
// .eq(SalaryAcctResultPO::getDeleteType, 0)
// .in(SalaryAcctResultPO::getSalaryAcctEmpId, salaryAcctEmployeeIds)
// .list();
// }
//
// @Override
// public List<SalaryAcctResultPO> listBySalaryAcctRecordIdsAndEmployeeIds(Collection<Long> salaryAcctRecordIds, Collection<Long> employeeIds, String tenantKey) {
// if (CollectionUtils.isEmpty(salaryAcctRecordIds) || CollectionUtils.isEmpty(employeeIds)) {
// return Collections.emptyList();
// }
// return new LambdaQueryChainWrapper<>(salaryAcctResultMapper)
// .eq(SalaryAcctResultPO::getTenantKey, tenantKey)
// .eq(SalaryAcctResultPO::getDeleteType, 0)
// .in(SalaryAcctResultPO::getSalaryAcctRecordId, salaryAcctRecordIds)
// .in(SalaryAcctResultPO::getEmployeeId, employeeIds)
// .list();
// }
//
// @Override
// public SalaryAcctResultDetailDTO getBySalaryAcctEmployeeId(Long salaryAcctEmployeeId, String tenantKey) {
// // 查询薪资核算人员
// SalaryAcctEmployeePO salaryAcctEmployeePO = salaryAcctEmployeeService.getById(salaryAcctEmployeeId, tenantKey);
// if (Objects.isNull(salaryAcctEmployeePO)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98831, "薪资核算人员不存在或已被删除"));
// }
// // 查询薪资核算所用薪资账套的薪资项目副本
// List<SalarySobItemPO> salarySobItemPOS = salarySobItemService.listBySalarySobId(salaryAcctEmployeePO.getSalarySobId(), tenantKey);
// // 查询薪资项目
// Set<Long> salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId);
// List<SalaryItemPO> salaryItemPOS = salaryItemService.listByIds(salaryItemIds, tenantKey);
// // 查询薪资核算所用薪资账套的人员信息字段
// List<SalarySobEmpFieldPO> salarySobEmpFieldPOS = salarySobEmpFieldService.listBySalarySobId(salaryAcctEmployeePO.getSalarySobId(), tenantKey);
// // 查询人员信息
// SimpleEmployee simpleEmployee = hrmCommonEmployeeService.getEmployeeById(salaryAcctEmployeePO.getEmployeeId(), tenantKey);
// // 查询薪资核算结果
// List<SalaryAcctResultPO> salaryAcctResultPOS = listBySalaryAcctEmployeeId(salaryAcctEmployeeId, tenantKey);
// // 查询个税扣缴义务人
// TaxAgentPO taxAgentPO = taxAgentService.getById(salaryAcctEmployeePO.getTaxAgentId(), tenantKey);
// // 转换成薪资核算结果详情dto
// return SalaryAcctResultBO.convert2DetailDTO(simpleEmployee, taxAgentPO, salaryAcctEmployeePO, salarySobEmpFieldPOS, salarySobItemPOS, salaryItemPOS, salaryAcctResultPOS);
// }
//
// @Override
// public Page<Map<String, Object>> listPageByParam(SalaryAcctResultQueryParam queryParam, String tenantKey) {
// // 查询薪资核算人员分页
// Page<SalaryAcctEmployeePO> page = salaryAcctEmployeeService.listPageByResultQueryParam(queryParam, tenantKey);
// // 查询薪资核算结果
// List<Map<String, Object>> data = listBySalaryAcctEmployees(page.getRecords(), queryParam, tenantKey);
// // 薪资核算结果的分页结果
// Page<Map<String, Object>> resultPage = new Page<>(page.getCurrent(), page.getSize(), page.getTotal(), page.isSearchCount());
// resultPage.setRecords(data);
// return resultPage;
// }
//
// @Override
// public List<Map<String, Object>> listByParam(SalaryAcctResultQueryParam queryParam, String tenantKey) {
// // 查询薪资核算人员
// List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = salaryAcctEmployeeService.listByResultQueryParam(queryParam, tenantKey);
// // 查询薪资核算结果
// return listBySalaryAcctEmployees(salaryAcctEmployeePOS, queryParam, tenantKey);
// }
//
// /**
// * 根据薪资核算人员查询薪资核算结果
// *
// * @param salaryAcctEmployeePOS 薪资核算人员
// * @param queryParam 列表查询条件
// * @param tenantKey 租户key
// * @return
// */
// private List<Map<String, Object>> listBySalaryAcctEmployees(List<SalaryAcctEmployeePO> salaryAcctEmployeePOS,
// SalaryAcctResultQueryParam queryParam,
// String tenantKey) {
// if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) {
// return Collections.emptyList();
// }
// // 查询薪资核算记录
// SalaryAcctRecordPO salaryAcctRecordPO = salaryAcctRecordService.getById(queryParam.getSalaryAcctRecordId(), tenantKey);
// if (Objects.isNull(salaryAcctRecordPO)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
// }
// // 查询薪资核算所用的薪资账套的员工信息字段
// List<SalarySobEmpFieldPO> salarySobEmpFieldPOS = salarySobEmpFieldService.listBySalarySobId(salaryAcctRecordPO.getSalarySobId(), tenantKey);
// // 查询薪资核算所用薪资账套的薪资项目
// List<SalarySobItemPO> salarySobItemPOS = salarySobItemService.listBySalarySobId(salaryAcctRecordPO.getSalarySobId(), tenantKey);
// Set<Long> salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId);
// List<SalaryItemPO> salaryItemPOS = salaryItemService.listByIds(salaryItemIds, tenantKey);
// // 查询薪资核算结果
// Set<Long> salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId);
// List<SalaryAcctResultPO> salaryAcctResultPOS = listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds, tenantKey);
// // 查询人员信息
// List<Long> employeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getEmployeeId, Collectors.toList());
// List<SimpleEmployee> simpleEmployees = hrmCommonEmployeeService.getEmployeeByIds(employeeIds, tenantKey);
// // 查询个税扣缴义务人
// Set<Long> taxAgentIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getTaxAgentId);
// List<TaxAgentPO> taxAgentPOS = taxAgentService.listByIds(taxAgentIds, tenantKey);
// // 判断是否存在合并计税
// Set<Long> salaryAcctEmployeeIds4ConsolidatedTax;
// if (StringUtils.isNotEmpty(queryParam.getConsolidatedTaxation())) {
// // 如果查询条件中含有"合并计税"那么在入参中的salaryAcctEmployeePOS就已经全部都是存在合并计税的人员了前面已经过滤了无需再次查询合并计税的人员
// salaryAcctEmployeeIds4ConsolidatedTax = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId);
// } else {
// // 如果查询条件中没有包含"合并计税"那么就需要查询出存在合并计税的人标记给前端
// SalaryAcctEmployeeQueryParam accEmployeeQueryParam = new SalaryAcctEmployeeQueryParam()
// .setSalaryAcctRecordId(queryParam.getSalaryAcctRecordId())
// .setIds(SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId));
// List<SalaryAcctEmployeePO> salaryAcctEmployeePOS4ConsolidatedTax = salaryAcctEmployeeService.listByParam4ConsolidatedTax(accEmployeeQueryParam, tenantKey);
// salaryAcctEmployeeIds4ConsolidatedTax = SalaryEntityUtil.properties(salaryAcctEmployeePOS4ConsolidatedTax, SalaryAcctEmployeePO::getId);
// }
// // 查询公式详情
// Set<Long> formulaIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getFormulaId);
// List<ExpressFormula> expressFormulas = salaryFormulaService.listExpressFormula(formulaIds, tenantKey);
// Map<Long, String> expressFormulaMap = SalaryEntityUtil.convert2Map(expressFormulas, ExpressFormula::getId, ExpressFormula::getFormula);
// Map<Long, String> customParameters = SalaryEntityUtil.convert2Map(salarySobItemPOS, SalarySobItemPO::getSalaryItemId, salarySobItemPO -> {
// if (salarySobItemPO.getFormulaId() <= 0) {
// return SalaryI18nUtil.getI18nLabel(92004, "输入/导入");
// }
// return expressFormulaMap.getOrDefault(salarySobItemPO.getFormulaId(), StringUtils.EMPTY);
// });
// // 转换成薪资核算结果列表
// return SalaryAcctResultBO
// .buildTableData(salaryItemPOS, salarySobEmpFieldPOS, simpleEmployees, salaryAcctEmployeePOS, salaryAcctResultPOS, taxAgentPOS, salaryAcctEmployeeIds4ConsolidatedTax, customParameters);
//
// }
//
// @Override
// public ConsolidatedTaxDetailDTO getConsolidatedTaxDetail(Long salaryAcctEmployeeId, String tenantKey) {
// // 查询当前的薪资核算人员
// SalaryAcctEmployeePO salaryAcctEmployeePO = salaryAcctEmployeeService.getById(salaryAcctEmployeeId, tenantKey);
// if (Objects.isNull(salaryAcctEmployeePO)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98831, "薪资核算人员不存在或已被删除"));
// }
// // 查询当前的薪资核算人员的个税扣缴义务人
// TaxAgentPO taxAgentPO = taxAgentService.getById(salaryAcctEmployeePO.getTaxAgentId(), tenantKey);
// // 查询当前的薪资核算人员的人员信息
// SimpleEmployee simpleEmployee = hrmCommonEmployeeService.getEmployeeById(salaryAcctEmployeePO.getEmployeeId(), tenantKey);
// // 查询当前的薪资核算记录
// SalaryAcctRecordPO salaryAcctRecordPO = salaryAcctRecordService.getById(salaryAcctEmployeePO.getSalaryAcctRecordId(), tenantKey);
// // 查询当前薪资核算记录所用的薪资账套
// SalarySobPO salarySobPO = salarySobService.getById(salaryAcctRecordPO.getSalarySobId(), tenantKey);
// // 当前薪资核算记录所用的薪资账套的员工信息字段
// List<SalarySobEmpFieldPO> salarySobEmpFieldPOS = salarySobEmpFieldService.listBySalarySobId(salarySobPO.getId(), tenantKey);
//
// List<SalaryAcctRecordPO> salaryAcctRecordPOS = Collections.singletonList(salaryAcctRecordPO);
// List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = Collections.singletonList(salaryAcctEmployeePO);
//
// // 如果当前薪资核算记录所用的薪资账套的薪资类型是工资薪金代表可能存在合并计税
// if (Objects.equals(salarySobPO.getIncomeCategory(), IncomeCategoryEnum.WAGES_AND_SALARIES.getValue())) {
// // 查询所有薪资类型为工资薪金的账套
// List<SalarySobPO> salarySobPOS = salarySobService.listByIncomeCategory(IncomeCategoryEnum.WAGES_AND_SALARIES, tenantKey);
// // 查询相同税款所属期内的薪资类型为工资薪金的账套的所有核算记录
// Set<Long> salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId);
// LocalDateRange taxCycleDateRange = SalaryDateUtil.localDate2Range(salaryAcctRecordPO.getTaxCycle());
// salaryAcctRecordPOS = salaryAcctRecordService.listBySalarySobIdsAndSalaryMonth(salarySobIds, taxCycleDateRange, tenantKey);
// // 查询当前薪资核算人员所涉及的合并计税的所有薪资核算人员
// Set<Long> salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId);
// salaryAcctEmployeePOS = salaryAcctEmployeeService.listByRecordIdsAndEmpIdAndTaxAgentId(salaryAcctRecordIds,
// salaryAcctEmployeePO.getEmployeeId(), salaryAcctEmployeePO.getTaxAgentId(), tenantKey);
// }
// // 查询薪资核算人员的薪资核算结果
// Set<Long> salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId);
// List<SalaryAcctResultPO> salaryAcctResultPOS = listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds, tenantKey);
// // 查询薪资核算人员所有合并计税的薪资核算记录所用的账套
// Set<Long> salarySobIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getSalarySobId);
// List<SalarySobPO> salarySobPOS = salarySobService.listByIds(salarySobIds, tenantKey);
// // 查询薪资项目所引用的薪资项目
// List<SalarySobItemPO> salarySobItemPOS = salarySobItemService.listBySalarySobIds(salarySobIds, tenantKey);
// // 查询薪资项目
// Set<Long> salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId);
// List<SalaryItemPO> salaryItemPOS = salaryItemService.listByIds(salaryItemIds, tenantKey);
// // 转换成合并计税详情dto
// return SalaryAcctResultBO.convert2ConsolidatedTaxDetailDTO(simpleEmployee, taxAgentPO, salarySobEmpFieldPOS, salaryItemPOS,
// salaryAcctEmployeePOS, salarySobPOS, salaryAcctRecordPOS, salaryAcctResultPOS);
// }
//
// @Override
// public void save(SalaryAcctResultSaveParam saveParam, Long employeeId, String tenantKey) {
// // 查询薪资核算人员
// SalaryAcctEmployeePO salaryAcctEmployeePO = salaryAcctEmployeeService.getById(saveParam.getSalaryAcctEmpId(), tenantKey);
// if (Objects.isNull(salaryAcctEmployeePO)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98831, "薪资核算人员不存在或已被删除"));
// }
// // 保存参数转换成薪资核算结果po
// List<SalaryAcctResultPO> salaryAcctResultPOS = SalaryAcctResultBO.convert2PO(saveParam, salaryAcctEmployeePO, employeeId, tenantKey);
// // 删除原来的薪资核算结果
// deleteBySalaryAcctEmployeeIds(Collections.singleton(saveParam.getSalaryAcctEmpId()), tenantKey);
// // 保存薪资核算结果
// if (CollectionUtils.isNotEmpty(salaryAcctResultPOS)) {
// salaryAcctResultMapper.batchInsert(salaryAcctResultPOS);
// }
// // 查询操作日志的targetName
// String targetName = salaryAcctRecordService.getLogTargetNameById(salaryAcctEmployeePO.getSalaryAcctRecordId(), tenantKey);
// // 查询人员信息
// SimpleEmployee simpleEmployee = hrmCommonEmployeeService.getEmployeeById(salaryAcctEmployeePO.getEmployeeId(), tenantKey);
// // 查询个税扣缴义务人
// TaxAgentPO taxAgentPO = taxAgentService.getById(salaryAcctEmployeePO.getTaxAgentId(), tenantKey);
// // 记录日志
@Override
public List<SalaryAcctResultPO> listBySalaryAcctRecordIds(Collection<Long> salaryAcctRecordIds) {
if (CollectionUtils.isEmpty(salaryAcctRecordIds)) {
return Collections.emptyList();
}
return salaryAcctResultMapper.listSome(SalaryAcctResultPO.builder().salaryAcctRecordIds(salaryAcctRecordIds).build());
}
@Override
public List<SalaryAcctResultPO> listBySalaryAcctEmployeeId(Long salaryAcctEmployeeId) {
return salaryAcctResultMapper.listSome(SalaryAcctResultPO.builder().salaryAcctEmpId(salaryAcctEmployeeId).build());
}
@Override
public List<SalaryAcctResultPO> listBySalaryAcctEmployeeIds(Collection<Long> salaryAcctEmployeeIds) {
if (CollectionUtils.isEmpty(salaryAcctEmployeeIds)) {
return Collections.emptyList();
}
return salaryAcctResultMapper.listSome(SalaryAcctResultPO.builder().salaryAcctEmpIds(salaryAcctEmployeeIds).build());
}
@Override
public List<SalaryAcctResultPO> listBySalaryAcctRecordIdsAndEmployeeIds(Collection<Long> salaryAcctRecordIds, Collection<Long> employeeIds) {
if (CollectionUtils.isEmpty(salaryAcctRecordIds) || CollectionUtils.isEmpty(employeeIds)) {
return Collections.emptyList();
}
return salaryAcctResultMapper.listSome(SalaryAcctResultPO.builder().salaryAcctRecordIds(salaryAcctRecordIds).employeeIds(employeeIds).build());
}
@Override
public SalaryAcctResultDetailDTO getBySalaryAcctEmployeeId(Long salaryAcctEmployeeId) {
// 查询薪资核算人员
SalaryAcctEmployeePO salaryAcctEmployeePO = salaryAcctEmployeeService.getById(salaryAcctEmployeeId);
if (Objects.isNull(salaryAcctEmployeePO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98831, "薪资核算人员不存在或已被删除"));
}
// 查询薪资核算所用薪资账套的薪资项目副本
List<SalarySobItemPO> salarySobItemPOS = salarySobItemService.listBySalarySobId(salaryAcctEmployeePO.getSalarySobId());
// 查询薪资项目
Set<Long> salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId);
List<SalaryItemPO> salaryItemPOS = salaryItemService.listByIds(salaryItemIds);
// 查询薪资核算所用薪资账套的人员信息字段
List<SalarySobEmpFieldPO> salarySobEmpFieldPOS = salarySobEmpFieldService.listBySalarySobId(salaryAcctEmployeePO.getSalarySobId());
// 查询人员信息
DataCollectionEmployee simpleEmployee = hrmCommonEmployeeService.getEmployeeById(salaryAcctEmployeePO.getEmployeeId());
// 查询薪资核算结果
List<SalaryAcctResultPO> salaryAcctResultPOS = listBySalaryAcctEmployeeId(salaryAcctEmployeeId);
// 查询个税扣缴义务人
TaxAgent taxAgent = taxAgentService.getById(salaryAcctEmployeePO.getTaxAgentId());
// 转换成薪资核算结果详情dto
return SalaryAcctResultBO.convert2DetailDTO(simpleEmployee, taxAgent, salaryAcctEmployeePO, salarySobEmpFieldPOS, salarySobItemPOS, salaryItemPOS, salaryAcctResultPOS);
}
@Override
public PageInfo<Map<String, Object>> listPageByParam(SalaryAcctResultQueryParam queryParam) {
// 查询薪资核算人员分页
PageInfo<SalaryAcctEmployeePO> page = salaryAcctEmployeeService.listPageByResultQueryParam(queryParam);
// 查询薪资核算结果
List<Map<String, Object>> data = listBySalaryAcctEmployees(page.getList(), queryParam);
// 薪资核算结果的分页结果
PageInfo<Map<String, Object>> resultPage = new PageInfo<>();
resultPage.setList(data);
return resultPage;
}
@Override
public List<Map<String, Object>> listByParam(SalaryAcctResultQueryParam queryParam) {
// 查询薪资核算人员
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = salaryAcctEmployeeService.listByResultQueryParam(queryParam);
// 查询薪资核算结果
return listBySalaryAcctEmployees(salaryAcctEmployeePOS, queryParam);
}
/**
* 根据薪资核算人员查询薪资核算结果
*
* @param salaryAcctEmployeePOS 薪资核算人员
* @param queryParam 列表查询条件
* @return
*/
private List<Map<String, Object>> listBySalaryAcctEmployees(List<SalaryAcctEmployeePO> salaryAcctEmployeePOS,
SalaryAcctResultQueryParam queryParam) {
if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) {
return Collections.emptyList();
}
// 查询薪资核算记录
SalaryAcctRecordPO salaryAcctRecordPO = salaryAcctRecordService.getById(queryParam.getSalaryAcctRecordId());
if (Objects.isNull(salaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
}
// 查询薪资核算所用的薪资账套的员工信息字段
List<SalarySobEmpFieldPO> salarySobEmpFieldPOS = salarySobEmpFieldService.listBySalarySobId(salaryAcctRecordPO.getSalarySobId());
// 查询薪资核算所用薪资账套的薪资项目
List<SalarySobItemPO> salarySobItemPOS = salarySobItemService.listBySalarySobId(salaryAcctRecordPO.getSalarySobId());
Set<Long> salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId);
List<SalaryItemPO> salaryItemPOS = salaryItemService.listByIds(salaryItemIds);
// 查询薪资核算结果
Set<Long> salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId);
List<SalaryAcctResultPO> salaryAcctResultPOS = listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds);
// 查询人员信息
List<Long> employeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getEmployeeId, Collectors.toList());
List<DataCollectionEmployee> simpleEmployees = hrmCommonEmployeeService.listByIds(employeeIds);
// 查询个税扣缴义务人
Set<Long> taxAgentIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getTaxAgentId);
List<TaxAgent> taxAgentPOS = taxAgentService.listByIds(taxAgentIds);
// 判断是否存在合并计税
Set<Long> salaryAcctEmployeeIds4ConsolidatedTax;
if (StringUtils.isNotEmpty(queryParam.getConsolidatedTaxation())) {
// 如果查询条件中含有"合并计税"那么在入参中的salaryAcctEmployeePOS就已经全部都是存在合并计税的人员了前面已经过滤了无需再次查询合并计税的人员
salaryAcctEmployeeIds4ConsolidatedTax = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId);
} else {
// 如果查询条件中没有包含"合并计税"那么就需要查询出存在合并计税的人标记给前端
SalaryAcctEmployeeQueryParam accEmployeeQueryParam = new SalaryAcctEmployeeQueryParam()
.setSalaryAcctRecordId(queryParam.getSalaryAcctRecordId())
.setIds(SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId));
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS4ConsolidatedTax = salaryAcctEmployeeService.listByParam4ConsolidatedTax(accEmployeeQueryParam);
salaryAcctEmployeeIds4ConsolidatedTax = SalaryEntityUtil.properties(salaryAcctEmployeePOS4ConsolidatedTax, SalaryAcctEmployeePO::getId);
}
// 查询公式详情
Set<Long> formulaIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getFormulaId);
List<ExpressFormula> expressFormulas = salaryFormulaService.listExpressFormula(formulaIds);
Map<Long, String> expressFormulaMap = SalaryEntityUtil.convert2Map(expressFormulas, ExpressFormula::getId, ExpressFormula::getFormula);
Map<Long, String> customParameters = SalaryEntityUtil.convert2Map(salarySobItemPOS, SalarySobItemPO::getSalaryItemId, salarySobItemPO -> {
if (salarySobItemPO.getFormulaId() <= 0) {
return SalaryI18nUtil.getI18nLabel(92004, "输入/导入");
}
return expressFormulaMap.getOrDefault(salarySobItemPO.getFormulaId(), StringUtils.EMPTY);
});
// 转换成薪资核算结果列表
return SalaryAcctResultBO
.buildTableData(salaryItemPOS, salarySobEmpFieldPOS, simpleEmployees, salaryAcctEmployeePOS, salaryAcctResultPOS, taxAgentPOS, salaryAcctEmployeeIds4ConsolidatedTax, customParameters);
}
@Override
public ConsolidatedTaxDetailDTO getConsolidatedTaxDetail(Long salaryAcctEmployeeId) {
// 查询当前的薪资核算人员
SalaryAcctEmployeePO salaryAcctEmployeePO = salaryAcctEmployeeService.getById(salaryAcctEmployeeId);
if (Objects.isNull(salaryAcctEmployeePO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98831, "薪资核算人员不存在或已被删除"));
}
// 查询当前的薪资核算人员的个税扣缴义务人
TaxAgent taxAgentPO = taxAgentService.getById(salaryAcctEmployeePO.getTaxAgentId());
// 查询当前的薪资核算人员的人员信息
DataCollectionEmployee simpleEmployee = hrmCommonEmployeeService.getEmployeeById(salaryAcctEmployeePO.getEmployeeId());
// 查询当前的薪资核算记录
SalaryAcctRecordPO salaryAcctRecordPO = salaryAcctRecordService.getById(salaryAcctEmployeePO.getSalaryAcctRecordId());
// 查询当前薪资核算记录所用的薪资账套
SalarySobPO salarySobPO = salarySobService.getById(salaryAcctRecordPO.getSalarySobId());
// 当前薪资核算记录所用的薪资账套的员工信息字段
List<SalarySobEmpFieldPO> salarySobEmpFieldPOS = salarySobEmpFieldService.listBySalarySobId(salarySobPO.getId());
List<SalaryAcctRecordPO> salaryAcctRecordPOS = Collections.singletonList(salaryAcctRecordPO);
List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = Collections.singletonList(salaryAcctEmployeePO);
// 如果当前薪资核算记录所用的薪资账套的薪资类型是工资薪金代表可能存在合并计税
if (Objects.equals(salarySobPO.getIncomeCategory(), IncomeCategoryEnum.WAGES_AND_SALARIES.getValue())) {
// 查询所有薪资类型为工资薪金的账套
List<SalarySobPO> salarySobPOS = salarySobService.listByIncomeCategory(IncomeCategoryEnum.WAGES_AND_SALARIES);
// 查询相同税款所属期内的薪资类型为工资薪金的账套的所有核算记录
Set<Long> salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId);
LocalDateRange taxCycleDateRange = SalaryDateUtil.localDate2Range(salaryAcctRecordPO.getTaxCycle());
salaryAcctRecordPOS = salaryAcctRecordService.listBySalarySobIdsAndSalaryMonth(salarySobIds, taxCycleDateRange);
// 查询当前薪资核算人员所涉及的合并计税的所有薪资核算人员
Set<Long> salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId);
salaryAcctEmployeePOS = salaryAcctEmployeeService.listByRecordIdsAndEmpIdAndTaxAgentId(salaryAcctRecordIds,
salaryAcctEmployeePO.getEmployeeId(), salaryAcctEmployeePO.getTaxAgentId());
}
// 查询薪资核算人员的薪资核算结果
Set<Long> salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId);
List<SalaryAcctResultPO> salaryAcctResultPOS = listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds);
// 查询薪资核算人员所有合并计税的薪资核算记录所用的账套
Set<Long> salarySobIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getSalarySobId);
List<SalarySobPO> salarySobPOS = salarySobService.listByIds(salarySobIds);
// 查询薪资项目所引用的薪资项目
List<SalarySobItemPO> salarySobItemPOS = salarySobItemService.listBySalarySobIds(salarySobIds);
// 查询薪资项目
Set<Long> salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId);
List<SalaryItemPO> salaryItemPOS = salaryItemService.listByIds(salaryItemIds);
// 转换成合并计税详情dto
return SalaryAcctResultBO.convert2ConsolidatedTaxDetailDTO(simpleEmployee, taxAgentPO, salarySobEmpFieldPOS, salaryItemPOS,
salaryAcctEmployeePOS, salarySobPOS, salaryAcctRecordPOS, salaryAcctResultPOS);
}
@Override
public void save(SalaryAcctResultSaveParam saveParam) {
// 查询薪资核算人员
SalaryAcctEmployeePO salaryAcctEmployeePO = salaryAcctEmployeeService.getById(saveParam.getSalaryAcctEmpId());
if (Objects.isNull(salaryAcctEmployeePO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98831, "薪资核算人员不存在或已被删除"));
}
// 保存参数转换成薪资核算结果po
List<SalaryAcctResultPO> salaryAcctResultPOS = SalaryAcctResultBO.convert2PO(saveParam, salaryAcctEmployeePO, (long)user.getUID());
// 删除原来的薪资核算结果
deleteBySalaryAcctEmployeeIds(Collections.singleton(saveParam.getSalaryAcctEmpId()));
// 保存薪资核算结果
if (CollectionUtils.isNotEmpty(salaryAcctResultPOS)) {
salaryAcctResultMapper.batchInsert(salaryAcctResultPOS);
}
// 查询操作日志的targetName
String targetName = salaryAcctRecordService.getLogTargetNameById(salaryAcctEmployeePO.getSalaryAcctRecordId());
// 查询人员信息
DataCollectionEmployee simpleEmployee = hrmCommonEmployeeService.getEmployeeById(salaryAcctEmployeePO.getEmployeeId());
// 查询个税扣缴义务人
TaxAgent taxAgentPO = taxAgentService.getById(salaryAcctEmployeePO.getTaxAgentId());
// 记录日志
// String operateDesc = simpleEmployee.getUsername() + "(" + Optional.ofNullable(taxAgentPO).map(TaxAgentPO::getName).orElse(StringUtils.EMPTY) + ")";
// LoggerContext<SalaryCheckResultPO> loggerContext = new LoggerContext<>();
// loggerContext.setTargetId(String.valueOf(salaryAcctEmployeePO.getSalaryAcctRecordId()));
@ -340,37 +297,37 @@
// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(95783, "编辑薪资核算结果") + ": " + operateDesc);
// loggerContext.setNewValueList(Lists.newArrayList(salaryAcctResultPOS));
// salaryAcctRecordLoggerTemplate.write(loggerContext);
// }
//
}
@Override
public void batchSave(Collection<SalaryAcctResultPO> salaryAcctResultPOS) {
if (CollectionUtils.isNotEmpty(salaryAcctResultPOS)) {
salaryAcctResultMapper.batchInsert(salaryAcctResultPOS);
}
}
@Override
public void deleteBySalaryAcctEmployeeIds(Collection<Long> salaryAcctEmployeeIds) {
salaryAcctResultMapper.deleteBySalaryAcctEmpIds(salaryAcctEmployeeIds);
}
@Override
public void deleteByAcctEmployeeIdsAndSalaryItemIds(Collection<Long> salaryAcctEmployeeIds, Collection<Long> salaryItemIds) {
salaryAcctResultMapper.deleteByAcctEmpIdsAndSalaryItemIds(salaryAcctEmployeeIds, salaryItemIds);
}
@Override
public void deleteBySalaryAcctRecordIds(Collection<Long> salaryAcctRecordIds) {
salaryAcctResultMapper.deleteBySalaryAcctRecordIds(salaryAcctRecordIds);
}
// @Override
// public void batchSave(Collection<SalaryAcctResultPO> salaryAcctResultPOS) {
// if (CollectionUtils.isNotEmpty(salaryAcctResultPOS)) {
// salaryAcctResultMapper.batchInsert(salaryAcctResultPOS);
// }
// }
//
// @Override
// public void deleteBySalaryAcctEmployeeIds(Collection<Long> salaryAcctEmployeeIds, String tenantKey) {
// salaryAcctResultMapper.deleteBySalaryAcctEmpIds(salaryAcctEmployeeIds, tenantKey);
// }
//
// @Override
// public void deleteByAcctEmployeeIdsAndSalaryItemIds(Collection<Long> salaryAcctEmployeeIds, Collection<Long> salaryItemIds, String tenantKey) {
// salaryAcctResultMapper.deleteByAcctEmpIdsAndSalaryItemIds(salaryAcctEmployeeIds, salaryItemIds, tenantKey);
// }
//
// @Override
// public void deleteBySalaryAcctRecordIds(Collection<Long> salaryAcctRecordIds, String tenantKey) {
// salaryAcctResultMapper.deleteBySalaryAcctRecordIds(salaryAcctRecordIds, tenantKey);
// }
//
// @Override
// public void calculate(SalaryAcctCalculateParam calculateParam, SimpleEmployee simpleEmployee, String tenantKey) {
// public void calculate(SalaryAcctCalculateParam calculateParam, DataCollectionEmployee simpleEmployee) {
// try {
// // 数据库字段加密用
// DSTenantKeyThreadVar.tenantKey.set(tenantKey);
// DSTenantKeyThreadVar.tenantKey.set();
// // 1查询薪资核算记录
// SalaryAcctRecordPO salaryAcctRecordPO = salaryAcctRecordService.getById(calculateParam.getSalaryAcctRecordId(), tenantKey);
// SalaryAcctRecordPO salaryAcctRecordPO = salaryAcctRecordService.getById(calculateParam.getSalaryAcctRecordId());
// if (Objects.isNull(salaryAcctRecordPO)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
// }
@ -379,16 +336,16 @@
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99148, "当前薪资核算记录已归档,请重新打开后再进行核算"));
// }
// // 2查询薪资核算记录的薪资周期考勤周期等
// SalarySobCycleDTO salarySobCycleDTO = salaryAcctRecordService.getSalarySobCycleById(calculateParam.getSalaryAcctRecordId(), tenantKey);
// SalarySobCycleDTO salarySobCycleDTO = salaryAcctRecordService.getSalarySobCycleById(calculateParam.getSalaryAcctRecordId());
// // 3查询薪资核算记录所用薪资账套的薪资项目副本
// List<SalarySobItemPO> salarySobItemPOS = salarySobItemService.listBySalarySobId(salaryAcctRecordPO.getSalarySobId(), tenantKey);
// List<SalarySobItemPO> salarySobItemPOS = salarySobItemService.listBySalarySobId(salaryAcctRecordPO.getSalarySobId());
// if (CollectionUtils.isEmpty(salarySobItemPOS)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99151, "当前所用的薪资账套未选择任何薪资项目,无法核算"));
// }
// // 4查询当前租户的所有薪资项目
// List<SalaryItemPO> salaryItemPOS = salaryItemService.listAll(tenantKey);
// // 5查询薪资核算记录所用薪资账套的调薪计薪规则
// List<SalarySobAdjustRulePO> salarySobAdjustRulePOS = salarySobAdjustRuleService.listBySalarySobId(salaryAcctRecordPO.getSalarySobId(), tenantKey);
// List<SalarySobAdjustRulePO> salarySobAdjustRulePOS = salarySobAdjustRuleService.listBySalarySobId(salaryAcctRecordPO.getSalarySobId());
// // 6查询社保福利的所有字段
// Map<String, String> welfareColumns = siAccountService.welfareColumns(tenantKey);
// // 7查询考勤引用的所有字段
@ -396,17 +353,17 @@
// // 8查询公式详情
// Set<Long> formulaIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getFormulaId);
// formulaIds.addAll(SalaryEntityUtil.properties(salaryItemPOS, SalaryItemPO::getFormulaId));
// List<ExpressFormula> expressFormulas = salaryFormulaService.listExpressFormula(formulaIds, tenantKey);
// List<ExpressFormula> expressFormulas = salaryFormulaService.listExpressFormula(formulaIds);
// // 9计算薪资项目的运算优先级
// List<List<Long>> salarySobItemsWithPriority = SalaryAcctCalculatePriorityBO.calculatePriority(salarySobItemPOS, salaryItemPOS, expressFormulas);
// // 10根据id查询其他合并计税的薪资核算记录
// List<SalaryAcctRecordPO> otherSalaryAcctRecordPOS = salaryAcctRecordService.listById4OtherConsolidatedTax(salaryAcctRecordPO.getId(), tenantKey);
// List<SalaryAcctRecordPO> otherSalaryAcctRecordPOS = salaryAcctRecordService.listById4OtherConsolidatedTax(salaryAcctRecordPO.getId());
// // 11查询本次核算人员
// List<SalaryAcctEmployeePO> salaryAcctEmployeePOS;
// if (CollectionUtils.isEmpty(calculateParam.getIds())) {
// salaryAcctEmployeePOS = salaryAcctEmployeeService.listBySalaryAcctRecordId(salaryAcctRecordPO.getId(), tenantKey);
// salaryAcctEmployeePOS = salaryAcctEmployeeService.listBySalaryAcctRecordId(salaryAcctRecordPO.getId());
// } else {
// salaryAcctEmployeePOS = salaryAcctEmployeeService.listByIds(calculateParam.getIds(), tenantKey);
// salaryAcctEmployeePOS = salaryAcctEmployeeService.listByIds(calculateParam.getIds());
// }
// if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(103378, "薪资核算人员不能为空"));
@ -420,7 +377,7 @@
// .setProgress(BigDecimal.ZERO)
// .setStatus(true)
// .setMessage(StringUtils.EMPTY);
// salaryAcctProgressService.initProgress("" + calculateParam.getSalaryAcctRecordId(), initProgress, simpleEmployee.getEmployeeId(), tenantKey);
// salaryAcctProgressService.initProgress("" + calculateParam.getSalaryAcctRecordId(), initProgress, simpleEmployee.getEmployeeId());
// // 12对薪资核算人员进行拆分
// List<List<SalaryAcctEmployeePO>> partition = Lists.partition(salaryAcctEmployeePOS, 100);
// // 12.1监控子线程的任务执行
@ -449,7 +406,7 @@
// LocalRunnable localRunnable = new LocalRunnable() {
// @Override
// public void execute() {
// salaryAcctCalculateService.calculate(salaryAcctCalculateBO, simpleEmployee, tenantKey);
// salaryAcctCalculateService.calculate(salaryAcctCalculateBO, simpleEmployee);
// }
// };
// ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "salaryAcctCalculate", localRunnable);
@ -466,19 +423,19 @@
// .collect(Collectors.joining("|"));
// salaryAcctProgressService.fail("" + calculateParam.getSalaryAcctRecordId(), errorMsg);
// // 删除薪资核算临时存储表中的数据
// salaryAcctResultTempService.deleteByCalculateKey(calculateKey, tenantKey);
// salaryAcctResultTempService.deleteByCalculateKey(calculateKey);
// return;
// }
// // 15处理核算结果临时表数据
// handleSalaryAcctResultTemp(calculateParam, calculateKey, tenantKey);
// handleSalaryAcctResultTemp(calculateParam, calculateKey);
// // 16开始运行校验规则
// SalaryAcctCheckParam salaryAcctCheckParam = new SalaryAcctCheckParam()
// .setSalaryAcctRecordId(calculateParam.getSalaryAcctRecordId())
// .setIds(calculateParam.getIds());
// salaryCheckResultService.check(salaryAcctCheckParam, true, simpleEmployee, tenantKey);
// salaryCheckResultService.check(salaryAcctCheckParam, true, simpleEmployee);
// // 记录日志
// // 查询操作日志的targetName
// String targetName = salaryAcctRecordService.getLogTargetNameById(calculateParam.getSalaryAcctRecordId(), tenantKey);
// String targetName = salaryAcctRecordService.getLogTargetNameById(calculateParam.getSalaryAcctRecordId());
// LoggerContext<SalaryCheckResultPO> loggerContext = new LoggerContext<>();
// loggerContext.setTargetId(String.valueOf(calculateParam.getSalaryAcctRecordId()));
// loggerContext.setTargetName(targetName);
@ -494,29 +451,29 @@
// DSTenantKeyThreadVar.tenantKey.remove();
// }
// }
//
// /**
// * 处理薪资核算临时存储表中的数据
// *
// * @param calculateParam
// * @param calculateKey
// */
/**
* 处理薪资核算临时存储表中的数据
*
* @param calculateParam
* @param calculateKey
*/
// private void handleSalaryAcctResultTemp(SalaryAcctCalculateParam calculateParam, String calculateKey, String tenantKey) {
// TransactionStatus status = dataSourceTransactionManager.getTransaction(new DefaultTransactionDefinition());
// try {
// // 查询薪资核算结果的临时存储
// List<SalaryAcctResultTempPO> salaryAcctResultTempPOS = salaryAcctResultTempService.listByCalculateKey(calculateKey, tenantKey);
// List<SalaryAcctResultTempPO> salaryAcctResultTempPOS = salaryAcctResultTempService.listByCalculateKey(calculateKey);
// // 删除原来的薪资核算结果
// if (CollectionUtils.isNotEmpty(calculateParam.getIds())) {
// salaryAcctResultMapper.deleteBySalaryAcctEmpIds(calculateParam.getIds(), tenantKey);
// salaryAcctResultMapper.deleteBySalaryAcctEmpIds(calculateParam.getIds());
// } else {
// salaryAcctResultMapper.deleteBySalaryAcctRecordIds(Collections.singleton(calculateParam.getSalaryAcctRecordId()), tenantKey);
// salaryAcctResultMapper.deleteBySalaryAcctRecordIds(Collections.singleton(calculateParam.getSalaryAcctRecordId()));
// }
// // 保存薪资的薪资核算结果
// List<SalaryAcctResultPO> salaryAcctResultPOS = SalaryAcctResultBO.convert2ResultPO(salaryAcctResultTempPOS);
// batchSave(salaryAcctResultPOS);
// // 删除薪资核算临时存储表中的数据
// salaryAcctResultTempService.deleteByCalculateKey(calculateKey, tenantKey);
// salaryAcctResultTempService.deleteByCalculateKey(calculateKey);
// // 提交事务
// dataSourceTransactionManager.commit(status);
// } catch (Exception e) {
@ -524,4 +481,4 @@
// throw e;
// }
// }
//}
}

View File

@ -14,7 +14,6 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.math.NumberUtils;
import weaver.hrm.User;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
@ -76,4 +75,9 @@ public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployee
public List<DataCollectionEmployee> listByIds(List<Long> ids) {
return employBiz.getEmployeeByIdsAll(ids);
}
@Override
public DataCollectionEmployee getEmployeeById(Long employeeId) {
return employBiz.getEmployeeById(employeeId);
}
}

View File

@ -0,0 +1,101 @@
package com.engine.salary.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.util.TypeUtils;
import java.lang.reflect.Type;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
public class JsonUtil {
private static final SerializerFeature[] DEFAULT_S_FEATURES;
private static final SerializerFeature[] PRETTY_S_FEATURES;
private static final Feature[] DEFAULT_P_FEATURES;
public JsonUtil() {
}
public static String toJsonString(Object obj) {
return JSON.toJSONString(obj, DEFAULT_S_FEATURES);
}
public static String toJsonString(Object obj, SerializerFeature... features) {
return JSON.toJSONString(obj, features);
}
public static String toPrettyJson(Object object) {
return JSON.toJSONString(object, PRETTY_S_FEATURES);
}
public static JSONObject parseJsonObject(String jsonStr) {
return JSON.parseObject(jsonStr, DEFAULT_P_FEATURES);
}
public static <T> T parseValue(JSONObject jsonObject, String key, Class<T> clazz) {
if (jsonObject != null) {
T value = jsonObject.getObject(key, (Type) clazz);
return value;
} else {
return null;
}
}
public static <T> T parseObject(String jsonStr, Class<T> clazz) {
return JSON.parseObject(jsonStr, (Type) clazz, DEFAULT_P_FEATURES);
}
public static <T> List<T> parseList(String jsonStr, Class<T> clazz) {
return JSON.parseArray(jsonStr, clazz);
}
public static <T> List<T> parseList(Object jsonObject, Class<T> clazz) {
String jsonStr = toJsonString(jsonObject);
return parseList(jsonStr, clazz);
}
public static <V> Map<String, V> parseMap(String jsonStr, Class<V> valueCls) {
Map<String, V> result = new LinkedHashMap();
Map<String, Object> map = JSON.parseObject(jsonStr, DEFAULT_P_FEATURES);
if (map != null && map.size() > 0) {
Iterator var4 = map.entrySet().iterator();
while(var4.hasNext()) {
Entry<String, Object> entry = (Entry)var4.next();
Object obj = entry.getValue();
try {
V value = JSON.parseObject(JSON.toJSONString(obj), valueCls);
result.put(entry.getKey(), value);
} catch (Exception var8) {
}
}
}
return result;
}
public static <V> Map<String, V> parseMap(Object jsonObject, Class<V> valueCls) {
String jsonStr = toJsonString(jsonObject);
return parseMap(jsonStr, valueCls);
}
public static <T> T parseBean(String jsonString, Class<T> beanClazz) {
return parseBean(parseJsonObject(jsonString), beanClazz);
}
public static <T> T parseBean(JSONObject jsonObject, Class<T> beanClazz) {
return TypeUtils.castToJavaBean(jsonObject, beanClazz);
}
static {
DEFAULT_S_FEATURES = new SerializerFeature[]{SerializerFeature.WriteDateUseDateFormat, SerializerFeature.SortField};
PRETTY_S_FEATURES = new SerializerFeature[]{SerializerFeature.WriteDateUseDateFormat, SerializerFeature.SortField, SerializerFeature.PrettyFormat};
DEFAULT_P_FEATURES = new Feature[]{Feature.OrderedField};
}
}

View File

@ -10,6 +10,7 @@ import com.engine.salary.util.SalaryDateUtil;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.wrapper.SalaryAcctEmployeeWrapper;
import com.engine.salary.wrapper.SalaryAcctRecordWrapper;
import com.engine.salary.wrapper.SalaryAcctResultWrapper;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
@ -39,7 +40,7 @@ public class SalaryAcctController {
private SalaryAcctEmployeeWrapper getSalaryAcctEmployeeWrapper(User user) {
return (SalaryAcctEmployeeWrapper) ServiceUtil.getService(SalaryAcctEmployeeWrapper.class, user);
}
// private SalaryAcctResultWrapper salaryAcctResultWrapper;
private SalaryAcctResultWrapper salaryAcctResultWrapper;
// private SalaryAcctCheckResultWrapper salaryAcctCheckResultWrapper;
// private SalaryComparisonResultWrapper salaryComparisonResultWrapper;
// private SalaryAcctExcelWrapper salaryAcctExcelWrapper;

View File

@ -0,0 +1,252 @@
//package com.engine.salary.wrapper;
//
//import com.engine.core.impl.Service;
//import com.weaver.common.distribution.genid.IdGenerator;
//import com.weaver.common.threadPool.ThreadPoolUtil;
//import com.weaver.common.threadPool.constant.ModulePoolEnum;
//import com.weaver.common.threadPool.entity.LocalRunnable;
//import com.weaver.datasecurity.interceptor.DSTenantKeyThreadVar;
//import com.weaver.framework.util.JsonUtil;
//import com.weaver.hrm.salary.common.excel.ExcelExportParam;
//import com.weaver.hrm.salary.entity.salaryacct.param.*;
//import com.weaver.hrm.salary.service.SalaryAcctExcelService;
//import com.weaver.teams.domain.EntityType;
//import com.weaver.teams.domain.user.SimpleEmployee;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import java.util.Map;
//
///**
// * 薪资核算导出导出
// * <p>Copyright: Copyright (c) 2022</p>
// * <p>Company: 泛微软件</p>
// *
// * @author qiantao
// * @version 1.0
// **/
//public class SalaryAcctExcelWrapper extends Service {
//
// @Autowired
// private SalaryAcctExcelService salaryAcctExcelService;
//
// /**
// * 薪资核算人员导出
// *
// * @param queryParam
// * @param simpleEmployee
// * @param tenantKey
// * @param eteamsId
// */
// public Map<String, Object> exportSalaryAcctEmployee(SalaryAcctEmployeeQueryParam queryParam,
// SimpleEmployee simpleEmployee, String tenantKey, String eteamsId) {
// ExcelExportParam excelExportParam = new ExcelExportParam()
// .setBiz(IdGenerator.generate())
// .setModule(EntityType.hrsa.name())
// .setFunction("acctEmployeeExportHandler");
// LocalRunnable localRunnable = new LocalRunnable() {
// @Override
// public void execute() {
// try {
// DSTenantKeyThreadVar.tenantKey.set(tenantKey);
// salaryAcctExcelService.exportSalaryAcctEmployee(excelExportParam, queryParam, simpleEmployee, tenantKey, eteamsId);
// } finally {
// DSTenantKeyThreadVar.tenantKey.remove();
// }
// }
// };
// ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "exportSalaryAcctEmployee", localRunnable);
// return JsonUtil.parseMap(excelExportParam, Object.class);
// }
//
// /**
// * 薪资核算环比减少人员导出
// *
// * @param queryParam
// * @param simpleEmployee
// * @param tenantKey
// * @param eteamsId
// * @return
// */
// public Map<String, Object> exportReducedEmployee(SalaryAcctEmployeeQueryParam queryParam,
// SimpleEmployee simpleEmployee, String tenantKey, String eteamsId) {
// ExcelExportParam excelExportParam = new ExcelExportParam()
// .setBiz(IdGenerator.generate())
// .setModule(EntityType.hrsa.name())
// .setFunction("reducedEmployeeExportHandler");
// LocalRunnable localRunnable = new LocalRunnable() {
// @Override
// public void execute() {
// try {
// DSTenantKeyThreadVar.tenantKey.set(tenantKey);
// salaryAcctExcelService.exportReducedEmployee(excelExportParam, queryParam, simpleEmployee, tenantKey, eteamsId);
// } finally {
// DSTenantKeyThreadVar.tenantKey.remove();
// }
// }
// };
// ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "exportReducedEmployee", localRunnable);
// return JsonUtil.parseMap(excelExportParam, Object.class);
// }
//
// /**
// * 薪资核算结果导出
// *
// * @param queryParam
// * @param simpleEmployee
// * @param tenantKey
// * @param eteamsId
// * @return
// */
// public Map<String, Object> exportSalaryAcctResult(SalaryAcctResultQueryParam queryParam,
// SimpleEmployee simpleEmployee, String tenantKey, String eteamsId) {
// ExcelExportParam excelExportParam = new ExcelExportParam()
// .setBiz(IdGenerator.generate())
// .setModule(EntityType.hrsa.name())
// .setFunction("salaryAcctResultExportHandler");
// LocalRunnable localRunnable = new LocalRunnable() {
// @Override
// public void execute() {
// try {
// DSTenantKeyThreadVar.tenantKey.set(tenantKey);
// salaryAcctExcelService.exportSalaryAcctResult(excelExportParam, queryParam, simpleEmployee, tenantKey, eteamsId);
// } finally {
// DSTenantKeyThreadVar.tenantKey.remove();
// }
// }
// };
// ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "exportSalaryAcctResult", localRunnable);
// return JsonUtil.parseMap(excelExportParam, Object.class);
// }
//
// /**
// * 下载薪资核算导入模板
// *
// * @param param
// * @param simpleEmployee
// * @param tenantKey
// * @param eteamsId
// * @return
// */
// public Map<String, Object> exportImportTemplate(SalaryAcctImportTemplateParam param,
// SimpleEmployee simpleEmployee, String tenantKey, String eteamsId) {
// ExcelExportParam excelExportParam = new ExcelExportParam()
// .setBiz(IdGenerator.generate())
// .setModule(EntityType.hrsa.name())
// .setFunction("salaryAcctImportTemplateHandler");
// LocalRunnable localRunnable = new LocalRunnable() {
// @Override
// public void execute() {
// try {
// DSTenantKeyThreadVar.tenantKey.set(tenantKey);
// salaryAcctExcelService.exportImportTemplate(excelExportParam, param, simpleEmployee, tenantKey, eteamsId);
// } finally {
// DSTenantKeyThreadVar.tenantKey.remove();
// }
// }
// };
// ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "exportImportTemplate", localRunnable);
// return JsonUtil.parseMap(excelExportParam, Object.class);
// }
//
// /**
// * 薪资核算线下对比结果导出
// *
// * @param queryParam
// * @param simpleEmployee
// * @param tenantKey
// * @param eteamsId
// * @return
// */
// public Map<String, Object> exportComparisonResult(SalaryComparisonResultQueryParam queryParam,
// SimpleEmployee simpleEmployee, String tenantKey, String eteamsId) {
// ExcelExportParam excelExportParam = new ExcelExportParam()
// .setBiz(IdGenerator.generate())
// .setModule(EntityType.hrsa.name())
// .setFunction("comparisonResultHandler");
// LocalRunnable localRunnable = new LocalRunnable() {
// @Override
// public void execute() {
// try {
// DSTenantKeyThreadVar.tenantKey.set(tenantKey);
// salaryAcctExcelService.exportComparisonResult(excelExportParam, queryParam, simpleEmployee, tenantKey, eteamsId);
// } finally {
// DSTenantKeyThreadVar.tenantKey.remove();
// }
// }
// };
// ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "exportComparisonResult", localRunnable);
// return JsonUtil.parseMap(excelExportParam, Object.class);
// }
//
// /**
// * 薪资核算线下对比结果导入模板导出
// *
// * @param exportParam
// * @param tenantKey
// * @return
// */
// public Map<String, Object> exportComparisonResultTemplate(SalaryComparisonResultExportParam exportParam, String tenantKey) {
// return salaryAcctExcelService.exportComparisonResultTemplate(exportParam, tenantKey);
// }
//
// /**
// * 薪资核算结果校验异常导出
// *
// * @param exportParam
// * @param simpleEmployee
// * @param tenantKey
// * @param eteamsId
// * @return
// */
// public Map<String, Object> exportCheckResult(SalaryCheckResultExportParam exportParam,
// SimpleEmployee simpleEmployee, String tenantKey, String eteamsId) {
// ExcelExportParam excelExportParam = new ExcelExportParam()
// .setBiz(IdGenerator.generate())
// .setModule(EntityType.hrsa.name())
// .setFunction("salaryCheckResultHandler");
// LocalRunnable localRunnable = new LocalRunnable() {
// @Override
// public void execute() {
// try {
// DSTenantKeyThreadVar.tenantKey.set(tenantKey);
// salaryAcctExcelService.exportCheckResult(excelExportParam, exportParam, simpleEmployee, tenantKey, eteamsId);
// } finally {
// DSTenantKeyThreadVar.tenantKey.remove();
// }
// }
// };
// ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "exportCheckResult", localRunnable);
// return JsonUtil.parseMap(excelExportParam, Object.class);
// }
//
// /**
// * 薪资核算结果校验异常明细导出
// *
// * @param checkResultId
// * @param simpleEmployee
// * @param tenantKey
// * @param eteamsId
// * @return
// */
// public Map<String, Object> exportCheckResultDetail(Long checkResultId,
// SimpleEmployee simpleEmployee, String tenantKey, String eteamsId) {
// ExcelExportParam excelExportParam = new ExcelExportParam()
// .setBiz(IdGenerator.generate())
// .setModule(EntityType.hrsa.name())
// .setFunction("salaryCheckResultDetailHandler");
// LocalRunnable localRunnable = new LocalRunnable() {
// @Override
// public void execute() {
// try {
// DSTenantKeyThreadVar.tenantKey.set(tenantKey);
// salaryAcctExcelService.exportCheckResultDetail(excelExportParam, checkResultId, simpleEmployee, tenantKey, eteamsId);
// } finally {
// DSTenantKeyThreadVar.tenantKey.remove();
// }
// }
// };
// ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "exportCheckResultDetail", localRunnable);
// return JsonUtil.parseMap(excelExportParam, Object.class);
// }
//}

View File

@ -0,0 +1,215 @@
package com.engine.salary.wrapper;
import com.cloudstore.eccom.pc.table.WeaTableColumn;
import com.engine.salary.entity.salaryacct.bo.SalaryAcctResultBO;
import com.engine.salary.entity.salaryacct.dto.ConsolidatedTaxDetailDTO;
import com.engine.salary.entity.salaryacct.dto.SalaryAcctResultDetailDTO;
import com.engine.salary.entity.salaryacct.param.SalaryAcctResultSaveParam;
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO;
import com.engine.salary.service.SalaryAcctRecordService;
import com.engine.salary.service.SalaryAcctResultService;
import com.engine.salary.service.SalarySobItemService;
import com.engine.salary.service.TaxAgentService;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 薪资核算结果
* <p>Copyright: Copyright (c) 2022</p>
* <p>Company: 泛微软件</p>
*
* @author qiantao
* @version 1.0
**/
@Component
public class SalaryAcctResultWrapper {
private SalaryAcctResultService salaryAcctResultService;
private SalaryAcctRecordService salaryAcctRecordService;
private SalarySobItemService salarySobItemService;
private SalaryAcctEmployeeWrapper salaryAcctEmployeeWrapper;
// private SalaryAcctProgressService salaryAcctProgressService;
// private SalaryCheckResultService salaryCheckResultService;
private TaxAgentService taxAgentService;
/**
* 薪资核算列表
*
* @param queryParam 列表查询条件
* @param tenantKey 租户key
* @return
*/
// public WeaTable<Map<String, Object>> listPage(SalaryAcctResultQueryParam queryParam, String tenantKey) {
// // 查询薪资核算记录
// SalaryAcctRecordPO salaryAcctRecordPO = salaryAcctRecordService.getById(queryParam.getSalaryAcctRecordId());
// if (Objects.isNull(salaryAcctRecordPO)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
// }
// // 构建薪资核算结果列表的表头
// List<WeaTableColumn> weaTableColumns = listWeaTableColumn(salaryAcctRecordPO, tenantKey);
// // 查询薪资核算结果分页
// Page<Map<String, Object>> page = salaryAcctResultService.listPageByParam(queryParam, tenantKey);
// // 转换成前端所需的数据格式
// WeaTable<Map<String, Object>> weaTable = new WeaTable<>();
// weaTable.setColumns(weaTableColumns);
// weaTable.setPage(page);
// weaTable.setData(page.getRecords());
// weaTable.setDisplayData(page.getRecords());
// weaTable.setPageUid("salaryAcctResultList");
// weaTable.setModule("hrmsalary");
// // 列表操作列
// if (Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())) {
// weaTable.setOperates(Collections.singletonList(new WeaTableOperate("edit", SalaryI18nUtil.getI18nLabel(87058, "编辑"), 0, true, true)));
// List<List<Permission>> operatesPermission = page.getRecords().stream().map(e -> Collections.singletonList(new Permission())).collect(Collectors.toList());
// weaTable.setOperatesPermission(operatesPermission);
// }
// return weaTable;
// }
/**
* 构建薪资核算结果列表的表头
*
* @param salaryAcctRecordPO 薪资核算记录
* @param tenantKey 租户key
* @return
*/
public List<WeaTableColumn> listWeaTableColumn(SalaryAcctRecordPO salaryAcctRecordPO, String tenantKey) {
// 查询薪资账套下的薪资项目+员工信息字段
SalarySobItemAggregateDTO salarySobItemAggregateDTO = salarySobItemService.getAggregateBySalarySobId(salaryAcctRecordPO.getSalarySobId());
// 构建薪资核算结果列表表头
return SalaryAcctResultBO.buildTableColumns(salarySobItemAggregateDTO);
}
/**
* 获取薪资核算列表的高级搜索
*
* @return
*/
// public WeaSearchCondition getSearchCondition(String tenantKey) {
// SalaryAcctResultSearchConditionDTO searchConditionDTO = new SalaryAcctResultSearchConditionDTO();
// WeaSearchCondition searchCondition = SalaryFormatUtil.<SalaryAcctResultSearchConditionDTO>getInstance()
// .buildCondition(SalaryAcctResultSearchConditionDTO.class, searchConditionDTO, "SalaryAcctResultCondition");
// // 查询个税扣缴义务人
// List<TaxAgentPO> taxAgentPOS = taxAgentService.listAll(tenantKey);
// List<WeaSearchConditionOption> weaSearchConditionOptions = taxAgentPOS.stream()
// .map(taxAgentPO -> new WeaSearchConditionOption(String.valueOf(taxAgentPO.getId()), taxAgentPO.getName()))
// .collect(Collectors.toList());
// // 给查询条件中的个税扣缴义务人填充下拉项
// searchCondition.getItems().forEach((k, v) -> {
// if (StringUtils.equals("taxAgentId", k)) {
// v.setOptions(weaSearchConditionOptions);
// }
// });
// // 其他条件不要
// searchCondition.getGroups().remove(1);
// return searchCondition;
// }
/**
* 薪资核算结果详情
*
* @param salaryAcctEmployeeId 薪资核算人员id
* @return
*/
public SalaryAcctResultDetailDTO getForm(Long salaryAcctEmployeeId) {
// 获取薪资核算结果详情
return salaryAcctResultService.getBySalaryAcctEmployeeId(salaryAcctEmployeeId);
}
/**
* 获取合并计税详情
*
* @param salaryAcctEmployeeId 薪资核算人员id
* @return
*/
public ConsolidatedTaxDetailDTO getConsolidatedTaxDetail(Long salaryAcctEmployeeId) {
// 获取合并计税详情
return salaryAcctResultService.getConsolidatedTaxDetail(salaryAcctEmployeeId);
}
/**
* 保存薪资核算结果
*
* @param saveParam 保存参数
*/
public void save(SalaryAcctResultSaveParam saveParam) {
salaryAcctResultService.save(saveParam);
}
/**
* 薪资核算-核算
*
* @param calculateParam 薪资核算的参数
* @param simpleEmployee 当前登陆人员
* @param tenantKey 租户key
*/
// public void calculate(SalaryAcctCalculateParam calculateParam, DataCollectionEmployee simpleEmployee) {
// // 检查薪资核算人员的个税扣缴义务人
// salaryAcctEmployeeWrapper.checkTaxAgent(calculateParam.getSalaryAcctRecordId());
// // 检查是否正在核算中
// SalaryAcctProgressDTO salaryAcctProgressDTO = salaryAcctProgressService.getProgress("" + calculateParam.getSalaryAcctRecordId(), simpleEmployee.getEmployeeId(), tenantKey);
// if (Objects.nonNull(salaryAcctProgressDTO) && salaryAcctProgressDTO.isStatus() && Optional.ofNullable(salaryAcctProgressDTO.getProgress()).orElse(BigDecimal.ZERO).compareTo(BigDecimal.ONE) < 0) {
// return;
// }
// // 初始化进度
// SalaryAcctProgressDTO initProgress = new SalaryAcctProgressDTO()
// .setTitle(SalaryI18nUtil.getI18nLabel(97515, "核算中"))
// .setTitleLabelId(97515L)
// .setTotalQuantity(NumberUtils.INTEGER_ONE)
// .setCalculatedQuantity(NumberUtils.INTEGER_ZERO)
// .setProgress(BigDecimal.ZERO)
// .setStatus(true)
// .setMessage(StringUtils.EMPTY);
// salaryAcctProgressService.initProgress("" + calculateParam.getSalaryAcctRecordId(), initProgress, simpleEmployee.getEmployeeId(), tenantKey);
// // 异步执行薪资核算
// LocalRunnable localRunnable = new LocalRunnable() {
// @Override
// public void execute() {
// salaryAcctResultService.calculate(calculateParam, simpleEmployee, tenantKey);
// }
// };
// ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "salaryAcctCalculate", localRunnable);
// }
/**
* 薪资核算-校验
*
* @param checkParam 薪资核算的参数
* @param simpleEmployee 当前登陆人员
* @param tenantKey 租户key
*/
// public void check(SalaryAcctCheckParam checkParam, SimpleEmployee simpleEmployee, String tenantKey) {
// // 检查是否正在核算中
// SalaryAcctProgressDTO salaryAcctProgressDTO = salaryAcctProgressService.getProgress("" + checkParam.getSalaryAcctRecordId(), simpleEmployee.getEmployeeId(), tenantKey);
// if (Objects.nonNull(salaryAcctProgressDTO) && salaryAcctProgressDTO.isStatus() && Optional.ofNullable(salaryAcctProgressDTO.getProgress()).orElse(BigDecimal.ZERO).compareTo(BigDecimal.ONE) < 0) {
// return;
// }
// // 初始化进度
// SalaryAcctProgressDTO initProgress = new SalaryAcctProgressDTO()
// .setTitle(SalaryI18nUtil.getI18nLabel(99664, "正在运行校验规则"))
// .setTitleLabelId(99664L)
// .setTotalQuantity(NumberUtils.INTEGER_ONE)
// .setCalculatedQuantity(NumberUtils.INTEGER_ZERO)
// .setProgress(BigDecimal.ZERO)
// .setStatus(true)
// .setMessage(StringUtils.EMPTY);
// salaryAcctProgressService.initProgress("" + checkParam.getSalaryAcctRecordId(), initProgress, simpleEmployee.getEmployeeId(), tenantKey);
// // 异步执行校验
// LocalRunnable localRunnable = new LocalRunnable() {
// @Override
// public void execute() {
// salaryCheckResultService.check(checkParam, false, simpleEmployee, tenantKey);
// }
// };
// ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "salaryAcctCheck", localRunnable);
// }
}