2022-03-28 20:04:27 +08:00
|
|
|
|
package com.engine.salary.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import com.engine.core.impl.Service;
|
2022-03-29 17:10:59 +08:00
|
|
|
|
import com.engine.salary.biz.*;
|
2022-03-28 20:04:27 +08:00
|
|
|
|
import com.engine.salary.common.LocalDateRange;
|
|
|
|
|
|
import com.engine.salary.constant.SalaryDefaultTenantConstant;
|
|
|
|
|
|
import com.engine.salary.constant.SalaryItemConstant;
|
|
|
|
|
|
import com.engine.salary.entity.salaryarchive.bo.SalaryArchiveBO;
|
|
|
|
|
|
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveDataDTO;
|
|
|
|
|
|
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveListDTO;
|
|
|
|
|
|
import com.engine.salary.entity.salaryarchive.param.SalaryArchiveDimissionSaveParam;
|
|
|
|
|
|
import com.engine.salary.entity.salaryarchive.param.SalaryArchiveItemQueryParam;
|
|
|
|
|
|
import com.engine.salary.entity.salaryarchive.param.SalaryArchiveQueryParam;
|
|
|
|
|
|
import com.engine.salary.entity.salaryarchive.param.SalaryArchiveTaxAgentQueryParam;
|
|
|
|
|
|
import com.engine.salary.entity.salaryarchive.po.SalaryArchiveDimissionPO;
|
|
|
|
|
|
import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO;
|
|
|
|
|
|
import com.engine.salary.entity.salaryarchive.po.SalaryArchivePO;
|
|
|
|
|
|
import com.engine.salary.entity.salaryarchive.po.SalaryArchiveTaxAgentPO;
|
|
|
|
|
|
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
|
|
|
|
|
import com.engine.salary.entity.taxrate.TaxAgent;
|
|
|
|
|
|
import com.engine.salary.enums.SalaryUserStatusEnum;
|
|
|
|
|
|
import com.engine.salary.enums.salaryarchive.SalaryArchiveImportTypeEnum;
|
|
|
|
|
|
import com.engine.salary.service.SalaryArchiveService;
|
2022-03-29 17:10:59 +08:00
|
|
|
|
import com.engine.salary.util.SalaryI18nUtil;
|
|
|
|
|
|
import com.engine.salary.util.excel.ExcelComment;
|
|
|
|
|
|
import com.engine.salary.util.excel.ExcelUtil;
|
2022-03-28 20:04:27 +08:00
|
|
|
|
import com.engine.salary.util.page.PageInfo;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2022-03-29 17:10:59 +08:00
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
2022-03-28 20:04:27 +08:00
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 薪资档案
|
|
|
|
|
|
* <p>Copyright: Copyright (c) 2022</p>
|
|
|
|
|
|
* <p>Company: 泛微软件</p>
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author qiantao
|
|
|
|
|
|
* @version 1.0
|
|
|
|
|
|
**/
|
|
|
|
|
|
public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveService {
|
|
|
|
|
|
|
|
|
|
|
|
private SalaryArchiveBiz mapper = new SalaryArchiveBiz();
|
|
|
|
|
|
private SalaryArchiveItemBiz salaryArchiveItemMapper = new SalaryArchiveItemBiz();
|
|
|
|
|
|
private SalaryArchiveTaxAgentBiz salaryArchiveTaxAgentMapper = new SalaryArchiveTaxAgentBiz();
|
|
|
|
|
|
private SalaryArchiveDimissionBiz salaryArchiveDimissionMapper = new SalaryArchiveDimissionBiz();
|
2022-03-29 17:10:59 +08:00
|
|
|
|
private SalaryItemBiz salaryItemMapper = new SalaryItemBiz();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// private SalaryBatchService salaryBatchService;
|
|
|
|
|
|
private TaxAgentBiz taxAgentService = new TaxAgentBiz();
|
2022-03-28 20:04:27 +08:00
|
|
|
|
private ExecutorService taskExecutor;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public SalaryArchivePO getById(Long salaryArchiveId) {
|
|
|
|
|
|
return mapper.getById(salaryArchiveId);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public PageInfo<SalaryArchiveListDTO> listPage(SalaryArchiveQueryParam queryParam) {
|
|
|
|
|
|
return mapper.listPage(queryParam);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取薪资档案对应的当前生效的薪资项目
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param salaryArchivesIds
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalaryArchiveItemPO> getCurrentEffectiveItemList(Collection<Long> salaryArchivesIds, Collection<Long> salaryItemIds) {
|
|
|
|
|
|
// 没有薪资项目时,给个不存在的,否则加载所有不合理 fixme
|
|
|
|
|
|
salaryItemIds = CollectionUtils.isEmpty(salaryItemIds) ? Collections.singletonList(0L) : salaryItemIds;
|
|
|
|
|
|
List<SalaryArchiveItemPO> salaryArchiveItems = salaryArchiveItemMapper.getCurrentEffectiveItemList(SalaryArchiveItemQueryParam.builder().salaryArchivesIds(salaryArchivesIds).salaryItemIds(salaryItemIds).effectiveTime(new Date()).build());
|
|
|
|
|
|
return salaryArchiveItems.stream()
|
|
|
|
|
|
.collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getSalaryArchiveId() + "-" + f.getSalaryItemId()))), ArrayList::new));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取薪资档案对应的当前生效的个税扣缴义务人
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param salaryArchivesIds
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalaryArchiveTaxAgentPO> getCurrentEffectiveTaxAgentList(Collection<Long> salaryArchivesIds) {
|
|
|
|
|
|
|
|
|
|
|
|
List<SalaryArchiveTaxAgentPO> salaryArchiveTaxAgents = salaryArchiveTaxAgentMapper.listByParam(SalaryArchiveTaxAgentQueryParam.builder().salaryArchivesIds(salaryArchivesIds).effectiveTime(new Date()).build());
|
|
|
|
|
|
|
|
|
|
|
|
return salaryArchiveTaxAgents.stream()
|
|
|
|
|
|
.collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(SalaryArchiveTaxAgentPO::getSalaryArchiveId))), ArrayList::new));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 构建薪资档案数据
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param salaryArchives
|
|
|
|
|
|
* @param taxAgentLists
|
|
|
|
|
|
* @param salaryItems
|
|
|
|
|
|
* @param isPage
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<Map<String, Object>> buildSalaryArchiveData(Collection<SalaryArchiveListDTO> salaryArchives,
|
|
|
|
|
|
Collection<TaxAgent> taxAgentLists,
|
|
|
|
|
|
List<SalaryItemPO> salaryItems,
|
|
|
|
|
|
Boolean isPage) {
|
|
|
|
|
|
// 分页用于表格展示,否则用于导出
|
|
|
|
|
|
Collection<Long> ids = isPage ? salaryArchives.stream().map(SalaryArchiveListDTO::getId).collect(Collectors.toList()) : CollectionUtils.emptyCollection();
|
|
|
|
|
|
|
|
|
|
|
|
List<Long> salaryItemIds = salaryItems.stream().map(SalaryItemPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
// 1.获取薪资档案所对应的当前生效的薪资项目数据
|
|
|
|
|
|
List<SalaryArchiveItemPO> salaryArchiveItemList = getCurrentEffectiveItemList(ids, salaryItemIds);
|
|
|
|
|
|
List<Map<String, Object>> salaryArchiveItemData = salaryArchives.stream().map(m -> {
|
|
|
|
|
|
Map<String, Object> map = Maps.newHashMap();
|
|
|
|
|
|
map.put("salaryArchiveId", m.getId());
|
|
|
|
|
|
List<SalaryArchiveItemPO> salaryArchiveItemValuelList = salaryArchiveItemList.stream().filter(i -> i.getSalaryArchiveId().equals(m.getId())).collect(Collectors.toList());
|
|
|
|
|
|
salaryArchiveItemValuelList.forEach(i -> {
|
|
|
|
|
|
map.put(i.getSalaryItemId() + SalaryItemConstant.DYNAMIC_SUFFIX, i.getItemValue());
|
|
|
|
|
|
});
|
|
|
|
|
|
return map;
|
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
//2.获取薪资档案所对应的当前生效的个税扣缴义务人列表
|
|
|
|
|
|
List<SalaryArchiveTaxAgentPO> taxAgentList = getCurrentEffectiveTaxAgentList(ids);
|
|
|
|
|
|
List<Map<String, Object>> taxAgentData = taxAgentList.stream().map(m -> {
|
|
|
|
|
|
Map<String, Object> map = Maps.newHashMap();
|
|
|
|
|
|
map.put("salaryArchiveId", m.getSalaryArchiveId());
|
|
|
|
|
|
map.put("taxAgentId", m.getTaxAgentId());
|
|
|
|
|
|
Optional<TaxAgent> optional = taxAgentLists.stream().filter(f -> f.getId().equals(m.getTaxAgentId())).findFirst();
|
|
|
|
|
|
map.put("taxAgentName", optional.isPresent() ? optional.get().getName() : "");
|
|
|
|
|
|
map.put("taxAgentEffectiveTime", m.getEffectiveTime() + "");
|
|
|
|
|
|
return map;
|
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
// 3.组装数据
|
|
|
|
|
|
List<Map<String, Object>> listMaps = new ArrayList<>();
|
|
|
|
|
|
salaryArchives.forEach(e -> {
|
|
|
|
|
|
e.setEmployeeStatus(SalaryUserStatusEnum.getDefaultLabelByValue(e.getEmployeeStatus()));
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> map = new LinkedHashMap<>();
|
|
|
|
|
|
map.put("id", e.getId());
|
|
|
|
|
|
map.put("username", e.getUsername());
|
|
|
|
|
|
map.put("employeeId", e.getEmployeeId());
|
|
|
|
|
|
|
|
|
|
|
|
Optional<Map<String, Object>> optionalTaxAgent = taxAgentData.stream().filter(f -> f.get("salaryArchiveId").toString().equals(e.getId().toString())).findFirst();
|
|
|
|
|
|
map.put("taxAgentName", optionalTaxAgent.isPresent() ? optionalTaxAgent.get().get("taxAgentName").toString() : "");
|
|
|
|
|
|
map.put("taxAgentId", optionalTaxAgent.isPresent() ? optionalTaxAgent.get().get("taxAgentId").toString() : "");
|
|
|
|
|
|
map.put("taxAgentEffectiveTime", optionalTaxAgent.isPresent() ? optionalTaxAgent.get().get("taxAgentEffectiveTime").toString() : "");
|
|
|
|
|
|
|
|
|
|
|
|
map.put("departmentName", e.getDepartmentName());
|
|
|
|
|
|
map.put("mobile", e.getMobile());
|
|
|
|
|
|
map.put("employeeStatus", e.getEmployeeStatus());
|
|
|
|
|
|
|
|
|
|
|
|
// 薪资项目动态
|
|
|
|
|
|
Optional<Map<String, Object>> optionalItem = salaryArchiveItemData.stream().filter(f -> f.get("salaryArchiveId").toString().equals(e.getId().toString())).findFirst();
|
|
|
|
|
|
optionalItem.ifPresent(map::putAll);
|
|
|
|
|
|
|
|
|
|
|
|
listMaps.add(map);
|
|
|
|
|
|
});
|
|
|
|
|
|
return listMaps;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void exportList(Map<String, Object> map, String username, String eteamsId, SalaryArchiveQueryParam queryParam) {
|
|
|
|
|
|
// String nameI18n = SalaryI18nUtil.getI18nLabel(85368, "薪资档案");
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// List<ExcelSheetData> sheetList = new ArrayList<>();
|
|
|
|
|
|
//
|
|
|
|
|
|
// ExcelSheetData excelSheetData = new ExcelSheetData();
|
|
|
|
|
|
// // 1.工作簿名称
|
|
|
|
|
|
// excelSheetData.setSheetName(nameI18n);
|
|
|
|
|
|
// // 获取所有可被引用的薪资项目
|
2022-03-29 17:10:59 +08:00
|
|
|
|
// List<SalaryItemPO> salaryItems = salaryItemMapper.getCanAdjustSalaryItems(tenantKey);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// String[] header = {
|
2022-03-29 17:10:59 +08:00
|
|
|
|
// SalaryI18nUtil.getI18nLabel(85429, "姓名"),
|
|
|
|
|
|
// SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"),
|
|
|
|
|
|
// SalaryI18nUtil.getI18nLabel(86185, "部门"),
|
|
|
|
|
|
// SalaryI18nUtil.getI18nLabel(86186, "手机号"),
|
|
|
|
|
|
// SalaryI18nUtil.getI18nLabel(91075, "状态")
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// };
|
|
|
|
|
|
// List<String> headerList = new ArrayList<>(Arrays.asList(header));
|
|
|
|
|
|
// for (SalaryItemPO salaryItem : salaryItems) {
|
|
|
|
|
|
// headerList.add(salaryItem.getName());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 2.表头
|
|
|
|
|
|
// excelSheetData.setHeaders(Collections.singletonList(headerList.toArray(new String[]{})));
|
|
|
|
|
|
// // 获取所有个税扣缴义务人
|
|
|
|
|
|
// Collection<TaxAgentListDTO> taxAgentList = taxAgentService.findAll(tenantKey);
|
|
|
|
|
|
// Collection<SalaryArchiveListDTO> salaryArchives = mapper.list(queryParam, tenantKey);
|
|
|
|
|
|
// List<Map<String, Object>> listMaps = buildSalaryArchiveData(salaryArchives, taxAgentList, salaryItems, employeeId, tenantKey, Boolean.FALSE);
|
|
|
|
|
|
// // 组装数据
|
|
|
|
|
|
// List<List<Object>> rows = new ArrayList<>();
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// listMaps.forEach(e -> {
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// List<Object> row = new ArrayList<>();
|
|
|
|
|
|
// row.add(e.get("username").toString());
|
|
|
|
|
|
// row.add(e.get("taxAgentName").toString());
|
|
|
|
|
|
// row.add(e.get("departmentName").toString());
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// row.add(e.get("mobile") == null ? "" : e.get("mobile").toString());
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// row.add(e.get("employeeStatus").toString());
|
|
|
|
|
|
// // 薪资项目数据
|
|
|
|
|
|
// for (SalaryItemPO salaryItem : salaryItems) {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// row.add(e.containsKey(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX) ? (e.get(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX) == null ? "" : e.get(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX).toString()) : "");
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// }
|
|
|
|
|
|
// rows.add(row);
|
|
|
|
|
|
// });
|
|
|
|
|
|
// // 3.表数据
|
|
|
|
|
|
// excelSheetData.setRows(rows);
|
|
|
|
|
|
//
|
|
|
|
|
|
// sheetList.add(excelSheetData);
|
|
|
|
|
|
//
|
|
|
|
|
|
// salaryBatchService.simpleExportExcel(ExportExcelInfo.builder()
|
|
|
|
|
|
// .bizId(map.get("biz").toString())
|
|
|
|
|
|
// .flag(true)
|
|
|
|
|
|
// .userId(employeeId)
|
|
|
|
|
|
// .eteamsId(eteamsId)
|
|
|
|
|
|
// .tenantKey(tenantKey)
|
|
|
|
|
|
// .operator(username)
|
|
|
|
|
|
// .module(map.get("module").toString())
|
|
|
|
|
|
// .fileName(nameI18n + SalaryDateUtil.getFormatLocalDateTime(LocalDateTime.now()))
|
|
|
|
|
|
// .handlerName("exportSalaryArchive")
|
|
|
|
|
|
// .dataType(nameI18n)
|
|
|
|
|
|
// .function("exportSalaryArchive").build(), sheetList);
|
2022-03-28 20:04:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-03-29 17:10:59 +08:00
|
|
|
|
public XSSFWorkbook downloadTemplate(SalaryArchiveImportTypeEnum salaryArchiveImportTypeEnum, SalaryArchiveQueryParam queryParam) {
|
|
|
|
|
|
boolean isInit = salaryArchiveImportTypeEnum.getValue().equals(SalaryArchiveImportTypeEnum.INIT.getValue());
|
|
|
|
|
|
boolean isTaxAgentAdjust = salaryArchiveImportTypeEnum.getValue().equals(SalaryArchiveImportTypeEnum.TAXAGENTADJUST.getValue());
|
|
|
|
|
|
boolean isSalaryItemAdjust = salaryArchiveImportTypeEnum.getValue().equals(SalaryArchiveImportTypeEnum.SALARYITEMADJUST.getValue());
|
|
|
|
|
|
|
|
|
|
|
|
String nameI18n = SalaryI18nUtil.getI18nLabel(101601, "薪资档案导入模板");
|
|
|
|
|
|
// 初始化
|
|
|
|
|
|
if (isInit) {
|
|
|
|
|
|
nameI18n += "-" + SalaryI18nUtil.getI18nLabel(SalaryArchiveImportTypeEnum.INIT.getLabelId(), SalaryArchiveImportTypeEnum.INIT.getDefaultLabel());
|
|
|
|
|
|
// 调整个税扣缴义务人
|
|
|
|
|
|
} else if (isTaxAgentAdjust) {
|
|
|
|
|
|
nameI18n += "-" + SalaryI18nUtil.getI18nLabel(SalaryArchiveImportTypeEnum.TAXAGENTADJUST.getLabelId(), SalaryArchiveImportTypeEnum.TAXAGENTADJUST.getDefaultLabel());
|
|
|
|
|
|
// 调薪
|
|
|
|
|
|
} else if (isSalaryItemAdjust) {
|
|
|
|
|
|
nameI18n += "-" + SalaryI18nUtil.getI18nLabel(SalaryArchiveImportTypeEnum.SALARYITEMADJUST.getLabelId(), SalaryArchiveImportTypeEnum.SALARYITEMADJUST.getDefaultLabel());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 1.工作簿名称
|
|
|
|
|
|
String sheetName = nameI18n;
|
|
|
|
|
|
// 获取所有可被引用的薪资项目
|
|
|
|
|
|
List<SalaryItemPO> salaryItems = salaryItemMapper.getCanAdjustSalaryItems();
|
|
|
|
|
|
|
|
|
|
|
|
// 2.表头
|
|
|
|
|
|
List<Object> header = Lists.newArrayList();
|
|
|
|
|
|
header.add(SalaryI18nUtil.getI18nLabel(85429, "姓名"));
|
|
|
|
|
|
header.add(SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"));
|
|
|
|
|
|
header.add(SalaryI18nUtil.getI18nLabel(85904, "生效日期"));
|
|
|
|
|
|
if (isTaxAgentAdjust || isSalaryItemAdjust) {
|
|
|
|
|
|
header.add(SalaryI18nUtil.getI18nLabel(85431, "调整原因"));
|
|
|
|
|
|
}
|
|
|
|
|
|
header.add(SalaryI18nUtil.getI18nLabel(86185, "部门"));
|
|
|
|
|
|
header.add(SalaryI18nUtil.getI18nLabel(86186, "手机号"));
|
|
|
|
|
|
header.add(SalaryI18nUtil.getI18nLabel(91075, "状态"));
|
|
|
|
|
|
if (isInit || isSalaryItemAdjust) {
|
|
|
|
|
|
for (SalaryItemPO salaryItem : salaryItems) {
|
|
|
|
|
|
header.add(salaryItem.getName());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取所有个税扣缴义务人
|
|
|
|
|
|
Collection<TaxAgent> taxAgentList = taxAgentService.listAll();
|
|
|
|
|
|
Collection<SalaryArchiveListDTO> salaryArchives = mapper.list(queryParam);
|
|
|
|
|
|
List<Map<String, Object>> listMaps = buildSalaryArchiveData(salaryArchives, taxAgentList, salaryItems, Boolean.FALSE);
|
|
|
|
|
|
// 组装数据
|
|
|
|
|
|
List<List<Object>> rows = new ArrayList<>();
|
|
|
|
|
|
rows.add(header);
|
|
|
|
|
|
listMaps.forEach(e -> {
|
|
|
|
|
|
List<Object> row = new ArrayList<>();
|
|
|
|
|
|
row.add(e.get("username").toString());
|
|
|
|
|
|
row.add(e.get("taxAgentName").toString());
|
|
|
|
|
|
if (isTaxAgentAdjust || isSalaryItemAdjust) {
|
|
|
|
|
|
row.add(isTaxAgentAdjust ? e.get("taxAgentEffectiveTime").toString() : "");
|
|
|
|
|
|
}
|
|
|
|
|
|
row.add("");
|
|
|
|
|
|
row.add(e.get("departmentName").toString());
|
|
|
|
|
|
row.add(e.get("mobile") == null ? "" : e.get("mobile").toString());
|
|
|
|
|
|
row.add(e.get("employeeStatus").toString());
|
|
|
|
|
|
// 调薪
|
|
|
|
|
|
if (isInit || isSalaryItemAdjust) {
|
|
|
|
|
|
// 薪资项目数据
|
|
|
|
|
|
for (SalaryItemPO salaryItem : salaryItems) {
|
|
|
|
|
|
row.add(e.containsKey(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX) ? (e.get(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX) == null ? "" : e.get(salaryItem.getId() + SalaryItemConstant.DYNAMIC_SUFFIX).toString()) : "");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
rows.add(row);
|
|
|
|
|
|
});
|
|
|
|
|
|
// 3.表数据
|
|
|
|
|
|
// 4.注释
|
|
|
|
|
|
List<ExcelComment> excelComments = Lists.newArrayList();
|
|
|
|
|
|
excelComments.add(new ExcelComment(0, 0, 0, 0, SalaryI18nUtil.getI18nLabel(100344, "必填")));
|
|
|
|
|
|
if (isInit || isTaxAgentAdjust) {
|
|
|
|
|
|
excelComments.add(new ExcelComment(0, 0, 1, 1, SalaryI18nUtil.getI18nLabel(100344, "必填")));
|
|
|
|
|
|
}
|
|
|
|
|
|
excelComments.add(new ExcelComment(0, 0, 2, 2, SalaryI18nUtil.getI18nLabel(100458, "必填,格式样例为'2022-01-01'、'2022/1/1'")));
|
|
|
|
|
|
|
|
|
|
|
|
//调整个税扣缴义务人
|
|
|
|
|
|
if (isTaxAgentAdjust) {
|
|
|
|
|
|
excelComments.add(new ExcelComment(0, 0, 3, 3, SalaryI18nUtil.getI18nLabel(100952, "必填,可填写如:调动,变更,入职,离职,其他,初始化")));
|
|
|
|
|
|
// 调薪
|
|
|
|
|
|
} else if (isSalaryItemAdjust) {
|
|
|
|
|
|
excelComments.add(new ExcelComment( 0, 0, 3, 3, SalaryI18nUtil.getI18nLabel(100953, "必填,可填写如:入职,转正,调薪,调岗调薪,离职,其他,初始化")));
|
|
|
|
|
|
}
|
|
|
|
|
|
XSSFWorkbook book = ExcelUtil.genWorkbookV2(rows, sheetName,excelComments);
|
|
|
|
|
|
return book;
|
|
|
|
|
|
|
2022-03-28 20:04:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// @BatchExportHandler("exportSalaryArchive")
|
|
|
|
|
|
// public void exportSalaryArchiveHandler() {
|
|
|
|
|
|
// BatchCallbackMessage message = BatchExportContext.getBatchCallbackMessage();
|
|
|
|
|
|
// log.info("接受到薪资档案导出的结果:{}", JSONObject.toJSONString(message));
|
|
|
|
|
|
// }
|
2022-03-28 20:04:27 +08:00
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalaryArchiveDimissionPO> dimissionSets() {
|
|
|
|
|
|
return salaryArchiveDimissionMapper.dimissionSets();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public String saveDimissionSet(SalaryArchiveDimissionSaveParam saveParam) {
|
2022-03-29 17:10:59 +08:00
|
|
|
|
Date now = new Date();
|
2022-03-28 20:04:27 +08:00
|
|
|
|
List<SalaryArchiveDimissionPO> dimissionSets = dimissionSets();
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(dimissionSets)) {
|
|
|
|
|
|
SalaryArchiveDimissionPO po = dimissionSets.get(0);
|
|
|
|
|
|
po.setDimissionTimeInterval(saveParam.getDimissionTimeInterval().getValue());
|
2022-03-29 17:10:59 +08:00
|
|
|
|
po.setUpdateTime(now);
|
2022-03-28 20:04:27 +08:00
|
|
|
|
salaryArchiveDimissionMapper.updateById(po);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
salaryArchiveDimissionMapper.insert(SalaryArchiveDimissionPO
|
2022-03-29 17:10:59 +08:00
|
|
|
|
.builder()
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// .id(IdGenerator.generate())
|
2022-03-29 17:10:59 +08:00
|
|
|
|
.dimissionTimeInterval(saveParam.getDimissionTimeInterval().getValue())
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.build()
|
2022-03-28 20:04:27 +08:00
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
return StringUtils.EMPTY;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalaryArchiveDataDTO> getSalaryArchiveData(LocalDateRange localDateRange, Collection<Long> employeeIds) {
|
|
|
|
|
|
return getSalaryArchiveData(localDateRange, employeeIds, Boolean.FALSE);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalaryArchiveDataDTO> getSalaryArchiveTaxAgentData(LocalDateRange localDateRange, Collection<Long> employeeIds) {
|
|
|
|
|
|
return getSalaryArchiveData(localDateRange, employeeIds, Boolean.TRUE);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 根据日期范围和人员获取薪资档案数据
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param localDateRange
|
|
|
|
|
|
* @param employeeIds
|
|
|
|
|
|
* @param isOnlyTaxAgent
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
private List<SalaryArchiveDataDTO> getSalaryArchiveData(LocalDateRange localDateRange, Collection<Long> employeeIds, boolean isOnlyTaxAgent) {
|
|
|
|
|
|
// 获取个税扣缴义务人调整数据
|
|
|
|
|
|
List<SalaryArchiveTaxAgentPO> salaryArchiveTaxAgentList = salaryArchiveTaxAgentMapper.listByParam(SalaryArchiveTaxAgentQueryParam.builder().employeeIds(employeeIds).effectiveTime(localDateRange.getEndDate()).build());
|
|
|
|
|
|
List<Long> allEmployeeIds = salaryArchiveTaxAgentList.stream().map(SalaryArchiveTaxAgentPO::getEmployeeId).distinct().collect(Collectors.toList());
|
|
|
|
|
|
// 获取所有可被引用的薪资项目
|
2022-03-29 17:10:59 +08:00
|
|
|
|
List<SalaryItemPO> salaryItems = salaryItemMapper.getCanAdjustSalaryItems();
|
2022-03-28 20:04:27 +08:00
|
|
|
|
Collection<Long> salaryItemIds = salaryItems.stream().map(SalaryItemPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
// 获取薪资项目调整数据,isOnlyTaxAgent为true时不需要薪资项目数据
|
|
|
|
|
|
List<SalaryArchiveItemPO> salaryArchiveItemDataList;
|
2022-03-29 17:10:59 +08:00
|
|
|
|
if (isOnlyTaxAgent || CollectionUtils.isEmpty(salaryItemIds)) {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
salaryArchiveItemDataList = Lists.newArrayList();
|
2022-03-29 17:10:59 +08:00
|
|
|
|
} else {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
salaryArchiveItemDataList = salaryArchiveItemMapper.listByParam(SalaryArchiveItemQueryParam.builder().salaryItemIds(salaryItemIds).employeeIds(employeeIds).effectiveTime(new Date()).build());
|
|
|
|
|
|
}
|
|
|
|
|
|
return SalaryArchiveBO.buildSalaryArchiveData(salaryArchiveTaxAgentList,
|
|
|
|
|
|
salaryArchiveItemDataList,
|
|
|
|
|
|
localDateRange,
|
|
|
|
|
|
allEmployeeIds,
|
|
|
|
|
|
isOnlyTaxAgent);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 导入薪资档案
|
|
|
|
|
|
*/
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// @BatchImportHandler("importSalaryArchive")
|
|
|
|
|
|
// public void importSalaryArchive() {
|
|
|
|
|
|
// BatchDocumentMessage message = BatchImportContext.getBatchDocumentMessage();
|
|
|
|
|
|
// log.info("【薪资档案】接收到上传的数据:{}", JSONObject.toJSONString(message));
|
|
|
|
|
|
// // 租户key
|
|
|
|
|
|
// String tenantKey = message.getTenantKey().toLowerCase();
|
|
|
|
|
|
// try {
|
|
|
|
|
|
// // 加密用
|
|
|
|
|
|
// DSTenantKeyThreadVar.tenantKey.set(tenantKey);
|
|
|
|
|
|
// // 接收到解析的数据
|
|
|
|
|
|
// batchImportEbatch(message);
|
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
|
// log.error("【薪资档案】导入失败:{}", String.format("BatchTaskId=%s,错误信息=%s", message.getBatchTaskId(), e.getMessage()));
|
|
|
|
|
|
// } finally {
|
|
|
|
|
|
// // 加密用
|
|
|
|
|
|
// DSTenantKeyThreadVar.tenantKey.remove();
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
2022-03-28 20:04:27 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 导入的数据插入到数据库中
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param message
|
|
|
|
|
|
*/
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
|
// public void batchImportEbatch(BatchDocumentMessage message) {
|
|
|
|
|
|
// List<ExcelSheet> excelSheets = message.getBatchFile().getExcelSheets();
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 租户key
|
|
|
|
|
|
// String tenantKey = message.getTenantKey().toLowerCase();
|
|
|
|
|
|
// Long currentEmployeeId = message.getUserId();
|
|
|
|
|
|
// String paramsData = message.getUploadSet().getCustomData();
|
|
|
|
|
|
// Map<String, Object> params = JSONObject.parseObject(paramsData, Map.class);
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 1.自定义参数校验
|
|
|
|
|
|
// boolean isValid = checkParams(message, params);
|
|
|
|
|
|
// if (!isValid) {
|
|
|
|
|
|
// return;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 导入类型
|
|
|
|
|
|
// String importType = params.get("importType").toString();
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 2.构建导入需要的数据
|
|
|
|
|
|
// SalaryArchiveImportHandleParam importHandleParam = buildImportHandleParam(tenantKey);
|
|
|
|
|
|
//
|
|
|
|
|
|
// int total = 0;
|
|
|
|
|
|
// for (ExcelSheet excelSheet : excelSheets) {
|
|
|
|
|
|
// List<Map<String, Object>> data = excelSheet.getData();
|
|
|
|
|
|
// if (data != null) {
|
|
|
|
|
|
// total += data.size();
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// int index = 0;
|
|
|
|
|
|
// int successCount = 0;
|
|
|
|
|
|
// int errorCount = 0;
|
|
|
|
|
|
// // 错误excel内容
|
|
|
|
|
|
// List<ExcelSheet> errorExcelSheets = new ArrayList<>();
|
|
|
|
|
|
// // 用于(初始化导入)的相同employeeId时的处理
|
|
|
|
|
|
// boolean isInit = importType.equals(SalaryArchiveImportTypeEnum.INIT.getValue());
|
|
|
|
|
|
// List<SalaryArchiveInitImportDTO> initImportData = Lists.newArrayList();
|
|
|
|
|
|
// // 用于(调薪和调整个税扣缴义务人)的相同employeeId时取第一条记录,如果是初始化导入则有重复
|
|
|
|
|
|
// List<Long> allEmployeeIds = Lists.newArrayList();
|
|
|
|
|
|
// for (ExcelSheet excelSheet : excelSheets) {
|
|
|
|
|
|
// if (excelSheet.getHeader().size() == 0) {
|
|
|
|
|
|
// continue;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// List<Map> headers = excelSheet.getHeader();
|
|
|
|
|
|
// boolean isValidHeader = checkHeaders(importType, message, headers);
|
|
|
|
|
|
// if (!isValidHeader) {
|
|
|
|
|
|
// return;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// int effectiveTimeIndex = 0;
|
|
|
|
|
|
// for (int j = 0; j < headers.size(); j++) {
|
|
|
|
|
|
// Map header = headers.get(j);
|
|
|
|
|
|
// String key = Optional.ofNullable(header.get("key")).orElse("").toString();
|
|
|
|
|
|
// if (key.equals(SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 85904, "生效日期"))) {
|
|
|
|
|
|
// effectiveTimeIndex = j;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 错误sheet数据
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// List<Map<String, Object>> errorData = new ArrayList<>();
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// // 错误提示
|
|
|
|
|
|
// List<ExcelComment> excelComments = new ArrayList<>();
|
|
|
|
|
|
//
|
|
|
|
|
|
// List<Map<String, Object>> data = excelSheet.getData();
|
|
|
|
|
|
// Map<String, Object> map;
|
|
|
|
|
|
// if (data == null) {
|
|
|
|
|
|
// continue;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// for (int i = 0; i < data.size(); i++) {
|
|
|
|
|
|
// index += 1;
|
|
|
|
|
|
// map = data.get(i);
|
|
|
|
|
|
// // 3.校验行内容
|
|
|
|
|
|
// boolean isError = singleRowCheck(importType, allEmployeeIds, map, headers, effectiveTimeIndex, excelComments, errorCount, currentEmployeeId, tenantKey, importHandleParam);
|
|
|
|
|
|
//
|
|
|
|
|
|
// if (isError) {
|
|
|
|
|
|
// errorCount += 1;
|
|
|
|
|
|
// // 添加错误数据
|
|
|
|
|
|
// errorData.add(map);
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// successCount += 1;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 初始化导入对重复记录校验
|
|
|
|
|
|
// if (isInit) {
|
|
|
|
|
|
// Map<String, Object> validMap = validInitImportData(isError, i, map, excelComments, errorCount, successCount, errorData, initImportData, currentEmployeeId, tenantKey, importHandleParam);
|
|
|
|
|
|
// errorCount = Integer.parseInt(validMap.getOrDefault("errorCount", errorCount).toString());
|
|
|
|
|
|
// successCount = Integer.parseInt(validMap.getOrDefault("successCount", successCount).toString());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 导入进度
|
|
|
|
|
|
// salaryBatchService.sendImportRate(message.getBizId(), total, index);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 如果sheet包含错误数据
|
|
|
|
|
|
// if (CollectionUtils.isNotEmpty(errorData)) {
|
|
|
|
|
|
// salaryBatchService.createErrorExcelSheet(headers, errorData, excelSheet.getName(), excelComments, errorExcelSheets);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 4.数据入库处理
|
|
|
|
|
|
// handleImportData(isInit, tenantKey, importHandleParam);
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 发送导入回调信息
|
|
|
|
|
|
// salaryBatchService.sendImportCallBackInfo(message, successCount, errorCount, errorExcelSheets);
|
|
|
|
|
|
// }
|
2022-03-28 20:04:27 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 构建导入处理参数
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param tenantKey
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// private SalaryArchiveImportHandleParam buildImportHandleParam(String tenantKey) {
|
|
|
|
|
|
// // 获取所有可被引用的薪资项目
|
2022-03-29 17:10:59 +08:00
|
|
|
|
// List<SalaryItemPO> salaryItems = salaryItemMapper.getCanAdjustSalaryItems(tenantKey);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
//
|
|
|
|
|
|
// Collection<Long> salaryItemIds = salaryItems.stream().map(SalaryItemPO::getId).collect(Collectors.toList());
|
|
|
|
|
|
//
|
|
|
|
|
|
// return SalaryArchiveImportHandleParam.builder()
|
|
|
|
|
|
// // 获取租户下所有的人员
|
|
|
|
|
|
// .employees(mapper.listEmployee(tenantKey))
|
|
|
|
|
|
// // 获取所有个税扣缴义务人
|
|
|
|
|
|
// .taxAgentList(taxAgentService.findAll(tenantKey))
|
|
|
|
|
|
// .salaryItems(salaryItems)
|
|
|
|
|
|
// // 查询已有的薪资档案基本数据
|
|
|
|
|
|
// .salaryArchives(mapper.list(SalaryArchiveQueryParam.builder().build(), tenantKey))
|
|
|
|
|
|
// .salaryItemIds(salaryItemIds)
|
|
|
|
|
|
// // 查询已生效的薪资项目数据
|
|
|
|
|
|
// .effectiveItemList(getEffectiveItemList(salaryItemIds, tenantKey))
|
|
|
|
|
|
// // 查询未生效的薪资项目数据
|
|
|
|
|
|
// .ineffectiveItemList(getIneffectiveItemList(salaryItemIds, tenantKey))
|
|
|
|
|
|
// // 查询已生效的个税扣缴义务人数据
|
|
|
|
|
|
// .effectiveTaxAgentList(getEffectiveTaxAgentList(tenantKey))
|
|
|
|
|
|
// // 查询未生效的个税扣缴义务人数据
|
|
|
|
|
|
// .ineffectiveTaxAgentList(getIneffectiveTaxAgentList(tenantKey))
|
|
|
|
|
|
// // 当前时间
|
|
|
|
|
|
// .nowTime(LocalDateTime.now())
|
|
|
|
|
|
// // 当天
|
|
|
|
|
|
// .today(LocalDate.now())
|
|
|
|
|
|
// // 待保存薪资档案
|
|
|
|
|
|
// .salaryArchiveSaves(Lists.newArrayList())
|
|
|
|
|
|
// // 待保存薪资档案-个税扣缴义务人
|
|
|
|
|
|
// .salaryArchiveTaxAgentSaves(Lists.newArrayList())
|
|
|
|
|
|
// // 待保存薪资档案-薪资项目
|
|
|
|
|
|
// .salaryArchiveItemSaves(Lists.newArrayList())
|
|
|
|
|
|
// // 待删除薪资档案-个税扣缴义务人
|
|
|
|
|
|
// .salaryArchiveTaxAgentDelTaxAgentIds(Lists.newArrayList())
|
|
|
|
|
|
// // 待删除薪资档案-薪资项目
|
|
|
|
|
|
// .salaryArchiveItemDelSalaryItemIds(Lists.newArrayList())
|
|
|
|
|
|
// .build();
|
|
|
|
|
|
// }
|
2022-03-28 20:04:27 +08:00
|
|
|
|
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// /**
|
|
|
|
|
|
// * 初始化导入数据校验
|
|
|
|
|
|
// * 说明:如果一个人的多条记录中有一个错那么就全部弄到错误文档中
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// *
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// * @param isError
|
|
|
|
|
|
// * @param rowNo
|
|
|
|
|
|
// * @param map
|
|
|
|
|
|
// * @param excelComments
|
|
|
|
|
|
// * @param errorCount
|
|
|
|
|
|
// * @param successCount
|
|
|
|
|
|
// * @param errorData
|
|
|
|
|
|
// * @param initImportData
|
|
|
|
|
|
// * @param currentEmployeeId
|
|
|
|
|
|
// * @param tenantKey
|
|
|
|
|
|
// * @param importHandleParam
|
|
|
|
|
|
// */
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// private Map<String, Object> validInitImportData(boolean isError, int rowNo, Map<String, Object> map, List<ExcelComment> excelComments, int errorCount, int successCount, List<Map<String, Object>> errorData, List<SalaryArchiveInitImportDTO> initImportData, Long currentEmployeeId, String tenantKey, SalaryArchiveImportHandleParam importHandleParam) {
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// Long employeeId = Long.valueOf(Optional.ofNullable(map.get("employeeId")).orElse("0").toString());
|
|
|
|
|
|
// Optional<SalaryArchiveInitImportDTO> optionalInitImport = initImportData.stream().filter(f -> f.getEmployeeId().equals(employeeId)).findFirst();
|
|
|
|
|
|
//
|
|
|
|
|
|
// Map<String, Object> validMap = new HashMap<>();
|
|
|
|
|
|
// validMap.put("errorCount", errorCount);
|
|
|
|
|
|
// validMap.put("successCount", successCount);
|
|
|
|
|
|
//
|
|
|
|
|
|
// if (employeeId.equals(0L)) {
|
|
|
|
|
|
// return validMap;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// AtomicInteger finalErrorCount = new AtomicInteger(errorCount);
|
|
|
|
|
|
// AtomicInteger finalSuccessCount = new AtomicInteger(successCount);
|
|
|
|
|
|
// if (optionalInitImport.isPresent()) {
|
|
|
|
|
|
// SalaryArchiveInitImportDTO initImport = optionalInitImport.get();
|
|
|
|
|
|
// List<SalaryArchiveInitImportSameDTO> sames = initImport.getSames();
|
|
|
|
|
|
// sames.add(SalaryArchiveInitImportSameDTO.builder()
|
|
|
|
|
|
// .isError(isError)
|
|
|
|
|
|
// .rowNo(rowNo)
|
|
|
|
|
|
// .row(map)
|
|
|
|
|
|
// .build());
|
|
|
|
|
|
// Optional<SalaryArchiveInitImportSameDTO> optionalSame = sames.stream().filter(SalaryArchiveInitImportSameDTO::isError).findFirst();
|
|
|
|
|
|
// // 只要是其中一行有错误
|
|
|
|
|
|
// if (optionalSame.isPresent()) {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// sames.forEach(e -> {
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// if (!e.isError()) {
|
|
|
|
|
|
// e.setError(Boolean.TRUE);
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 101723, "该员工的薪资档案记录有误,请检查"), finalErrorCount.get() + 1, finalErrorCount.get() + 1, 0, 0);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// finalErrorCount.addAndGet(1);
|
|
|
|
|
|
// errorData.add(e.getRow());
|
|
|
|
|
|
// finalSuccessCount.addAndGet(-1);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// // 如果到目前为止都没错的话,则相互之间检验调整记录
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// } else {
|
|
|
|
|
|
// int nums = sames.size();
|
|
|
|
|
|
// // 1.生效时间不可重复
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// List<String> effectiveTimeList = sames.stream().map(m -> Optional.ofNullable(m.getRow().get("effectiveTime")).orElse("").toString()).distinct().collect(Collectors.toList());
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// // 2.个税扣缴义务人和薪资项目共同决定是否重复
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// List<String> rowSameList = sames.stream().map(m -> {
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// Map<String, Object> row = m.getRow();
|
|
|
|
|
|
// String taxAgent = Optional.ofNullable(row.get("taxAgent")).orElse("").toString();
|
|
|
|
|
|
// String salaryItem = Optional.ofNullable(row.get("salaryItemVal")).orElse("").toString();
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// return taxAgent + salaryItem;
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// }).distinct().collect(Collectors.toList());
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// if (effectiveTimeList.size() != nums || rowSameList.size() != nums) {
|
|
|
|
|
|
// sames.forEach(e -> {
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// if (!e.isError()) {
|
|
|
|
|
|
// e.setError(Boolean.TRUE);
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 101723, "该员工的薪资档案记录有误,请检查"), finalErrorCount.get() + 1, finalErrorCount.get() + 1, 0, 0);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// finalErrorCount.addAndGet(1);
|
|
|
|
|
|
// errorData.add(e.getRow());
|
|
|
|
|
|
// finalSuccessCount.addAndGet(-1);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// initImport.setSames(sames);
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// SalaryArchiveInitImportDTO initImport = new SalaryArchiveInitImportDTO();
|
|
|
|
|
|
// initImport.setEmployeeId(employeeId);
|
|
|
|
|
|
// List<SalaryArchiveInitImportSameDTO> sames = Lists.newArrayList();
|
|
|
|
|
|
// sames.add(SalaryArchiveInitImportSameDTO.builder()
|
|
|
|
|
|
// .isError(isError)
|
|
|
|
|
|
// .rowNo(rowNo)
|
|
|
|
|
|
// .row(map)
|
|
|
|
|
|
// .build());
|
|
|
|
|
|
// initImport.setSames(sames);
|
|
|
|
|
|
// initImportData.add(initImport);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 如果出现错误
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// if (isError || errorCount != finalErrorCount.get() || successCount != finalSuccessCount.get()) {
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// validMap.put("errorCount", finalErrorCount.get());
|
|
|
|
|
|
// validMap.put("successCount", finalSuccessCount.get());
|
|
|
|
|
|
// // 将前面添加好的数据给过滤掉
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// importHandleParam.setSalaryArchiveSaves(importHandleParam.getSalaryArchiveSaves().stream().filter(f -> !f.getEmployeeId().equals(employeeId)).collect(Collectors.toList()));
|
|
|
|
|
|
// importHandleParam.setSalaryArchiveTaxAgentSaves(importHandleParam.getSalaryArchiveTaxAgentSaves().stream().filter(f -> !f.getEmployeeId().equals(employeeId)).collect(Collectors.toList()));
|
|
|
|
|
|
// importHandleParam.setSalaryArchiveItemSaves(importHandleParam.getSalaryArchiveItemSaves().stream().filter(f -> !f.getEmployeeId().equals(employeeId)).collect(Collectors.toList()));
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// }
|
|
|
|
|
|
// return validMap;
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// /**
|
|
|
|
|
|
// * 校验单行数据
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// *
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// * @param importType
|
|
|
|
|
|
// * @param allEmployeeIds
|
|
|
|
|
|
// * @param map
|
|
|
|
|
|
// * @param headers
|
|
|
|
|
|
// * @param excelComments
|
|
|
|
|
|
// * @param errorCount
|
|
|
|
|
|
// * @param currentEmployeeId
|
|
|
|
|
|
// * @param tenantKey
|
|
|
|
|
|
// * @param importHandleParam
|
|
|
|
|
|
// * @return
|
|
|
|
|
|
// */
|
|
|
|
|
|
// private boolean singleRowCheck(String importType, List<Long> allEmployeeIds, Map<String, Object> map, List<Map> headers, int effectiveTimeIndex, List<ExcelComment> excelComments, int errorCount, Long currentEmployeeId, String tenantKey, SalaryArchiveImportHandleParam importHandleParam) {
|
|
|
|
|
|
// boolean isError = false;
|
|
|
|
|
|
//
|
|
|
|
|
|
// boolean isInit = importType.equals(SalaryArchiveImportTypeEnum.INIT.getValue());
|
|
|
|
|
|
// boolean isTaxAgentAdjust = importType.equals(SalaryArchiveImportTypeEnum.TAXAGENTADJUST.getValue());
|
|
|
|
|
|
// boolean isSalaryItemAdjust = importType.equals(SalaryArchiveImportTypeEnum.SALARYITEMADJUST.getValue());
|
|
|
|
|
|
//
|
|
|
|
|
|
// String userNameI18n = SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 85429, "姓名");
|
|
|
|
|
|
// String taxAgentI18n = SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 86184, "个税扣缴义务人");
|
|
|
|
|
|
// String effectiveTimeI18n = SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 85904, "生效日期");
|
|
|
|
|
|
// String adjustReasonI18n = SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 85431, "调整原因");
|
|
|
|
|
|
// // 1.姓名
|
|
|
|
|
|
// String userName = Optional.ofNullable(map.get(userNameI18n)).orElse("").toString();
|
|
|
|
|
|
// String deparmentName = Optional.ofNullable(map.get(SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 86185, "部门"))).orElse("").toString();
|
|
|
|
|
|
// List<Long> employeeSameIds = importHandleParam.getEmployees().stream().filter(e -> (StringUtils.isBlank(userName) || Objects.equals(e.getUsername(), userName))
|
|
|
|
|
|
// && (StringUtils.isBlank(deparmentName) || Objects.equals(e.getDeparmentName(), deparmentName))).map(SalaryArchiveEmployeePO::getEmployeeId)
|
|
|
|
|
|
// .collect(Collectors.toList());
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 && employeeSameIds.get(0) > 0 ? employeeSameIds.get(0) : null;
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// // 调薪和调整个税扣缴义务人的存在相同的取第一条
|
|
|
|
|
|
// if (employeeId != null && allEmployeeIds.contains(employeeId) && (isTaxAgentAdjust || isSalaryItemAdjust)) {
|
|
|
|
|
|
// return isError;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (employeeId != null) {
|
|
|
|
|
|
// allEmployeeIds.add(employeeId);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 用于初始化导入数据校验
|
|
|
|
|
|
// map.put("employeeId", employeeId);
|
|
|
|
|
|
// map.put("rowId", employeeId);
|
|
|
|
|
|
// // 2.生效日期
|
|
|
|
|
|
// String effectiveTimeCellVal = Optional.ofNullable(map.get(effectiveTimeI18n)).orElse("").toString().replaceAll(" 00:00:00", "");
|
|
|
|
|
|
// // 免得失败后,会追加 00:00:00
|
|
|
|
|
|
// map.put(effectiveTimeI18n, effectiveTimeCellVal);
|
|
|
|
|
|
// map.put("effectiveTime", effectiveTimeCellVal);
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// LocalDate effectiveTime = SalaryDateUtil.checkDay(effectiveTimeCellVal) ? dateStrToLocalDate(effectiveTimeCellVal) : null;
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// // 3.个税扣缴义务人
|
|
|
|
|
|
// String taxAgentCellVal = Optional.ofNullable(map.get(taxAgentI18n)).orElse("").toString();
|
|
|
|
|
|
// // 用于初始化导入的同一个人的记录校验
|
|
|
|
|
|
// map.put("taxAgent", taxAgentCellVal);
|
|
|
|
|
|
// Optional<TaxAgentListDTO> optionalTaxAgent = importHandleParam.getTaxAgentList().stream().filter(m -> m.getName().equals(taxAgentCellVal)).findFirst();
|
|
|
|
|
|
// Long taxAgentId = optionalTaxAgent.map(TaxAgentListDTO::getId).orElse(null);
|
|
|
|
|
|
// // 4.调整原因
|
|
|
|
|
|
// String adjustReason = "";
|
|
|
|
|
|
// if (isTaxAgentAdjust) {
|
|
|
|
|
|
// // 4.调整原因[个税扣缴义务人]
|
|
|
|
|
|
// adjustReason = SalaryArchiveTaxAgentAdjustReasonEnum.getValueByDefaultLabel(Optional.ofNullable(map.get(adjustReasonI18n)).orElse("").toString(), currentEmployeeId, tenantKey);
|
|
|
|
|
|
// } else if (isSalaryItemAdjust) {
|
|
|
|
|
|
// // 4.调整原因[薪资项目]
|
|
|
|
|
|
// adjustReason = SalaryArchiveItemAdjustReasonEnum.getValueByDefaultLabel(Optional.ofNullable(map.get(adjustReasonI18n)).orElse("").toString(), currentEmployeeId, tenantKey);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 构建薪资档案
|
|
|
|
|
|
//
|
2022-03-29 17:10:59 +08:00
|
|
|
|
// SalaryArchivePO finalSalaryArchive = buildSalaryArchive(isInit, currentEmployeeId, importHandleParam);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// for (int j = 0; j < headers.size(); j++) {
|
|
|
|
|
|
// Map header = headers.get(j);
|
|
|
|
|
|
// Object key = header.get("key");
|
|
|
|
|
|
// if (key == null) {
|
|
|
|
|
|
// continue;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// String cellVal = Optional.ofNullable(map.get(key.toString())).orElse("").toString();
|
|
|
|
|
|
//
|
|
|
|
|
|
// boolean isEmpty = StringUtils.isEmpty(cellVal) &&
|
|
|
|
|
|
// (userNameI18n.equals(key.toString())
|
|
|
|
|
|
// // 个税扣缴义务人列判空(初始化导入或调整个税扣缴义务人)
|
|
|
|
|
|
// || (taxAgentI18n.equals(key.toString()) && (isInit || isTaxAgentAdjust))
|
|
|
|
|
|
// || effectiveTimeI18n.equals(key.toString())
|
|
|
|
|
|
// // 调整原因列判空(调薪或调整个税扣缴义务人)
|
|
|
|
|
|
// || (adjustReasonI18n.equals(key.toString()) && (isTaxAgentAdjust || isSalaryItemAdjust)));
|
|
|
|
|
|
// // 判空
|
|
|
|
|
|
// if (isEmpty) {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 100577, "不能为空"), errorCount + 1, errorCount + 1, j, j);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// isError = true;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 1.姓名列处理
|
|
|
|
|
|
// if (!isEmpty && userNameI18n.equals(key.toString())) {
|
|
|
|
|
|
// if (CollectionUtils.isEmpty(employeeSameIds) || employeeSameIds.size() > 1) {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 100578, "员工信息不能为空且不可重复(姓名与部门同时确认唯一)"), errorCount + 1, errorCount + 1, j, j);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// isError = true;
|
|
|
|
|
|
// } else if (employeeId == null) {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 100579, "姓名错误,系统内不存在该姓名"), errorCount + 1, errorCount + 1, j, j);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// isError = true;
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// // (调薪或调整个税扣缴义务人)
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// } else if (finalSalaryArchive == null && (isTaxAgentAdjust || isSalaryItemAdjust)) {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 101653, "该人员的薪资档案不存在,请先初始化"), errorCount + 1, errorCount + 1, j, j);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// isError = true;
|
|
|
|
|
|
// }
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// // 2.个税扣缴义务人列处理(初始化导入或调整个税扣缴义务人)
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// } else if (!isEmpty && taxAgentI18n.equals(key.toString()) && (isInit || isTaxAgentAdjust)) {
|
|
|
|
|
|
// isError = handleTaxAgent(isError, isInit, effectiveTimeIndex, excelComments, errorCount, j, currentEmployeeId, tenantKey,
|
|
|
|
|
|
// taxAgentId, effectiveTime, finalSalaryArchive, adjustReason, importHandleParam);
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// // 3.生效时间处理
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// } else if (!isEmpty && effectiveTimeI18n.equals(key.toString()) && effectiveTime == null) {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 102497, "生效日期错误或格式不正确,正确格式示例为'2022-01-01'、'2022/1/1'"), errorCount + 1, errorCount + 1, j, j);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// isError = true;
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// // 4.调整原因列处理(调薪或调整个税扣缴义务人)
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// } else if (!isEmpty && adjustReasonI18n.equals(key.toString()) && (isTaxAgentAdjust || isSalaryItemAdjust) && StringUtils.isEmpty(adjustReason)) {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 100591, "调整原因不存在"), errorCount + 1, errorCount + 1, j, j);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// isError = true;
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// // 5.薪资项目列处理(初始化导入或调薪)
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// } else {
|
|
|
|
|
|
// // 薪资项目数据
|
|
|
|
|
|
// if (effectiveTime == null || finalSalaryArchive == null || !(isInit || isSalaryItemAdjust)) {
|
|
|
|
|
|
// continue;
|
|
|
|
|
|
// }
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// isError = handleSalaryItem(isError, isInit, effectiveTimeIndex, excelComments, errorCount, j, currentEmployeeId, tenantKey,
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// effectiveTime, finalSalaryArchive, adjustReason, importHandleParam, key.toString(), cellVal, map);
|
|
|
|
|
|
//
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// return isError;
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// private SalaryArchivePO buildSalaryArchive(boolean isInit, Long currentEmployeeId, String tenantKey, Long employeeId, SalaryArchiveImportHandleParam importHandleParam) {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// Optional<SalaryArchiveListDTO> optionalSA = importHandleParam.getSalaryArchives().stream().filter(p -> p.getEmployeeId().toString().equals(employeeId != null ? employeeId.toString() : "")).findFirst();
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// SalaryArchivePO salaryArchive = null;
|
|
|
|
|
|
// if (optionalSA.isPresent()) {
|
|
|
|
|
|
// // 修改档案
|
|
|
|
|
|
// SalaryArchiveListDTO sa = optionalSA.get();
|
|
|
|
|
|
// salaryArchive = new SalaryArchivePO();
|
|
|
|
|
|
// salaryArchive.setId(sa.getId());
|
|
|
|
|
|
// salaryArchive.setEmployeeId(sa.getEmployeeId());
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// } else if (employeeId != null && isInit) {
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// // 新增档案
|
|
|
|
|
|
// salaryArchive = SalaryArchivePO.builder()
|
|
|
|
|
|
// .id(IdGenerator.generate())
|
|
|
|
|
|
// .employeeId(employeeId)
|
|
|
|
|
|
// .createTime(importHandleParam.getNowTime())
|
|
|
|
|
|
// .updateTime(importHandleParam.getNowTime())
|
|
|
|
|
|
// .creator(currentEmployeeId)
|
|
|
|
|
|
// .tenantKey(tenantKey)
|
|
|
|
|
|
// .build();
|
|
|
|
|
|
// importHandleParam.getSalaryArchiveSaves().add(salaryArchive);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// return salaryArchive;
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// /**
|
|
|
|
|
|
// * 个税扣缴义务人处理
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// *
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// * @param isError
|
|
|
|
|
|
// * @param excelComments
|
|
|
|
|
|
// * @param errorCount
|
|
|
|
|
|
// * @param j
|
|
|
|
|
|
// * @param currentEmployeeId
|
|
|
|
|
|
// * @param tenantKey
|
|
|
|
|
|
// * @param taxAgentId
|
|
|
|
|
|
// * @param effectiveTime
|
|
|
|
|
|
// * @param finalSalaryArchive
|
|
|
|
|
|
// * @param taxAgentAdjustReason
|
|
|
|
|
|
// * @param importHandleParam
|
|
|
|
|
|
// * @return
|
|
|
|
|
|
// */
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// private boolean handleTaxAgent(boolean isError, boolean isInit, int effectiveTimeIndex,
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// List<ExcelComment> excelComments, int errorCount, int j, Long currentEmployeeId, String tenantKey,
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// Long taxAgentId, LocalDate effectiveTime, SalaryArchivePO finalSalaryArchive, String taxAgentAdjustReason, SalaryArchiveImportHandleParam importHandleParam) {
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// if (taxAgentId == null) {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 100545, "个税扣缴义务人不存在"), errorCount + 1, errorCount + 1, j, j);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// isError = true;
|
|
|
|
|
|
// } else if (effectiveTime != null && finalSalaryArchive != null) {
|
|
|
|
|
|
// boolean isBeforeError = false;
|
|
|
|
|
|
// if (!isInit) {
|
|
|
|
|
|
// // 前后调整校验
|
|
|
|
|
|
// // 已生效
|
|
|
|
|
|
// List<SalaryArchiveTaxAgentPO> effectiveList = importHandleParam.getEffectiveTaxAgentList().stream().filter(i -> finalSalaryArchive.getId().equals(i.getSalaryArchiveId())).collect(Collectors.toList());
|
|
|
|
|
|
// // 当前已生效
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// SalaryArchiveTaxAgentPO effectiveTaxAgent = CollectionUtils.isNotEmpty(effectiveList) && effectiveList.size() > 0 ? effectiveList.get(0) : null;
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// // 当前已生效的前一次调整
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// SalaryArchiveTaxAgentPO effectiveBeforeTaxAgent = CollectionUtils.isNotEmpty(effectiveList) && effectiveList.size() > 1 ? effectiveList.get(1) : null;
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// // 未生效
|
|
|
|
|
|
// Optional<SalaryArchiveTaxAgentPO> optionalIneffective = importHandleParam.getIneffectiveTaxAgentList().stream().filter(i -> finalSalaryArchive.getId().equals(i.getSalaryArchiveId())).findFirst();
|
|
|
|
|
|
// SalaryArchiveTaxAgentPO ineffectiveTaxAgent = optionalIneffective.orElse(null);
|
|
|
|
|
|
// // 1.检验是否可以调整
|
|
|
|
|
|
// if (effectiveTaxAgent != null) {
|
|
|
|
|
|
// // 当前已经生效的时间
|
|
|
|
|
|
// LocalDate currentEffectiveTime = effectiveTaxAgent.getEffectiveTime();
|
|
|
|
|
|
// // 1.1 如果早于<当前已生效
|
|
|
|
|
|
// if (effectiveTime.isBefore(currentEffectiveTime)) {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 100429, "生效日期不可早于当前已生效的调整日期"), errorCount + 1, errorCount + 1, effectiveTimeIndex, effectiveTimeIndex);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// isError = true;
|
|
|
|
|
|
// isBeforeError = true;
|
|
|
|
|
|
// // 1.2 如果等于当前已生效
|
|
|
|
|
|
// } else if (effectiveTime.isEqual(currentEffectiveTime)) {
|
|
|
|
|
|
// if (effectiveBeforeTaxAgent != null && effectiveBeforeTaxAgent.getTaxAgentId().equals(taxAgentId)) {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 100432, "调整前后不可相同"), errorCount + 1, errorCount + 1, j, j);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// isError = true;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (ineffectiveTaxAgent != null && ineffectiveTaxAgent.getTaxAgentId().equals(taxAgentId)) {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 100434, "与未生效的调整后不可相同"), errorCount + 1, errorCount + 1, j, j);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// isError = true;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 1.3 如果>已经生效且<=今天
|
|
|
|
|
|
// } else if (effectiveTime.isAfter(currentEffectiveTime) && !effectiveTime.isAfter(importHandleParam.getToday())) {
|
|
|
|
|
|
// if (effectiveTaxAgent.getTaxAgentId().equals(taxAgentId)) {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 100432, "调整前后不可相同"), errorCount + 1, errorCount + 1, j, j);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// isError = true;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (ineffectiveTaxAgent != null && ineffectiveTaxAgent.getTaxAgentId().equals(taxAgentId)) {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 100434, "与未生效的调整后不可相同"), errorCount + 1, errorCount + 1, j, j);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// isError = true;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 1.4 如果>今天
|
|
|
|
|
|
// } else if (effectiveTime.isAfter(importHandleParam.getToday()) && effectiveTaxAgent.getTaxAgentId().equals(taxAgentId)) {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 100432, "调整前后不可相同"), errorCount + 1, errorCount + 1, j, j);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// isError = true;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// } else if (ineffectiveTaxAgent != null && ineffectiveTaxAgent.getTaxAgentId().equals(taxAgentId)) {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 100434, "与未生效的调整后不可相同"), errorCount + 1, errorCount + 1, j, j);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// isError = true;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 2.数据处理,有的就先删后增
|
|
|
|
|
|
// if (effectiveTaxAgent != null && effectiveTime.isEqual(effectiveTaxAgent.getEffectiveTime())) {
|
|
|
|
|
|
// importHandleParam.getSalaryArchiveTaxAgentDelTaxAgentIds().add(effectiveTaxAgent.getId());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (ineffectiveTaxAgent != null && effectiveTime.isAfter(importHandleParam.getToday())) {
|
|
|
|
|
|
// importHandleParam.getSalaryArchiveTaxAgentDelTaxAgentIds().add(ineffectiveTaxAgent.getId());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (!isBeforeError) {
|
|
|
|
|
|
// importHandleParam.getSalaryArchiveTaxAgentSaves().add(SalaryArchiveTaxAgentPO.builder()
|
|
|
|
|
|
// .id(IdGenerator.generate())
|
|
|
|
|
|
// .salaryArchiveId(finalSalaryArchive.getId())
|
|
|
|
|
|
// .employeeId(finalSalaryArchive.getEmployeeId())
|
|
|
|
|
|
// .taxAgentId(taxAgentId)
|
|
|
|
|
|
// .effectiveTime(effectiveTime)
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// .adjustReason(StringUtils.isEmpty(taxAgentAdjustReason) ? SalaryArchiveTaxAgentAdjustReasonEnum.INIT.getValue() : taxAgentAdjustReason)
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// .operator(currentEmployeeId)
|
|
|
|
|
|
// .operateTime(importHandleParam.getNowTime())
|
|
|
|
|
|
// .createTime(importHandleParam.getNowTime())
|
|
|
|
|
|
// .updateTime(importHandleParam.getNowTime())
|
|
|
|
|
|
// .creator(currentEmployeeId)
|
|
|
|
|
|
// .tenantKey(tenantKey)
|
|
|
|
|
|
// .build());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// return isError;
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// /**
|
|
|
|
|
|
// * 薪资项目处理
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// *
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// * @param isError
|
|
|
|
|
|
// * @param excelComments
|
|
|
|
|
|
// * @param errorCount
|
|
|
|
|
|
// * @param j
|
|
|
|
|
|
// * @param currentEmployeeId
|
|
|
|
|
|
// * @param tenantKey
|
|
|
|
|
|
// * @param effectiveTime
|
|
|
|
|
|
// * @param finalSalaryArchive
|
|
|
|
|
|
// * @param salaryItemAdjustReason
|
|
|
|
|
|
// * @param importHandleParam
|
|
|
|
|
|
// * @param cellVal
|
|
|
|
|
|
// * @return
|
|
|
|
|
|
// */
|
|
|
|
|
|
// private boolean handleSalaryItem(boolean isError, boolean isInit, int effectiveTimeIndex,
|
|
|
|
|
|
// List<ExcelComment> excelComments, int errorCount, int j, Long currentEmployeeId, String tenantKey,
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// LocalDate effectiveTime, SalaryArchivePO finalSalaryArchive, String salaryItemAdjustReason, SalaryArchiveImportHandleParam importHandleParam,
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// String key, String cellVal, Map<String, Object> map) {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// Optional<SalaryItemPO> optionalSalaryItem = importHandleParam.getSalaryItems().stream().filter(e -> e.getName().equals(key)).findFirst();
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// if (optionalSalaryItem.isPresent()) {
|
|
|
|
|
|
// Long salaryItemId = optionalSalaryItem.get().getId();
|
|
|
|
|
|
// boolean isBeforeError = false;
|
|
|
|
|
|
// if (!isInit) {
|
|
|
|
|
|
// // 已生效
|
|
|
|
|
|
// List<SalaryArchiveItemPO> effectiveList = importHandleParam.getEffectiveItemList().stream().filter(i -> finalSalaryArchive.getId().equals(i.getSalaryArchiveId()) && i.getSalaryItemId().equals(salaryItemId)).collect(Collectors.toList());
|
|
|
|
|
|
// // 当前已生效
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// SalaryArchiveItemPO effectiveSalaryItem = CollectionUtils.isNotEmpty(effectiveList) && effectiveList.size() > 0 ? effectiveList.get(0) : null;
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// // 当前已生效的前一次调整
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// SalaryArchiveItemPO effectiveBeforeSalaryItem = CollectionUtils.isNotEmpty(effectiveList) && effectiveList.size() > 1 ? effectiveList.get(1) : null;
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// // 未生效
|
|
|
|
|
|
// Optional<SalaryArchiveItemPO> optionalIneffective = importHandleParam.getIneffectiveItemList().stream().filter(i -> finalSalaryArchive.getId().equals(i.getSalaryArchiveId()) && i.getSalaryItemId().equals(salaryItemId)).findFirst();
|
|
|
|
|
|
// SalaryArchiveItemPO ineffectiveSalaryItem = optionalIneffective.orElse(null);
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 1.检验是否可以调整
|
|
|
|
|
|
// if (effectiveSalaryItem != null) {
|
|
|
|
|
|
// // 当前已经生效的时间
|
|
|
|
|
|
// LocalDate currentEffectiveTime = effectiveSalaryItem.getEffectiveTime();
|
|
|
|
|
|
// // 1.1 如果早于<当前已生效
|
|
|
|
|
|
// if (effectiveTime.isBefore(currentEffectiveTime)) {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 100429, "生效日期不可早于当前已生效的调整日期"), errorCount + 1, errorCount + 1, effectiveTimeIndex, effectiveTimeIndex);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// isError = true;
|
|
|
|
|
|
// isBeforeError = true;
|
|
|
|
|
|
// // 1.2 如果等于当前已生效
|
|
|
|
|
|
// } else if (effectiveTime.isEqual(currentEffectiveTime)) {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// if (effectiveBeforeSalaryItem != null && effectiveBeforeSalaryItem.getItemValue().equals(cellVal)) {
|
|
|
|
|
|
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 100432, "调整前后不可相同"), errorCount + 1, errorCount + 1, j, j);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// isError = true;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (ineffectiveSalaryItem != null && ineffectiveSalaryItem.getItemValue().equals(cellVal)) {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 100434, "与未生效的调整后不可相同"), errorCount + 1, errorCount + 1, j, j);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// isError = true;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 1.3 如果>已经生效且<=今天
|
|
|
|
|
|
// } else if (effectiveTime.isAfter(currentEffectiveTime) && !effectiveTime.isAfter(importHandleParam.getToday())) {
|
|
|
|
|
|
// if (effectiveSalaryItem.getItemValue().equals(cellVal)) {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 100432, "调整前后不可相同"), errorCount + 1, errorCount + 1, j, j);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// isError = true;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (ineffectiveSalaryItem != null && ineffectiveSalaryItem.getItemValue().equals(cellVal)) {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 100434, "与未生效的调整后不可相同"), errorCount + 1, errorCount + 1, j, j);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// isError = true;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 1.4 如果>今天
|
|
|
|
|
|
// } else if (effectiveTime.isAfter(importHandleParam.getToday()) && effectiveSalaryItem.getItemValue().equals(cellVal)) {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 100432, "调整前后不可相同"), errorCount + 1, errorCount + 1, j, j);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// isError = true;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// } else if (ineffectiveSalaryItem != null && ineffectiveSalaryItem.getItemValue().equals(cellVal)) {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 100434, "与未生效的调整后不可相同"), errorCount + 1, errorCount + 1, j, j);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// isError = true;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 2.数据处理
|
|
|
|
|
|
// if (effectiveSalaryItem != null && effectiveTime.isEqual(effectiveSalaryItem.getEffectiveTime())) {
|
|
|
|
|
|
// importHandleParam.getSalaryArchiveItemDelSalaryItemIds().add(effectiveSalaryItem.getId());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (ineffectiveSalaryItem != null && effectiveTime.isAfter(importHandleParam.getToday())) {
|
|
|
|
|
|
// importHandleParam.getSalaryArchiveItemDelSalaryItemIds().add(ineffectiveSalaryItem.getId());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (!isBeforeError) {
|
|
|
|
|
|
// importHandleParam.getSalaryArchiveItemSaves().add(SalaryArchiveItemPO.builder()
|
|
|
|
|
|
// .id(IdGenerator.generate())
|
|
|
|
|
|
// .salaryArchiveId(finalSalaryArchive.getId())
|
|
|
|
|
|
// .employeeId(finalSalaryArchive.getEmployeeId())
|
|
|
|
|
|
// .effectiveTime(effectiveTime)
|
|
|
|
|
|
// .adjustReason(StringUtils.isEmpty(salaryItemAdjustReason) ? SalaryArchiveItemAdjustReasonEnum.INIT.getValue() : salaryItemAdjustReason)
|
|
|
|
|
|
// .salaryItemId(salaryItemId)
|
|
|
|
|
|
// .itemValue(cellVal)
|
|
|
|
|
|
// .description("")
|
|
|
|
|
|
// .operator(currentEmployeeId)
|
|
|
|
|
|
// .operateTime(importHandleParam.getNowTime())
|
|
|
|
|
|
// .createTime(importHandleParam.getNowTime())
|
|
|
|
|
|
// .updateTime(importHandleParam.getNowTime())
|
|
|
|
|
|
// .creator(currentEmployeeId)
|
|
|
|
|
|
// .tenantKey(tenantKey)
|
|
|
|
|
|
// .build());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 用于初始化导入,同一个人的多行记录之间的薪资项目是否调整
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// map.put("salaryItemVal", Optional.ofNullable(map.get("salaryItemVal")).orElse("").toString() + salaryItemId + cellVal);
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// }
|
|
|
|
|
|
// return isError;
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// /**
|
|
|
|
|
|
// * 字符串转日期
|
|
|
|
|
|
// * 兼容/和-
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// *
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// * @param effectiveTime
|
|
|
|
|
|
// * @return
|
|
|
|
|
|
// */
|
|
|
|
|
|
// private LocalDate dateStrToLocalDate(String effectiveTime) {
|
|
|
|
|
|
// LocalDate localDate = null;
|
|
|
|
|
|
// try {
|
|
|
|
|
|
// if (effectiveTime.contains("/")) {
|
|
|
|
|
|
// String[] strs = effectiveTime.split("/");
|
|
|
|
|
|
// localDate = LocalDate.of(Integer.parseInt(strs[0]), Integer.parseInt(strs[1]), Integer.parseInt(strs[2]));
|
|
|
|
|
|
// } else if (effectiveTime.contains("-")) {
|
|
|
|
|
|
// String[] strs = effectiveTime.replaceAll("-0", "-").split("-");
|
|
|
|
|
|
// // localDate = LocalDate.parse(effectiveTime, DateTimeFormatter.ofPattern("yyyy-MM-dd")); // 月份日期超过最大会被改为最大
|
|
|
|
|
|
// localDate = LocalDate.of(Integer.parseInt(strs[0]), Integer.parseInt(strs[1]), Integer.parseInt(strs[2]));
|
|
|
|
|
|
// }
|
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
|
// localDate = null;
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// return localDate;
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// private List<SalaryArchiveItemPO> getEffectiveItemList(Collection<Long> salaryItemIds, String tenantKey) {
|
|
|
|
|
|
// // 没有薪资项目时,给个不存在的,否则加载所有不合理
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// salaryItemIds = CollectionUtils.isEmpty(salaryItemIds) ? Collections.singletonList(0L) : salaryItemIds;
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// return new LambdaQueryChainWrapper<>(salaryArchiveItemMapper)
|
|
|
|
|
|
// .eq(SalaryArchiveItemPO::getDeleteType, 0)
|
|
|
|
|
|
// .eq(SalaryArchiveItemPO::getTenantKey, tenantKey)
|
|
|
|
|
|
// .le(SalaryArchiveItemPO::getEffectiveTime, LocalDate.now())
|
|
|
|
|
|
// .in(SalaryArchiveItemPO::getSalaryItemId, salaryItemIds)
|
|
|
|
|
|
// .orderByDesc(SalaryArchiveItemPO::getEffectiveTime)
|
|
|
|
|
|
// .list();
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// private List<SalaryArchiveItemPO> getIneffectiveItemList(Collection<Long> salaryItemIds, String tenantKey) {
|
|
|
|
|
|
// // 没有薪资项目时,给个不存在的,否则加载所有不合理
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// salaryItemIds = CollectionUtils.isEmpty(salaryItemIds) ? Collections.singletonList(0L) : salaryItemIds;
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// return new LambdaQueryChainWrapper<>(salaryArchiveItemMapper)
|
|
|
|
|
|
// .eq(SalaryArchiveItemPO::getDeleteType, 0)
|
|
|
|
|
|
// .eq(SalaryArchiveItemPO::getTenantKey, tenantKey)
|
|
|
|
|
|
// .in(SalaryArchiveItemPO::getSalaryItemId, salaryItemIds)
|
|
|
|
|
|
// .gt(SalaryArchiveItemPO::getEffectiveTime, LocalDate.now())
|
|
|
|
|
|
// .list();
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// private List<SalaryArchiveTaxAgentPO> getEffectiveTaxAgentList(String tenantKey) {
|
|
|
|
|
|
// return new LambdaQueryChainWrapper<>(salaryArchiveTaxAgentMapper)
|
|
|
|
|
|
// .eq(SalaryArchiveTaxAgentPO::getDeleteType, 0)
|
|
|
|
|
|
// .eq(SalaryArchiveTaxAgentPO::getTenantKey, tenantKey)
|
|
|
|
|
|
// .le(SalaryArchiveTaxAgentPO::getEffectiveTime, LocalDate.now())
|
|
|
|
|
|
// .orderByDesc(SalaryArchiveTaxAgentPO::getEffectiveTime)
|
|
|
|
|
|
// .list();
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// private List<SalaryArchiveTaxAgentPO> getIneffectiveTaxAgentList(String tenantKey) {
|
|
|
|
|
|
// return new LambdaQueryChainWrapper<>(salaryArchiveTaxAgentMapper)
|
|
|
|
|
|
// .eq(SalaryArchiveTaxAgentPO::getDeleteType, 0)
|
|
|
|
|
|
// .eq(SalaryArchiveTaxAgentPO::getTenantKey, tenantKey)
|
|
|
|
|
|
// .gt(SalaryArchiveTaxAgentPO::getEffectiveTime, LocalDate.now())
|
|
|
|
|
|
// .list();
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// /**
|
|
|
|
|
|
// * 检查参数
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// *
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// * @param message
|
|
|
|
|
|
// * @param params
|
|
|
|
|
|
// * @return
|
|
|
|
|
|
// */
|
|
|
|
|
|
// private boolean checkParams(BatchDocumentMessage message, Map<String, Object> params) {
|
|
|
|
|
|
// boolean isValid = true;
|
|
|
|
|
|
// String errorMsg = "";
|
|
|
|
|
|
// if (params == null) {
|
|
|
|
|
|
// errorMsg = SalaryI18nUtil.getI18nLabel(message.getTenantKey(), message.getUserId(), 100582, "参数必传");
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// if (!params.containsKey("importType")
|
|
|
|
|
|
// || params.get("importType") == null) {
|
|
|
|
|
|
// errorMsg = SalaryI18nUtil.getI18nLabel(message.getTenantKey(), message.getUserId(), 100592, "导入类型必传");
|
|
|
|
|
|
// } else {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// Optional<SalaryArchiveImportTypeEnum> optional = Arrays.stream(SalaryArchiveImportTypeEnum.values()).filter(e -> e.getValue().equals(params.get("importType").toString())).findFirst();
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// if (!optional.isPresent()) {
|
|
|
|
|
|
// errorMsg = SalaryI18nUtil.getI18nLabel(message.getTenantKey(), message.getUserId(), 100593, "导入类型不正确");
|
|
|
|
|
|
// } else {
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// message.setDataType(message.getDataType() + "-" + SalaryI18nUtil.getI18nLabel(message.getTenantKey(), message.getUserId(), optional.get().getLabelId(), optional.get().getDefaultLabel()));
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 有错误信息发送
|
|
|
|
|
|
// if (org.apache.commons.lang3.StringUtils.isNotEmpty(errorMsg)) {
|
|
|
|
|
|
// // 发送导入回调信息
|
|
|
|
|
|
// salaryBatchService.sendImportCallBackInfo(message, errorMsg);
|
|
|
|
|
|
// isValid = false;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// return isValid;
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// /**
|
|
|
|
|
|
// * 检查列头
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// *
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// * @param importType
|
|
|
|
|
|
// * @param message
|
|
|
|
|
|
// * @param headers
|
|
|
|
|
|
// * @return
|
|
|
|
|
|
// */
|
|
|
|
|
|
// private boolean checkHeaders(String importType, BatchDocumentMessage message, List<Map> headers) {
|
|
|
|
|
|
// boolean isValid = true;
|
|
|
|
|
|
// boolean isInit = importType.equals(SalaryArchiveImportTypeEnum.INIT.getValue());
|
|
|
|
|
|
// boolean isTaxAgentAdjust = importType.equals(SalaryArchiveImportTypeEnum.TAXAGENTADJUST.getValue());
|
|
|
|
|
|
// boolean isSalaryItemAdjust = importType.equals(SalaryArchiveImportTypeEnum.SALARYITEMADJUST.getValue());
|
|
|
|
|
|
//
|
|
|
|
|
|
// String tenantKey = message.getTenantKey();
|
|
|
|
|
|
// Long currentEmployeeId = message.getUserId();
|
|
|
|
|
|
// String userNameI18n = SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 85429, "姓名");
|
|
|
|
|
|
// String taxAgentI18n = SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 86184, "个税扣缴义务人");
|
|
|
|
|
|
// String effectiveTimeI18n = SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 85904, "生效日期");
|
|
|
|
|
|
// String adjustReasonI18n = SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 85431, "调整原因");
|
|
|
|
|
|
//
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// List<String> headerList = headers.stream().map(m -> Optional.ofNullable(m.get("key")).orElse("").toString()).collect(Collectors.toList());
|
2022-03-28 16:36:40 +08:00
|
|
|
|
//
|
|
|
|
|
|
// List<String> mustHeaders = Lists.newArrayList();
|
|
|
|
|
|
// if (isInit) {
|
|
|
|
|
|
// mustHeaders.add(userNameI18n);
|
|
|
|
|
|
// mustHeaders.add(taxAgentI18n);
|
|
|
|
|
|
// mustHeaders.add(effectiveTimeI18n);
|
|
|
|
|
|
// } else if (isTaxAgentAdjust) {
|
|
|
|
|
|
// mustHeaders.add(userNameI18n);
|
|
|
|
|
|
// mustHeaders.add(taxAgentI18n);
|
|
|
|
|
|
// mustHeaders.add(effectiveTimeI18n);
|
|
|
|
|
|
// mustHeaders.add(adjustReasonI18n);
|
|
|
|
|
|
// } else if (isSalaryItemAdjust) {
|
|
|
|
|
|
// mustHeaders.add(userNameI18n);
|
|
|
|
|
|
// mustHeaders.add(effectiveTimeI18n);
|
|
|
|
|
|
// mustHeaders.add(adjustReasonI18n);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 缺少的必须列
|
|
|
|
|
|
// List<String> lackHeaders = mustHeaders.stream().filter(item -> !headerList.contains(item)).collect(Collectors.toList());
|
|
|
|
|
|
//
|
|
|
|
|
|
// String errorMsg = "";
|
|
|
|
|
|
// String checkHeaderI18n = SalaryI18nUtil.getI18nLabel(tenantKey, currentEmployeeId, 101850, "缺少如下列,请检查:");
|
|
|
|
|
|
// if (CollectionUtils.isNotEmpty(lackHeaders)) {
|
|
|
|
|
|
// errorMsg = checkHeaderI18n + Joiner.on(",").join(lackHeaders);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 有错误信息发送
|
|
|
|
|
|
// if (StringUtils.isNotEmpty(errorMsg)) {
|
|
|
|
|
|
// // 发送导入回调信息
|
|
|
|
|
|
// salaryBatchService.sendImportCallBackInfo(message, errorMsg);
|
|
|
|
|
|
// isValid = false;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// return isValid;
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// /**
|
|
|
|
|
|
// * 数据落库处理
|
2022-03-28 20:04:27 +08:00
|
|
|
|
// *
|
2022-03-28 16:36:40 +08:00
|
|
|
|
// * @param importHandleParam
|
|
|
|
|
|
// */
|
|
|
|
|
|
// private void handleImportData(boolean isInit, String tenantKey, SalaryArchiveImportHandleParam importHandleParam) {
|
|
|
|
|
|
//
|
|
|
|
|
|
// List<SalaryArchivePO> salaryArchiveSaves = importHandleParam.getSalaryArchiveSaves();
|
|
|
|
|
|
// List<SalaryArchiveTaxAgentPO> salaryArchiveTaxAgentSaves = importHandleParam.getSalaryArchiveTaxAgentSaves();
|
|
|
|
|
|
// List<SalaryArchiveItemPO> salaryArchiveItemSaves = importHandleParam.getSalaryArchiveItemSaves();
|
|
|
|
|
|
// List<Long> salaryArchiveTaxAgentDelTaxAgentIds = importHandleParam.getSalaryArchiveTaxAgentDelTaxAgentIds();
|
|
|
|
|
|
// List<Long> salaryArchiveItemDelSalaryItemIds = importHandleParam.getSalaryArchiveItemDelSalaryItemIds();
|
|
|
|
|
|
// // 初始化导入
|
|
|
|
|
|
// if (isInit) {
|
|
|
|
|
|
// List<Long> salaryArchiveTaxAgentIds = importHandleParam.getSalaryArchiveTaxAgentSaves().stream().map(SalaryArchiveTaxAgentPO::getSalaryArchiveId).distinct().collect(Collectors.toList());
|
|
|
|
|
|
// List<Long> salaryArchiveItemIds = importHandleParam.getSalaryArchiveItemSaves().stream().map(SalaryArchiveItemPO::getSalaryArchiveId).distinct().collect(Collectors.toList());
|
|
|
|
|
|
// List<Long> salaryArchiveIds = salaryArchiveTaxAgentIds.stream().filter(item -> salaryArchiveItemIds.contains(item)).collect(Collectors.toList());
|
|
|
|
|
|
// if (CollectionUtils.isNotEmpty(salaryArchiveIds)) {
|
|
|
|
|
|
// List<List<Long>> partition = Lists.partition(salaryArchiveIds, 1000);
|
|
|
|
|
|
// for (List<Long> p : partition) {
|
|
|
|
|
|
// new LambdaUpdateChainWrapper<>(salaryArchiveTaxAgentMapper)
|
|
|
|
|
|
// .eq(SalaryArchiveTaxAgentPO::getDeleteType, 0)
|
|
|
|
|
|
// .eq(SalaryArchiveTaxAgentPO::getTenantKey, tenantKey)
|
|
|
|
|
|
// .in(SalaryArchiveTaxAgentPO::getSalaryArchiveId, p)
|
|
|
|
|
|
// .set(SalaryArchiveTaxAgentPO::getDeleteType, 1)
|
|
|
|
|
|
// .update();
|
|
|
|
|
|
// new LambdaUpdateChainWrapper<>(salaryArchiveItemMapper)
|
|
|
|
|
|
// .eq(SalaryArchiveItemPO::getDeleteType, 0)
|
|
|
|
|
|
// .eq(SalaryArchiveItemPO::getTenantKey, tenantKey)
|
|
|
|
|
|
// .in(SalaryArchiveItemPO::getSalaryArchiveId, p)
|
|
|
|
|
|
// .set(SalaryArchiveItemPO::getDeleteType, 1)
|
|
|
|
|
|
// .update();
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// if (CollectionUtils.isNotEmpty(salaryArchiveTaxAgentDelTaxAgentIds)) {
|
|
|
|
|
|
// salaryArchiveTaxAgentMapper.deleteBatchIds(salaryArchiveTaxAgentDelTaxAgentIds);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (CollectionUtils.isNotEmpty(salaryArchiveItemDelSalaryItemIds)) {
|
|
|
|
|
|
// salaryArchiveItemMapper.deleteBatchIds(salaryArchiveItemDelSalaryItemIds);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 新增薪资档案
|
|
|
|
|
|
// if (CollectionUtils.isNotEmpty(salaryArchiveSaves)) {
|
|
|
|
|
|
// // 薪资档案
|
|
|
|
|
|
// mapper.batchInsert(salaryArchiveSaves);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 薪资档案-个税扣缴义务人
|
|
|
|
|
|
// if (CollectionUtils.isNotEmpty(salaryArchiveTaxAgentSaves)) {
|
|
|
|
|
|
// salaryArchiveTaxAgentMapper.batchInsert(salaryArchiveTaxAgentSaves);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 薪资档案-薪资项目
|
|
|
|
|
|
// if (CollectionUtils.isNotEmpty(salaryArchiveItemSaves)) {
|
|
|
|
|
|
// salaryArchiveItemMapper.batchInsert(salaryArchiveItemSaves);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
2022-03-28 20:04:27 +08:00
|
|
|
|
}
|