weaver-hrm-salary/src/com/engine/salary/service/impl/SalaryComparisonResultServi...

245 lines
14 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//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.SalaryComparisonResultService;
//import com.google.common.collect.Sets;
//import com.weaver.common.component.table.column.WeaTableColumn;
//import com.weaver.common.component.table.page.Page;
//import com.weaver.common.hrm.service.HrmCommonEmployeeService;
//import com.weaver.excel.formula.api.entity.ExpressFormula;
//import com.weaver.hrm.salary.dao.ExcelAcctResultMapper;
//import com.weaver.hrm.salary.entity.salaryacct.bo.SalaryAcctResultBO;
//import com.weaver.hrm.salary.entity.salaryacct.dto.SalaryComparisonResultListDTO;
//import com.weaver.hrm.salary.entity.salaryacct.param.SalaryAcctEmployeeQueryParam;
//import com.weaver.hrm.salary.entity.salaryacct.param.SalaryComparisonResultQueryParam;
//import com.weaver.hrm.salary.entity.salaryacct.po.ExcelAcctResultPO;
//import com.weaver.hrm.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
//import com.weaver.hrm.salary.entity.salaryacct.po.SalaryAcctRecordPO;
//import com.weaver.hrm.salary.entity.salaryacct.po.SalaryAcctResultPO;
//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.bo.SalarySobItemAggregateBO;
//import com.weaver.hrm.salary.entity.salarysob.dto.SalarySobItemAggregateDTO;
//import com.weaver.hrm.salary.entity.salarysob.po.SalarySobEmpFieldPO;
//import com.weaver.hrm.salary.entity.salarysob.po.SalarySobItemGroupPO;
//import com.weaver.hrm.salary.entity.salarysob.po.SalarySobItemPO;
//import com.weaver.hrm.salary.entity.salarysob.po.SalarySobPO;
//import com.weaver.hrm.salary.exception.SalaryRunTimeException;
//import com.weaver.hrm.salary.service.*;
//import com.weaver.hrm.salary.util.SalaryEntityUtil;
//import com.weaver.hrm.salary.util.SalaryI18nUtil;
//import com.weaver.hrm.salary.util.SalaryPageUtil;
//import com.weaver.teams.domain.user.SimpleEmployee;
//import org.apache.commons.collections4.CollectionUtils;
//import org.apache.commons.lang3.BooleanUtils;
//import org.apache.commons.lang3.StringUtils;
//import org.apache.commons.lang3.math.NumberUtils;
//
//import java.util.*;
//import java.util.stream.Collectors;
//
///**
// * 薪资核算的线下对比结果
// * <p>Copyright: Copyright (c) 2022</p>
// * <p>Company: 泛微软件</p>
// *
// * @author qiantao
// * @version 1.0
// **/
//public class SalaryComparisonResultServiceImpl extends Service implements SalaryComparisonResultService {
//
//
// private ExcelAcctResultMapper excelAcctResultMapper;
//
// private SalaryAcctResultService salaryAcctResultService;
//
// private SalaryAcctEmployeeService salaryAcctEmployeeService;
//
// private SalarySobItemService salarySobItemService;
//
// private SalaryAcctRecordService salaryAcctRecordService;
//
// private SalarySobEmpFieldService salarySobEmpFieldService;
//
// private HrmCommonEmployeeService hrmCommonEmployeeService;
//
// private TaxAgentService taxAgentService;
//
// private SalaryFormulaService salaryFormulaService;
//
// private SalaryItemService salaryItemService;
//
// private SalarySobService salarySobService;
//
// private SalarySobItemGroupService salarySobItemGroupService;
//
// @Override
// public List<ExcelAcctResultPO> listBySalaryAcctRecordId(Long salaryAcctRecordId, String tenantKey) {
// return new LambdaQueryChainWrapper<>(excelAcctResultMapper)
// .eq(ExcelAcctResultPO::getTenantKey, tenantKey)
// .eq(ExcelAcctResultPO::getDeleteType, 0)
// .eq(ExcelAcctResultPO::getSalaryAcctRecordId, salaryAcctRecordId)
// .list();
// }
//
// @Override
// public List<ExcelAcctResultPO> listBySalaryAcctEmployeeIds(Collection<Long> salaryAcctEmployeeIds, String tenantKey) {
// if (CollectionUtils.isEmpty(salaryAcctEmployeeIds)) {
// return Collections.emptyList();
// }
// return new LambdaQueryChainWrapper<>(excelAcctResultMapper)
// .eq(ExcelAcctResultPO::getTenantKey, tenantKey)
// .eq(ExcelAcctResultPO::getDeleteType, 0)
// .in(ExcelAcctResultPO::getSalaryAcctEmpId, salaryAcctEmployeeIds)
// .list();
// }
//
// @Override
// public SalaryComparisonResultListDTO listPageByParam(SalaryComparisonResultQueryParam queryParam, String tenantKey) {
// return listByParam(true, queryParam, tenantKey);
// }
//
// @Override
// public SalaryComparisonResultListDTO listByParam(SalaryComparisonResultQueryParam queryParam, String tenantKey) {
// return listByParam(false, queryParam, tenantKey);
// }
//
// /**
// * 根据薪资核算人员查询薪资核算线下对比结果
// *
// * @param queryParam 列表查询条件
// * @param tenantKey 租户key
// * @return
// */
// private SalaryComparisonResultListDTO listByParam(boolean needPage, SalaryComparisonResultQueryParam queryParam, String tenantKey) {
// // 查询薪资核算记录
// SalaryAcctRecordPO salaryAcctRecordPO = salaryAcctRecordService.getById(queryParam.getSalaryAcctRecordId(), tenantKey);
// if (Objects.isNull(salaryAcctRecordPO)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
// }
// // 查询薪资核算所用薪资账套
// SalarySobPO salarySobPO = salarySobService.getById(salaryAcctRecordPO.getSalarySobId(), tenantKey);
// // 查询薪资核算所用的薪资账套的员工信息字段
// List<SalarySobEmpFieldPO> salarySobEmpFieldPOS = salarySobEmpFieldService.listBySalarySobId(salaryAcctRecordPO.getSalarySobId(), tenantKey);
// // 查询薪资账套的薪资项目分类
// List<SalarySobItemGroupPO> salarySobItemGroupPOS = salarySobItemGroupService.listBySalarySobId(salaryAcctRecordPO.getSalarySobId(), tenantKey);
// // 查询薪资核算所用薪资账套的薪资项目副本
// List<SalarySobItemPO> salarySobItemPOS = salarySobItemService.listBySalarySobId(salaryAcctRecordPO.getSalarySobId(), tenantKey);
// // 查询公式详情
// 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);
// });
// // 查询薪资项目
// Set<Long> salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId);
// List<SalaryItemPO> salaryItemPOS = salaryItemService.listByIds(salaryItemIds, tenantKey);
// // 转换成聚合dto
// SalarySobItemAggregateBO salarySobItemAggregateBO = new SalarySobItemAggregateBO(salarySobPO, salarySobEmpFieldPOS,
// salarySobItemGroupPOS, salarySobItemPOS, expressFormulas, salaryItemPOS);
// SalarySobItemAggregateDTO salarySobItemAggregateDTO = salarySobItemAggregateBO.convert2AggregateDTO();
//
// // 薪资核算人员
// List<SalaryAcctEmployeePO> salaryAcctEmployeePOS = salaryAcctEmployeeService.listByResultQueryParam(queryParam, tenantKey);
// if (CollectionUtils.isEmpty(salaryAcctEmployeePOS)) {
// // 构建薪资核算结果列表表头
// List<WeaTableColumn> weaTableColumns = SalaryAcctResultBO.buildTableColumns4ComparisonResult(salarySobItemAggregateDTO, Collections.emptySet());
// // 构建列表数据
// Page<Map<String, Object>> dtoPage = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize());
// dtoPage.setTotal(NumberUtils.INTEGER_ZERO);
// dtoPage.setRecords(Collections.emptyList());
// // 返回结果
// return new SalaryComparisonResultListDTO().setWeaTableColumns(weaTableColumns).setData(dtoPage);
// }
// // 薪资核算结果
// List<SalaryAcctResultPO> salaryAcctResultPOS;
// // 线下导入结果
// List<ExcelAcctResultPO> excelAcctResultPOS;
// // 如果薪资核算人员太多利用薪资核算人员id查询薪资核算结果的效率就不太好改为直接用薪资核算记录id查询
// if (salaryAcctEmployeePOS.size() > 1000) {
// // 查询薪资核算结果
// salaryAcctResultPOS = salaryAcctResultService.listBySalaryAcctRecordIds(Collections.singleton(queryParam.getSalaryAcctRecordId()), tenantKey);
// // 查询线下导入结果
// excelAcctResultPOS = listBySalaryAcctRecordId(queryParam.getSalaryAcctRecordId(), tenantKey);
// } else {
// // 薪资核算人员id
// Set<Long> salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getId);
// // 查询薪资核算结果
// salaryAcctResultPOS = salaryAcctResultService.listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds, tenantKey);
// // 查询线下导入结果
// excelAcctResultPOS = listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds, tenantKey);
// }
//
// // 查询个税扣缴义务人
// Set<Long> taxAgentIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getTaxAgentId);
// List<TaxAgentPO> taxAgentPOS = taxAgentService.listByIds(taxAgentIds, tenantKey);
// // 查询人员信息
// List<Long> employeeIds = SalaryEntityUtil.properties(salaryAcctEmployeePOS, SalaryAcctEmployeePO::getEmployeeId, Collectors.toList());
// List<SimpleEmployee> simpleEmployees = hrmCommonEmployeeService.getEmployeeByIds(employeeIds, tenantKey);
// // 判断是否存在合并计税
// Set<Long> salaryAcctEmployeeIds4ConsolidatedTax;
// if (StringUtils.isEmpty(queryParam.getConsolidatedTaxation())) {
// 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);
// }
// // 系统值和线下值不一致的薪资项目id
// Set<Long> includeSalaryItemIds = Sets.newHashSetWithExpectedSize(salaryItemPOS.size());
// // 转换成薪资核算线下对比结果
// List<Map<String, Object>> resultMapList = SalaryAcctResultBO.buildComparisonTableData(salaryItemPOS, salarySobEmpFieldPOS, simpleEmployees,
// salaryAcctEmployeePOS, salaryAcctResultPOS, excelAcctResultPOS, taxAgentPOS, customParameters, salaryAcctEmployeeIds4ConsolidatedTax, includeSalaryItemIds);
// // 系统值和线下值一致的人员
// if (queryParam.isOnlyDiffEmployee()) {
// // 过滤系统值和线下值一致的薪资核算人员
// resultMapList = resultMapList.stream()
// .filter(map -> BooleanUtils.toBoolean(String.valueOf(map.get("different"))))
// .collect(Collectors.toList());
// }
// // 分页
// Page<Map<String, Object>> dtoPage = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize());
// dtoPage.setTotal(resultMapList.size());
// if (needPage) {
// dtoPage.setRecords(SalaryPageUtil.subList((int) dtoPage.getCurrent(), (int) dtoPage.getSize(), resultMapList));
// } else {
// dtoPage.setRecords(resultMapList);
// }
// Set<Long> excludeSalaryItemIds = Sets.newHashSet();
// if (queryParam.isOnlyDiffSalaryItem()) {
// // 过滤系统值和线下值一致的薪资项目
// excludeSalaryItemIds = salaryItemPOS.stream()
// .filter(salaryItemPO -> !includeSalaryItemIds.contains(salaryItemPO.getId()))
// .map(SalaryItemPO::getId)
// .collect(Collectors.toSet());
// }
// // 构建薪资核算结果列表表头
// List<WeaTableColumn> weaTableColumns = SalaryAcctResultBO.buildTableColumns4ComparisonResult(salarySobItemAggregateDTO, excludeSalaryItemIds);
// // 返回结果
// return new SalaryComparisonResultListDTO().setWeaTableColumns(weaTableColumns).setData(dtoPage);
// }
//
// @Override
// public void batchSave(Collection<ExcelAcctResultPO> excelAcctResultPOS) {
// excelAcctResultMapper.batchInsert(excelAcctResultPOS);
// }
//
// @Override
// public void deleteBySalaryAcctEmployeeIds(Collection<Long> salaryAcctEmployeeIds, String tenantKey) {
// excelAcctResultMapper.deleteBySalaryAcctEmployeeIds(salaryAcctEmployeeIds, tenantKey);
// }
//
// @Override
// public void deleteBySalaryAcctRecordIds(Collection<Long> salaryAcctRecordIds, String tenantKey) {
// excelAcctResultMapper.deleteBySalaryAcctRecordIds(salaryAcctRecordIds, tenantKey);
// }
//}