2023-05-09 10:43:51 +08:00
|
|
|
|
package com.engine.salary.report.service.impl;
|
|
|
|
|
|
|
2024-03-25 16:08:34 +08:00
|
|
|
|
import cn.hutool.core.util.NumberUtil;
|
2023-05-09 10:43:51 +08:00
|
|
|
|
import com.engine.common.util.ServiceUtil;
|
|
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
|
|
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
2024-10-08 14:19:02 +08:00
|
|
|
|
import com.engine.salary.entity.salaryacct.param.SalaryAcctEmployeeQueryParam;
|
2023-05-09 10:43:51 +08:00
|
|
|
|
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
|
2023-05-26 11:17:25 +08:00
|
|
|
|
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
|
2023-05-09 10:43:51 +08:00
|
|
|
|
import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO;
|
|
|
|
|
|
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
2023-05-26 11:17:25 +08:00
|
|
|
|
import com.engine.salary.entity.salarysob.po.SalarySobPO;
|
2024-09-19 16:46:36 +08:00
|
|
|
|
import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam;
|
2023-05-09 10:43:51 +08:00
|
|
|
|
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
2023-05-26 11:17:25 +08:00
|
|
|
|
import com.engine.salary.enums.UserStatusEnum;
|
2024-09-19 16:46:36 +08:00
|
|
|
|
import com.engine.salary.enums.auth.AuthFilterTypeEnum;
|
2023-07-12 09:45:00 +08:00
|
|
|
|
import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum;
|
2025-03-17 11:03:42 +08:00
|
|
|
|
import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum;
|
2024-03-25 16:08:34 +08:00
|
|
|
|
import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum;
|
2023-05-09 10:43:51 +08:00
|
|
|
|
import com.engine.salary.mapper.salaryacct.SalaryAcctEmployeeMapper;
|
|
|
|
|
|
import com.engine.salary.report.common.constant.SalaryConstant;
|
|
|
|
|
|
import com.engine.salary.report.entity.bo.SalaryStatisticsEmployeeBO;
|
|
|
|
|
|
import com.engine.salary.report.entity.dto.SalaryStatisticsEmployeeDetailResultDTO;
|
|
|
|
|
|
import com.engine.salary.report.entity.dto.SalaryStatisticsEmployeeListDTO;
|
|
|
|
|
|
import com.engine.salary.report.entity.param.SalaryStatisticsEmployeeDetailQueryParam;
|
|
|
|
|
|
import com.engine.salary.report.entity.param.SalaryStatisticsEmployeeQueryParam;
|
2024-03-25 16:08:34 +08:00
|
|
|
|
import com.engine.salary.report.entity.param.SalaryStatisticsEmployeeSalaryQueryParam;
|
2023-05-09 10:43:51 +08:00
|
|
|
|
import com.engine.salary.report.service.SalaryStatisticsEmployeeService;
|
|
|
|
|
|
import com.engine.salary.service.*;
|
2024-09-19 16:46:36 +08:00
|
|
|
|
import com.engine.salary.service.auth.AuthService;
|
|
|
|
|
|
import com.engine.salary.service.auth.AuthServiceImpl;
|
2023-05-09 10:43:51 +08:00
|
|
|
|
import com.engine.salary.service.impl.*;
|
2025-11-18 09:34:24 +08:00
|
|
|
|
import com.engine.salary.sys.service.SalarySysConfService;
|
|
|
|
|
|
import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl;
|
2024-11-25 16:04:19 +08:00
|
|
|
|
import com.engine.salary.util.SalaryAssert;
|
|
|
|
|
|
import com.engine.salary.util.SalaryDateUtil;
|
|
|
|
|
|
import com.engine.salary.util.SalaryEntityUtil;
|
|
|
|
|
|
import com.engine.salary.util.SalaryI18nUtil;
|
2023-05-09 10:43:51 +08:00
|
|
|
|
import com.engine.salary.util.db.MapperProxyFactory;
|
|
|
|
|
|
import com.engine.salary.util.page.PageInfo;
|
|
|
|
|
|
import com.engine.salary.util.page.SalaryPageUtil;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
|
import com.google.common.collect.Maps;
|
2024-03-25 16:08:34 +08:00
|
|
|
|
import com.wbi.util.Util;
|
2023-05-09 10:43:51 +08:00
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
2025-11-18 09:34:24 +08:00
|
|
|
|
import static com.engine.salary.sys.constant.SalarySysConstant.REPORT_ORGANIZATIN_TYPE;
|
|
|
|
|
|
|
2023-05-09 10:43:51 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 薪酬统计员工明细
|
|
|
|
|
|
* <p>Copyright: Copyright (c) 2022</p>
|
|
|
|
|
|
* <p>Company: 泛微软件</p>
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author qiantao
|
|
|
|
|
|
* @version 1.0
|
|
|
|
|
|
**/
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
|
public class SalaryStatisticsEmployeeServiceImpl extends Service implements SalaryStatisticsEmployeeService {
|
|
|
|
|
|
|
|
|
|
|
|
private SalaryAcctEmployeeMapper getSalaryAcctEmployeeMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(SalaryAcctEmployeeMapper.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private SalaryAcctEmployeeService getSalaryAcctEmployeeService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private SalaryAcctResultService getSalaryAcctResultService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private SalaryItemService getSalaryItemService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalaryItemServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-26 11:17:25 +08:00
|
|
|
|
private SalarySobService getSalarySobService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalarySobServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private SalaryAcctRecordService getSalaryAcctRecordService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-09 10:43:51 +08:00
|
|
|
|
|
|
|
|
|
|
// private ExtEmployeeMapper extEmployeeMapper;
|
|
|
|
|
|
|
|
|
|
|
|
private TaxAgentService getTaxAgentService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private SalaryEmployeeService getSalaryEmployeeService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalaryEmployeeServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-19 16:46:36 +08:00
|
|
|
|
public AuthService getAuthService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(AuthServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-11 15:34:17 +08:00
|
|
|
|
private SettingService getSettingService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SettingServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-18 09:34:24 +08:00
|
|
|
|
private SalarySysConfService getSalarySysConfService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalarySysConfServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private final boolean isRealOrg = "1".equals(getSalarySysConfService(user).getValueByCode(REPORT_ORGANIZATIN_TYPE));
|
2023-05-09 10:43:51 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public PageInfo<SalaryStatisticsEmployeeListDTO> listPage(SalaryStatisticsEmployeeQueryParam queryParam) {
|
|
|
|
|
|
List<SalaryStatisticsEmployeeListDTO> list = Collections.emptyList();
|
2023-05-26 11:17:25 +08:00
|
|
|
|
PageInfo<SalaryStatisticsEmployeeListDTO> page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), list, SalaryStatisticsEmployeeListDTO.class);
|
2023-05-09 10:43:51 +08:00
|
|
|
|
|
|
|
|
|
|
// 1.分权处理, 首先获取个税扣缴义务人参数
|
2024-09-19 16:46:36 +08:00
|
|
|
|
TaxAgentQueryParam taxAgentQueryParam = new TaxAgentQueryParam();
|
|
|
|
|
|
taxAgentQueryParam.setFilterType(AuthFilterTypeEnum.QUERY_DATA);
|
|
|
|
|
|
Collection<TaxAgentPO> taxAgentViews = getTaxAgentService(user).listAuth(taxAgentQueryParam);
|
2023-05-09 10:43:51 +08:00
|
|
|
|
List<Long> taxAgentIds = Objects.isNull(taxAgentViews) ? Lists.newArrayList() : taxAgentViews.stream().map(TaxAgentPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
if (CollectionUtils.isEmpty(taxAgentIds)) {
|
|
|
|
|
|
return page;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 2.年月参数处理,注意:薪资所属月居然是用字符串存储的,无法通过sql between处理
|
|
|
|
|
|
Set<Date> salaryMonths = SalaryStatisticsEmployeeBO.getSalaryMonths(queryParam.getYear(), queryParam.getSalaryMonth())
|
|
|
|
|
|
.stream()
|
|
|
|
|
|
.map(SalaryDateUtil::dateStrToLocalYearMonth)
|
|
|
|
|
|
.collect(Collectors.toSet());
|
|
|
|
|
|
|
|
|
|
|
|
// 查询薪资核算人员
|
2024-10-08 14:19:02 +08:00
|
|
|
|
SalaryAcctEmployeeQueryParam salaryAcctEmployeeQueryParam = SalaryAcctEmployeeQueryParam.builder().salaryMonths(salaryMonths).taxAgentIds(taxAgentIds).build();
|
|
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployeeList = getSalaryAcctEmployeeService(user).listByParam(salaryAcctEmployeeQueryParam);
|
2024-09-19 16:46:36 +08:00
|
|
|
|
salaryAcctEmployeeList = getAuthService(user).auth(salaryAcctEmployeeList, AuthFilterTypeEnum.QUERY_DATA,SalaryAcctEmployeePO.class,"report");
|
2023-05-09 10:43:51 +08:00
|
|
|
|
if (CollectionUtils.isEmpty(salaryAcctEmployeeList)) {
|
|
|
|
|
|
return page;
|
|
|
|
|
|
}
|
2024-09-19 16:46:36 +08:00
|
|
|
|
|
2023-05-09 10:43:51 +08:00
|
|
|
|
// 内部人员id
|
2024-10-08 14:19:02 +08:00
|
|
|
|
Set<Long> innerEmployeeIds = salaryAcctEmployeeList.stream().map(SalaryAcctEmployeePO::getEmployeeId).collect(Collectors.toCollection(LinkedHashSet::new));
|
|
|
|
|
|
|
2023-05-09 10:43:51 +08:00
|
|
|
|
// 3.关键字搜索参数
|
|
|
|
|
|
if (StringUtils.isNotEmpty(queryParam.getKeyword())) {
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(innerEmployeeIds)) {
|
2023-07-12 09:45:00 +08:00
|
|
|
|
List<DataCollectionEmployee> salaryEmployees = getSalaryEmployeeService(user).listAll(UseEmployeeTypeEnum.ALL);
|
2023-05-09 10:43:51 +08:00
|
|
|
|
Set<Long> finalInnerEmployeeIds = innerEmployeeIds;
|
|
|
|
|
|
innerEmployeeIds = salaryEmployees.stream()
|
|
|
|
|
|
.filter(e -> finalInnerEmployeeIds.contains(e.getEmployeeId()) && (e.getUsername().contains(queryParam.getKeyword()) || (StringUtils.isNotEmpty(e.getWorkcode()) && e.getWorkcode().contains(queryParam.getKeyword()))))
|
|
|
|
|
|
.map(DataCollectionEmployee::getEmployeeId)
|
|
|
|
|
|
.collect(Collectors.toSet());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-19 16:46:36 +08:00
|
|
|
|
list = innerEmployeeIds.stream().map(e -> SalaryStatisticsEmployeeListDTO.builder().id(e).build()).collect(Collectors.toList());
|
2023-05-09 10:43:51 +08:00
|
|
|
|
|
|
|
|
|
|
// 第一页数据显示处理
|
|
|
|
|
|
page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), list, SalaryStatisticsEmployeeListDTO.class);
|
|
|
|
|
|
List<SalaryStatisticsEmployeeListDTO> salaryStatisticsEmployeeListDTOs = page.getList();
|
|
|
|
|
|
List<Long> employeeIds = salaryStatisticsEmployeeListDTOs.stream().map(SalaryStatisticsEmployeeListDTO::getId).collect(Collectors.toList());
|
2023-05-26 11:17:25 +08:00
|
|
|
|
List<DataCollectionEmployee> simpleEmployeeList = getSalaryEmployeeService(user).getEmployeeByIdsAll(employeeIds);
|
2023-05-09 10:43:51 +08:00
|
|
|
|
Map<Long, DataCollectionEmployee> innerEmployeeMap = simpleEmployeeList.stream().collect(Collectors.toMap(DataCollectionEmployee::getEmployeeId, v -> v));
|
|
|
|
|
|
salaryStatisticsEmployeeListDTOs.forEach(e -> {
|
|
|
|
|
|
DataCollectionEmployee simpleEmployee = innerEmployeeMap.get(e.getId());
|
|
|
|
|
|
e.setName(Objects.isNull(simpleEmployee) ? "" : simpleEmployee.getUsername());
|
|
|
|
|
|
e.setSubCompany(simpleEmployee.getSubcompanyName());
|
|
|
|
|
|
e.setDepartment(simpleEmployee.getDepartmentName());
|
|
|
|
|
|
e.setPosition(simpleEmployee.getJobtitleName());
|
2023-05-26 11:17:25 +08:00
|
|
|
|
e.setStatus(UserStatusEnum.getDefaultLabelByValue(Integer.parseInt(simpleEmployee.getStatus())));
|
2023-05-09 10:43:51 +08:00
|
|
|
|
e.setJobNum(simpleEmployee.getWorkcode());
|
|
|
|
|
|
e.setIdNo(simpleEmployee.getIdNo());
|
|
|
|
|
|
});
|
|
|
|
|
|
page.setList(salaryStatisticsEmployeeListDTOs);
|
|
|
|
|
|
return page;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public SalaryStatisticsEmployeeDetailResultDTO getDetailSalaryAcctResult(SalaryStatisticsEmployeeDetailQueryParam queryParam) {
|
|
|
|
|
|
SalaryAssert.notNull(queryParam.getEmployeeId(), SalaryI18nUtil.getI18nLabel(163974, "人员id不能为空"));
|
|
|
|
|
|
|
|
|
|
|
|
// 薪资所属月参数,如果已经有年的就取交集
|
|
|
|
|
|
Set<Date> salaryMonths = SalaryStatisticsEmployeeBO.getSalaryMonths(queryParam.getYear(), queryParam.getSalaryMonth()).stream().map(SalaryDateUtil::dateStrToLocalYearMonth).collect(Collectors.toSet());
|
|
|
|
|
|
|
|
|
|
|
|
// 1.获取该员工所有核算人员数据
|
|
|
|
|
|
SalaryAcctEmployeePO build = SalaryAcctEmployeePO.builder().employeeId(queryParam.getEmployeeId()).build();
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(queryParam.getIds())) {
|
|
|
|
|
|
build.setIds(queryParam.getIds());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(salaryMonths)) {
|
|
|
|
|
|
build.setSalaryMonths(salaryMonths);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (Objects.nonNull(queryParam.getTaxAgentId())) {
|
|
|
|
|
|
build.setTaxAgentId(queryParam.getTaxAgentId());
|
|
|
|
|
|
}
|
|
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployees = getSalaryAcctEmployeeMapper().listSome(build);
|
|
|
|
|
|
salaryAcctEmployees = salaryAcctEmployees.stream().sorted(Comparator.comparing(SalaryAcctEmployeePO::getSalaryMonth)).collect(Collectors.toList());
|
|
|
|
|
|
Collections.reverse(salaryAcctEmployees);
|
|
|
|
|
|
|
|
|
|
|
|
// 2.获取核算结果数据
|
2023-05-25 13:51:27 +08:00
|
|
|
|
List<Long> salaryAcctEmployeeIds = salaryAcctEmployees.stream().map(SalaryAcctEmployeePO::getId).collect(Collectors.toList());
|
2023-05-09 10:43:51 +08:00
|
|
|
|
List<SalaryAcctResultPO> salaryAcctResultValues = getSalaryAcctResultService(user).listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds);
|
|
|
|
|
|
|
|
|
|
|
|
// 3.获取薪资项目
|
|
|
|
|
|
Map<String, String> resultMap = Maps.newHashMap();
|
|
|
|
|
|
salaryAcctResultValues.forEach(sv -> {
|
|
|
|
|
|
resultMap.put(sv.getSalaryItemId() + "", sv.getResultValue());
|
|
|
|
|
|
});
|
|
|
|
|
|
List<Long> salaryItemIds = resultMap.keySet().stream().map(Long::valueOf).collect(Collectors.toList());
|
|
|
|
|
|
List<SalaryItemPO> salaryItemList = CollectionUtils.isEmpty(salaryItemIds) ? Lists.newArrayList() : getSalaryItemService(user).listByIds(salaryItemIds);
|
|
|
|
|
|
|
|
|
|
|
|
return SalaryStatisticsEmployeeDetailResultDTO.builder()
|
|
|
|
|
|
.salaryAcctEmployeeList(salaryAcctEmployees)
|
|
|
|
|
|
.salaryAcctResultValueList(salaryAcctResultValues)
|
|
|
|
|
|
.salaryItemList(salaryItemList)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<Map<String, Object>> listDetailPage(SalaryStatisticsEmployeeDetailResultDTO salaryStatisticsEmployeeDetailResult, SalaryStatisticsEmployeeDetailQueryParam queryParam) {
|
|
|
|
|
|
|
|
|
|
|
|
List<TaxAgentPO> taxAgentList = getTaxAgentService(user).listAll();
|
|
|
|
|
|
Map<Long, String> taxAgentMap = SalaryEntityUtil.convert2Map(taxAgentList, TaxAgentPO::getId, TaxAgentPO::getName);
|
|
|
|
|
|
|
2023-05-26 11:17:25 +08:00
|
|
|
|
List<SalarySobPO> salarySobPOS = getSalarySobService(user).listAll();
|
|
|
|
|
|
Map<Long, String> SalarySobMap = SalaryEntityUtil.convert2Map(salarySobPOS, SalarySobPO::getId, SalarySobPO::getName);
|
|
|
|
|
|
|
|
|
|
|
|
List<SalaryAcctRecordPO> salaryAcctRecordPOS = getSalaryAcctRecordService(user).listAll();
|
|
|
|
|
|
Map<Long, Integer> salaryAcctRecordMap = SalaryEntityUtil.convert2Map(salaryAcctRecordPOS, SalaryAcctRecordPO::getId, SalaryAcctRecordPO::getAcctTimes);
|
|
|
|
|
|
|
2025-03-17 11:03:42 +08:00
|
|
|
|
List<SalaryItemPO> salaryItemPOList = getSalaryItemService(user).listAll();
|
|
|
|
|
|
Map<Long, String> itemDataTypeMap = SalaryEntityUtil.convert2Map(salaryItemPOList, SalaryItemPO::getId, SalaryItemPO::getDataType);
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-05-09 10:43:51 +08:00
|
|
|
|
Map<Long, List<SalaryAcctResultPO>> acctResultValueList = SalaryEntityUtil.group2Map(salaryStatisticsEmployeeDetailResult.getSalaryAcctResultValueList(), SalaryAcctResultPO::getSalaryAcctEmpId);
|
2025-03-17 11:03:42 +08:00
|
|
|
|
Map<Long, Map<String, Object>> acctResultValueMap = new HashMap<>();
|
2023-05-09 10:43:51 +08:00
|
|
|
|
acctResultValueList.forEach((k, v) -> {
|
2025-03-17 11:03:42 +08:00
|
|
|
|
Map<String, Object> map = new HashMap();
|
2023-05-09 10:43:51 +08:00
|
|
|
|
v.forEach(l -> {
|
2025-03-17 11:03:42 +08:00
|
|
|
|
String dataType = itemDataTypeMap.getOrDefault(l.getSalaryItemId(), "string");
|
|
|
|
|
|
SalaryDataTypeEnum typeEnum = SalaryDataTypeEnum.parseByValue(dataType);
|
|
|
|
|
|
String resultValue = l.getResultValue();
|
|
|
|
|
|
if (typeEnum == SalaryDataTypeEnum.NUMBER && NumberUtil.isNumber(resultValue)) {
|
|
|
|
|
|
map.put(l.getSalaryItemId() + "", Double.valueOf(resultValue));
|
|
|
|
|
|
} else {
|
|
|
|
|
|
map.put(l.getSalaryItemId() + "", resultValue);
|
|
|
|
|
|
}
|
2023-05-09 10:43:51 +08:00
|
|
|
|
});
|
|
|
|
|
|
acctResultValueMap.put(k, map);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-03-25 16:08:34 +08:00
|
|
|
|
// 获取人员信息
|
|
|
|
|
|
List<DataCollectionEmployee> employeeList = getSalaryEmployeeService(user).listByIds(salaryStatisticsEmployeeDetailResult.getSalaryAcctEmployeeList().stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList()));
|
|
|
|
|
|
Map<Long, DataCollectionEmployee> empMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId);
|
2023-05-09 10:43:51 +08:00
|
|
|
|
List<Map<String, Object>> list = Lists.newArrayList();
|
|
|
|
|
|
Map<String, Object> map;
|
|
|
|
|
|
for (SalaryAcctEmployeePO se : salaryStatisticsEmployeeDetailResult.getSalaryAcctEmployeeList()) {
|
|
|
|
|
|
map = Maps.newHashMap();
|
2025-03-17 11:03:42 +08:00
|
|
|
|
Map<String, Object> resultValueMap = Optional.ofNullable(acctResultValueMap.get(se.getId())).orElse(Maps.newHashMap());
|
2023-05-09 10:43:51 +08:00
|
|
|
|
Map<String, Object> finalMap = map;
|
|
|
|
|
|
resultValueMap.forEach((k, v) -> {
|
|
|
|
|
|
finalMap.put(k + SalaryConstant.DYNAMIC_SUFFIX, v);
|
|
|
|
|
|
});
|
2024-03-25 16:08:34 +08:00
|
|
|
|
DataCollectionEmployee emp = empMap.getOrDefault(se.getEmployeeId(), DataCollectionEmployee.builder().build());
|
2023-05-09 10:43:51 +08:00
|
|
|
|
map.put("id", se.getId().toString());
|
2023-05-26 11:17:25 +08:00
|
|
|
|
map.put("salaryMonth", SalaryDateUtil.getFormatYearMonth(se.getSalaryMonth()));
|
2023-05-09 10:43:51 +08:00
|
|
|
|
map.put("taxAgent", taxAgentMap.get(se.getTaxAgentId()));
|
2024-10-11 15:34:17 +08:00
|
|
|
|
map.put("salarySob", SalarySobMap.get(se.getSalarySobId()));
|
2023-05-26 11:17:25 +08:00
|
|
|
|
map.put("acctTimes", salaryAcctRecordMap.get(se.getSalaryAcctRecordId()));
|
2024-03-25 16:08:34 +08:00
|
|
|
|
map.put("userName", Util.null2String(emp.getUsername()));
|
|
|
|
|
|
map.put("workCode", Util.null2String(emp.getWorkcode()));
|
2024-12-09 14:34:57 +08:00
|
|
|
|
map.put("idNo", Util.null2String(emp.getIdNo()));
|
2024-10-09 18:10:38 +08:00
|
|
|
|
map.put("companystartdate", Util.null2String(emp.getCompanystartdate()));
|
2024-03-25 16:08:34 +08:00
|
|
|
|
|
2025-11-18 09:34:24 +08:00
|
|
|
|
if(isRealOrg){
|
|
|
|
|
|
map.put("subCompany", Util.null2String(emp.getSubcompanyName()));
|
|
|
|
|
|
map.put("department", Util.null2String(emp.getDepartmentName()));
|
|
|
|
|
|
map.put("jobTitle", Util.null2String(emp.getJobtitleName()));
|
|
|
|
|
|
map.put("status", Util.null2String(NumberUtil.isNumber(emp.getStatus()) ? SalaryEmployeeStatusEnum.parseByValue(Integer.valueOf(emp.getStatus())).getDefaultLabel() : null));
|
|
|
|
|
|
}else {
|
|
|
|
|
|
map.put("subCompany", Util.null2String(se.getSubcompanyName()));
|
|
|
|
|
|
map.put("department", Util.null2String(se.getDepartmentName()));
|
|
|
|
|
|
map.put("jobTitle", Util.null2String(se.getJobtitleName()));
|
|
|
|
|
|
map.put("status", Util.null2String(NumberUtil.isNumber(se.getStatus()) ? SalaryEmployeeStatusEnum.parseByValue(Integer.valueOf(se.getStatus())).getDefaultLabel() : null));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-09 10:43:51 +08:00
|
|
|
|
// IncomeCategoryEnum incomeCategoryEnum = IncomeCategoryEnum.parseByValue(Integer.parseInt(se.getIncomeCategory()));
|
|
|
|
|
|
// map.put("incomeCategory", Objects.isNull(incomeCategoryEnum) ? "" : SalaryI18nUtil.getI18nLabel(incomeCategoryEnum.getLabelId(), incomeCategoryEnum.getDefaultLabel()));
|
|
|
|
|
|
list.add(map);
|
|
|
|
|
|
}
|
|
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-25 16:08:34 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public PageInfo<SalaryAcctEmployeePO> listSalaryAcctEmp(SalaryStatisticsEmployeeSalaryQueryParam queryParam) {
|
|
|
|
|
|
// 1.分权处理, 首先获取个税扣缴义务人参数
|
2024-09-19 16:46:36 +08:00
|
|
|
|
TaxAgentQueryParam param = TaxAgentQueryParam.builder().build();
|
|
|
|
|
|
param.setFilterType(AuthFilterTypeEnum.QUERY_DATA);
|
|
|
|
|
|
Collection<TaxAgentPO> taxAgentViews = getTaxAgentService(user).listAuth(param);
|
2024-03-25 16:08:34 +08:00
|
|
|
|
List<Long> taxAgentIds = Objects.isNull(taxAgentViews) ? Lists.newArrayList() : taxAgentViews.stream().map(TaxAgentPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(queryParam.getTaxAgentIds())) {
|
|
|
|
|
|
taxAgentIds = taxAgentIds.stream().filter(queryParam.getTaxAgentIds()::contains).collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (CollectionUtils.isEmpty(taxAgentIds)) {
|
|
|
|
|
|
return new PageInfo<>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 2.年月参数处理,注意:薪资所属月居然是用字符串存储的,无法通过sql between处理
|
|
|
|
|
|
List<Date> dataParam = new ArrayList<>();
|
|
|
|
|
|
if (StringUtils.isNotBlank(queryParam.getStartDateStr())) {
|
2024-10-11 15:34:17 +08:00
|
|
|
|
dataParam.add(SalaryDateUtil.dateStrToLocalTime(queryParam.getStartDateStr() + "-01 00:00:00"));
|
2024-03-25 16:08:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotBlank(queryParam.getEndDateStr())) {
|
2024-10-11 15:34:17 +08:00
|
|
|
|
dataParam.add(SalaryDateUtil.dateStrToLocalTime(queryParam.getEndDateStr() + "-01 00:00:00"));
|
2024-03-25 16:08:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
Set<Date> salaryMonths = SalaryStatisticsEmployeeBO.getSalaryMonths(null, dataParam)
|
|
|
|
|
|
.stream()
|
|
|
|
|
|
.map(SalaryDateUtil::dateStrToLocalYearMonth)
|
|
|
|
|
|
.collect(Collectors.toSet());
|
|
|
|
|
|
|
|
|
|
|
|
// 查询薪资核算人员
|
2024-10-08 15:45:12 +08:00
|
|
|
|
SalaryAcctEmployeeQueryParam salaryAcctEmployeeQueryParam = SalaryAcctEmployeeQueryParam.builder().salaryMonths(salaryMonths).taxAgentIds(taxAgentIds).build();
|
|
|
|
|
|
List<SalaryAcctEmployeePO> salaryAcctEmployeeList = getSalaryAcctEmployeeService(user).listByParam(salaryAcctEmployeeQueryParam);
|
2024-09-19 16:46:36 +08:00
|
|
|
|
salaryAcctEmployeeList = getAuthService(user).auth(salaryAcctEmployeeList, AuthFilterTypeEnum.QUERY_DATA,SalaryAcctEmployeePO.class,"report");
|
|
|
|
|
|
|
2024-03-25 16:08:34 +08:00
|
|
|
|
if (CollectionUtils.isNotEmpty(queryParam.getSubCompanyIds()) || CollectionUtils.isNotEmpty(queryParam.getDepartmentIds()) || StringUtils.isNotBlank(queryParam.getKeyword())) {
|
|
|
|
|
|
// 根据分部、部门筛选
|
|
|
|
|
|
List<DataCollectionEmployee> employeeList = getSalaryEmployeeService(user).listBySubCompanyOrDepartment(queryParam.getSubCompanyIds(), queryParam.getDepartmentIds());
|
|
|
|
|
|
// 根据关键词过滤
|
2024-10-11 15:34:17 +08:00
|
|
|
|
if (StringUtils.isNotBlank(queryParam.getKeyword())) {
|
2024-03-25 16:08:34 +08:00
|
|
|
|
employeeList = employeeList.stream()
|
2024-11-26 18:14:41 +08:00
|
|
|
|
.filter(e -> (StringUtils.isNotEmpty(e.getUsername()) && e.getUsername().contains(queryParam.getKeyword()) || (StringUtils.isNotEmpty(e.getWorkcode()) && e.getWorkcode().contains(queryParam.getKeyword()))))
|
2024-03-25 16:08:34 +08:00
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
List<Long> employeeIds = employeeList.stream().map(DataCollectionEmployee::getEmployeeId).collect(Collectors.toList());
|
2024-10-11 15:34:17 +08:00
|
|
|
|
salaryAcctEmployeeList = salaryAcctEmployeeList.stream().filter(acctEmp -> employeeIds.contains(acctEmp.getEmployeeId())).collect(Collectors.toList());
|
2024-03-25 16:08:34 +08:00
|
|
|
|
}
|
2025-03-18 17:45:00 +08:00
|
|
|
|
|
|
|
|
|
|
//人员浏览按钮筛选
|
|
|
|
|
|
List<Long> employeeIds = queryParam.getEmployeeIds();
|
|
|
|
|
|
if(CollectionUtils.isNotEmpty(employeeIds)){
|
|
|
|
|
|
salaryAcctEmployeeList = salaryAcctEmployeeList.stream().filter(acctEmp -> employeeIds.contains(acctEmp.getEmployeeId())).collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-25 16:08:34 +08:00
|
|
|
|
if (CollectionUtils.isEmpty(salaryAcctEmployeeList)) {
|
|
|
|
|
|
return new PageInfo<>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 分页
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(queryParam.getIds())) {
|
|
|
|
|
|
salaryAcctEmployeeList = salaryAcctEmployeeList.stream().filter(emp -> queryParam.getIds().contains(emp.getId())).collect(Collectors.toList());
|
|
|
|
|
|
}
|
2024-10-08 15:45:12 +08:00
|
|
|
|
salaryAcctEmployeeList = salaryAcctEmployeeList.stream().sorted(Comparator.comparing(SalaryAcctEmployeePO::getSalaryMonth).reversed()).collect(Collectors.toList());
|
2024-11-11 10:51:59 +08:00
|
|
|
|
PageInfo<SalaryAcctEmployeePO> salaryAcctEmployeePageInfo = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), salaryAcctEmployeeList);
|
2024-03-25 16:08:34 +08:00
|
|
|
|
if (queryParam.isExport()) {
|
2024-11-11 10:51:59 +08:00
|
|
|
|
salaryAcctEmployeePageInfo.setList(salaryAcctEmployeeList);
|
2024-03-25 16:08:34 +08:00
|
|
|
|
}
|
2024-11-11 10:51:59 +08:00
|
|
|
|
return salaryAcctEmployeePageInfo;
|
2024-03-25 16:08:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public SalaryStatisticsEmployeeDetailResultDTO getDetailSalaryAcctResultByAcctEmp(List<SalaryAcctEmployeePO> salaryAcctEmployeeList) {
|
|
|
|
|
|
// 3.获取薪资项目
|
2024-11-25 16:04:19 +08:00
|
|
|
|
List<SalaryItemPO> salaryItemList = getSalaryItemService(user).listAll();
|
|
|
|
|
|
salaryItemList = salaryItemList.stream()
|
|
|
|
|
|
.sorted(new Comparator<SalaryItemPO>() {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public int compare(SalaryItemPO o1, SalaryItemPO o2) {
|
|
|
|
|
|
if (o1.getSortedIndex() == null && o2.getSortedIndex() == null) {
|
|
|
|
|
|
Integer systemType1 = o1.getSystemType() == null ? 0 : o1.getSystemType();
|
|
|
|
|
|
Integer systemType2 = o2.getSystemType() == null ? 0 : o2.getSystemType();
|
|
|
|
|
|
return systemType1.compareTo(systemType2);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Integer sortedIndex1 = o1.getSortedIndex() == null ? 0 : o1.getSortedIndex();
|
|
|
|
|
|
Integer sortedIndex2 = o2.getSortedIndex() == null ? 0 : o2.getSortedIndex();
|
|
|
|
|
|
return sortedIndex2.compareTo(sortedIndex1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
.collect(Collectors.toList());
|
2024-03-25 16:08:34 +08:00
|
|
|
|
if (CollectionUtils.isEmpty(salaryAcctEmployeeList)) {
|
|
|
|
|
|
return SalaryStatisticsEmployeeDetailResultDTO.builder()
|
|
|
|
|
|
.salaryAcctEmployeeList(Collections.emptyList())
|
|
|
|
|
|
.salaryAcctResultValueList(Collections.emptyList())
|
2024-10-11 18:02:52 +08:00
|
|
|
|
.salaryItemList(salaryItemList)
|
2024-03-25 16:08:34 +08:00
|
|
|
|
.build();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取核算结果数据
|
|
|
|
|
|
List<Long> salaryAcctEmployeeIds = salaryAcctEmployeeList.stream().map(SalaryAcctEmployeePO::getId).collect(Collectors.toList());
|
|
|
|
|
|
List<SalaryAcctResultPO> salaryAcctResultValues = getSalaryAcctResultService(user).listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds);
|
|
|
|
|
|
|
|
|
|
|
|
return SalaryStatisticsEmployeeDetailResultDTO.builder()
|
|
|
|
|
|
.salaryAcctEmployeeList(salaryAcctEmployeeList)
|
|
|
|
|
|
.salaryAcctResultValueList(salaryAcctResultValues)
|
|
|
|
|
|
.salaryItemList(salaryItemList)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
}
|
2023-05-09 10:43:51 +08:00
|
|
|
|
}
|