//package com.engine.salary.entity.salaryacct.bo; // //import com.google.common.collect.Lists; //import com.google.common.collect.Sets; //import com.weaver.common.distribution.genid.IdGenerator; //import com.weaver.hrm.salary.entity.salaryacct.dto.SalaryAccEmployeeListDTO; //import com.weaver.hrm.salary.entity.salaryacct.po.SalaryAcctEmployeePO; //import com.weaver.hrm.salary.entity.salaryacct.po.SalaryAcctRecordPO; //import com.weaver.hrm.salary.entity.salaryarchive.dto.SalaryArchiveDataDTO; //import com.weaver.hrm.salary.entity.salaryarchive.dto.SalaryArchiveTaxAgentDataDTO; //import com.weaver.hrm.salary.entity.salaryarchive.po.TaxAgentPO; //import com.weaver.hrm.salary.util.SalaryDateUtil; //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 java.time.LocalDateTime; //import java.util.*; //import java.util.stream.Collectors; // ///** // * @description: 薪资核算人员 // * @author: xiajun // * @modified By: xiajun // * @date: Created in 1/21/22 4:20 PM // * @version:v1.0 // */ //public class SalaryAcctEmployeeBO { // // /** // * 将薪资核算人员po转换成薪资核算人员列表dto // * // * @param salaryAccountingEmployees // * @param taxAgents // * @param simpleEmployees // * @return // */ // public static List convert2EmployeeListDTO(List salaryAccountingEmployees, // List taxAgents, // List simpleEmployees) { // if (CollectionUtils.isEmpty(salaryAccountingEmployees)) { // return Collections.emptyList(); // } // Map taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getId, TaxAgentPO::getName); // Map simpleEmployeeMap = SalaryEntityUtil.convert2Map(simpleEmployees, SimpleEmployee::getId); // return salaryAccountingEmployees.stream() // .map(e -> { // SimpleEmployee simpleEmployee = simpleEmployeeMap.get(e.getEmployeeId()); // if (simpleEmployee == null) { // return SalaryAccEmployeeListDTO.builder() // .id(e.getId()) // .employeeId(e.getId()) // .taxAgentId(e.getTaxAgentId()) // .taxAgentName(taxAgentNameMap.getOrDefault(e.getTaxAgentId(), StringUtils.EMPTY)) // .build(); // } // return SalaryAccEmployeeListDTO.builder() // .id(e.getId()) // .employeeId(simpleEmployee.getEmployeeId()) // .employeeName(simpleEmployee.getUsername()) // .taxAgentId(e.getTaxAgentId()) // .taxAgentName(taxAgentNameMap.getOrDefault(e.getTaxAgentId(), StringUtils.EMPTY)) // .departmentId(simpleEmployee.getDepartment().getId()) // .departmentName(simpleEmployee.getDepartment().getName()) // .status(simpleEmployee.getStatus().getDescription()) // .mobile(simpleEmployee.getMobile()) // .jobNum(simpleEmployee.getJobNum()) // .hireDate(SalaryDateUtil.getFormatLocalDate(simpleEmployee.getHiredate())) // .dismissDate("") // .build(); // }).collect(Collectors.toList()); // } // // /** // * 转换成薪资核算人员的po // * // * @param employeeIds // * @param salaryAcctRecord // * @param salaryArchiveTaxAgentData // * @param employeeId // * @param tenantKey // * @return // */ // public static List convert2EmployeePO(Collection employeeIds, // SalaryAcctRecordPO salaryAcctRecord, // List salaryArchiveTaxAgentData, // Long employeeId, String tenantKey) { // if (CollectionUtils.isEmpty(employeeIds)) { // return Collections.emptyList(); // } // List resultList = Lists.newArrayList(); // Map>> empIdKeyTaxAgentMap = SalaryEntityUtil.group2Map(salaryArchiveTaxAgentData, SalaryArchiveDataDTO::getEmployeeId, SalaryArchiveDataDTO::getTaxAgents); // LocalDateTime now = LocalDateTime.now(); // for (Long id : employeeIds) { // Set taxAgentIds = Sets.newHashSet(); // Set> taxAgentSet = empIdKeyTaxAgentMap.getOrDefault(id, Collections.emptySet()); // for (List taxAgents : taxAgentSet) { // taxAgentIds.addAll(SalaryEntityUtil.properties(taxAgents, SalaryArchiveTaxAgentDataDTO::getTaxAgentId)); // } // if (CollectionUtils.isEmpty(taxAgentIds)) { // taxAgentIds.add(0L); // } // for (Long taxAgentId : taxAgentIds) { // SalaryAcctEmployeePO salaryAcctEmployee = SalaryAcctEmployeePO.builder() // .id(IdGenerator.generate()) // .salaryAcctRecordId(salaryAcctRecord.getId()) // .salarySobId(salaryAcctRecord.getSalarySobId()) // .salaryMonth(salaryAcctRecord.getSalaryMonth()) // .employeeId(id) // .taxAgentId(taxAgentId) // .creator(employeeId) // .createTime(now) // .updateTime(now) // .deleteType(0) // .tenantKey(tenantKey) // .build(); // resultList.add(salaryAcctEmployee); // } // } // return resultList; // } //}