补充列
This commit is contained in:
parent
c4c757d055
commit
c2cbdce9ec
|
|
@ -4,6 +4,7 @@ import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
|||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.salary.biz.TaxAgentBiz;
|
||||
import com.engine.salary.constant.SalaryDefaultTenantConstant;
|
||||
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
||||
import com.engine.salary.entity.salaryacct.bo.SalaryAcctEmployeeBO;
|
||||
import com.engine.salary.entity.salaryacct.bo.SalaryAcctResultBO;
|
||||
|
|
@ -11,8 +12,10 @@ import com.engine.salary.entity.salaryacct.dto.SalaryAccEmployeeListDTO;
|
|||
import com.engine.salary.entity.salaryacct.dto.SalaryAcctImportFieldDTO;
|
||||
import com.engine.salary.entity.salaryacct.dto.SalaryComparisonResultListDTO;
|
||||
import com.engine.salary.entity.salaryacct.param.*;
|
||||
import com.engine.salary.entity.salaryacct.po.ExcelAcctResultPO;
|
||||
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
|
||||
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
|
||||
import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO;
|
||||
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
||||
import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO;
|
||||
import com.engine.salary.entity.salarysob.dto.SalarySobItemDTO;
|
||||
|
|
@ -25,18 +28,27 @@ import com.engine.salary.exception.SalaryRunTimeException;
|
|||
import com.engine.salary.service.*;
|
||||
import com.engine.salary.util.SalaryEntityUtil;
|
||||
import com.engine.salary.util.SalaryI18nUtil;
|
||||
import com.engine.salary.util.excel.ExcelParseHelper;
|
||||
import com.engine.salary.util.excel.ExcelSupport;
|
||||
import com.engine.salary.util.excel.ExcelUtil;
|
||||
import com.engine.salary.util.valid.ValidUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import weaver.file.ImageFileManager;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.engine.salary.util.excel.ExcelSupport.EXCEL_TYPE_XLSX;
|
||||
|
||||
/**
|
||||
* 薪资核算导入导出
|
||||
* <p>Copyright: Copyright (c) 2022</p>
|
||||
|
|
@ -444,235 +456,259 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
|
|||
// }
|
||||
// }
|
||||
|
||||
// private void batchImport(SalaryAcctImportParam param, String importType) {
|
||||
// ValidUtil.doValidator(param);
|
||||
// LocalDateTime now = LocalDateTime.now();
|
||||
//
|
||||
// // 薪资核算记录的id
|
||||
// Long salaryAcctRecordId = param.getSalaryAcctRecordId();
|
||||
// // 薪资核算记录
|
||||
// SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salaryAcctRecordId);
|
||||
// if (salaryAcctRecordPO == null) {
|
||||
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
|
||||
// }
|
||||
// // 薪资账套下的薪资项目副本
|
||||
// List<SalarySobItemPO> salarySobItemPOS = getSalarySobItemService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId());
|
||||
// // 薪资项目
|
||||
// Set<Long> salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId);
|
||||
// List<SalaryItemPO> salaryItems = getSalaryItemService(user).listByIds(salaryItemIds);
|
||||
// Map<String, Long> salaryItemMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getName, SalaryItemPO::getId);
|
||||
// // 薪资核算确认的人员
|
||||
// List<SalaryAcctEmployeePO> salaryAcctEmployees = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(salaryAcctRecordId);
|
||||
// Map<String, SalaryAcctEmployeePO> salaryAcctEmployeeMap = SalaryEntityUtil.convert2Map(salaryAcctEmployees, e -> e.getEmployeeId() + "-" + e.getTaxAgentId());
|
||||
// // 租户下所有的人员
|
||||
// List<DataCollectionEmployee> salaryEmployees = getSalaryEmployeeService(user).listAll();
|
||||
// Map<String, Long> salaryEmployeeMap = SalaryEntityUtil.convert2Map(salaryEmployees, DataCollectionEmployee::getUsername, DataCollectionEmployee::getEmployeeId);
|
||||
// // 租户下所有的个税扣缴义务人
|
||||
// List<TaxAgent> taxAgents = taxAgentService.listAll();
|
||||
// Map<String, Long> taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgent::getName, TaxAgent::getId);
|
||||
//
|
||||
// // 索引(用于计算进度)
|
||||
// int index = 0;
|
||||
// // 失败的数量
|
||||
// int failCount = 0;
|
||||
// // 成功的数量
|
||||
// int successCount = 0;
|
||||
// // 总数
|
||||
private Map<String, Object> batchImport(SalaryAcctImportParam param, String importType) {
|
||||
ValidUtil.doValidator(param);
|
||||
Date now = new Date();
|
||||
|
||||
Long currentEmployeeId = (long) user.getUID();
|
||||
|
||||
// 薪资核算记录的id
|
||||
Long salaryAcctRecordId = param.getSalaryAcctRecordId();
|
||||
// 薪资核算记录
|
||||
SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(salaryAcctRecordId);
|
||||
if (salaryAcctRecordPO == null) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
|
||||
}
|
||||
// 薪资账套下的薪资项目副本
|
||||
List<SalarySobItemPO> salarySobItemPOS = getSalarySobItemService(user).listBySalarySobId(salaryAcctRecordPO.getSalarySobId());
|
||||
// 薪资项目
|
||||
Set<Long> salaryItemIds = SalaryEntityUtil.properties(salarySobItemPOS, SalarySobItemPO::getSalaryItemId);
|
||||
List<SalaryItemPO> salaryItems = getSalaryItemService(user).listByIds(salaryItemIds);
|
||||
Map<String, Long> salaryItemMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getName, SalaryItemPO::getId);
|
||||
// 薪资核算确认的人员
|
||||
List<SalaryAcctEmployeePO> salaryAcctEmployees = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordId(salaryAcctRecordId);
|
||||
Map<String, SalaryAcctEmployeePO> salaryAcctEmployeeMap = SalaryEntityUtil.convert2Map(salaryAcctEmployees, e -> e.getEmployeeId() + "-" + e.getTaxAgentId());
|
||||
// 租户下所有的人员
|
||||
List<DataCollectionEmployee> salaryEmployees = getSalaryEmployeeService(user).listAll();
|
||||
Map<String, Long> salaryEmployeeMap = SalaryEntityUtil.convert2Map(salaryEmployees, DataCollectionEmployee::getUsername, DataCollectionEmployee::getEmployeeId);
|
||||
// 租户下所有的个税扣缴义务人
|
||||
List<TaxAgent> taxAgents = taxAgentService.listAll();
|
||||
Map<String, Long> taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgent::getName, TaxAgent::getId);
|
||||
|
||||
// 索引(用于计算进度)
|
||||
int index = 0;
|
||||
// 失败的数量
|
||||
int failCount = 0;
|
||||
// 成功的数量
|
||||
int successCount = 0;
|
||||
// 总数
|
||||
// int total = message.getBatchFile().getExcelSheets().stream()
|
||||
// .filter(e -> CollectionUtils.isNotEmpty(e.getHeader()) && CollectionUtils.isNotEmpty(e.getData()))
|
||||
// .map(e -> BigDecimal.valueOf(e.getData().size()))
|
||||
// .reduce(BigDecimal.ZERO, BigDecimal::add)
|
||||
// .intValue();
|
||||
// // 包含错误提示信息的sheet页
|
||||
// List<Map<String, String>> errorExcelSheets = Lists.newArrayList();
|
||||
// // 解析excel
|
||||
// Set<Long> salaryAcctEmpIds = Sets.newHashSet();
|
||||
// // excel导入了哪些薪资项目
|
||||
// Set<Long> excelSalaryItemIds = Sets.newHashSet();
|
||||
// List<SalaryAcctResultPO> salaryAcctResults = Lists.newArrayList();
|
||||
// List<SalaryAcctEmployeePO> newSalaryAcctEmployees = Lists.newArrayList();
|
||||
//
|
||||
// List<ExcelAcctResultPO> excelAcctResults = Lists.newArrayList();
|
||||
//
|
||||
// InputStream fileInputStream = null;
|
||||
// fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(param.getImageId()));
|
||||
//
|
||||
// Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX);
|
||||
// List<String> headers = ExcelSupport.getSheetHeader(sheet, 0);
|
||||
//
|
||||
// if (CollectionUtils.isEmpty(headers)) {
|
||||
// return;
|
||||
// }
|
||||
// // 错误提示信息
|
||||
// List<ExcelComment> excelComments = Lists.newArrayList();
|
||||
// // 存在错误的那行数据
|
||||
// List<Map<String, Object>> errorDatas = Lists.newArrayList();
|
||||
// // 表头
|
||||
// List<Map> headers = excelSheet.getHeader();
|
||||
// // 处理数值
|
||||
// List<Map<String, Object>> data = excelSheet.getData();
|
||||
// if (CollectionUtils.isEmpty(data)) {
|
||||
// continue;
|
||||
// }
|
||||
// for (int i = 0; i < data.size(); i++) {
|
||||
// int usernameIndex = 0;
|
||||
// boolean isError = false;
|
||||
// Map<String, Object> map = data.get(i);
|
||||
// Long employeeId = 0L;
|
||||
// Long taxAgentId = 0L;
|
||||
// List<SalaryAcctResultPO> salaryAcctResultsOfOneEmp = Lists.newArrayListWithExpectedSize(headers.size() - 1);
|
||||
// List<ExcelAcctResultPO> excelAcctResultsOfOneEmp = Lists.newArrayListWithExpectedSize(headers.size() - 1);
|
||||
// for (int j = 0; j < headers.size(); j++) {
|
||||
// Map header = headers.get(j);
|
||||
// Object dataKey = header.get("key");
|
||||
// if (dataKey == null) {
|
||||
// continue;
|
||||
// }
|
||||
// String dataValue = (String) map.getOrDefault(dataKey.toString(), "");
|
||||
// if (StringUtils.equals(SalaryI18nUtil.getI18nLabel(85429, "姓名"), dataKey.toString())) {
|
||||
// usernameIndex = j;
|
||||
// if (StringUtils.isEmpty(dataValue)) {
|
||||
// isError = true;
|
||||
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(102838, "姓名不能为空"), i, i, j, j);
|
||||
// } else {
|
||||
// employeeId = salaryEmployeeMap.getOrDefault(dataValue, 0L);
|
||||
// if (employeeId == null || employeeId <= 0) {
|
||||
// isError = true;
|
||||
// 包含错误提示信息的sheet页
|
||||
List<Map<String, String>> errorExcelSheets = Lists.newArrayList();
|
||||
// 解析excel
|
||||
Set<Long> salaryAcctEmpIds = Sets.newHashSet();
|
||||
// excel导入了哪些薪资项目
|
||||
Set<Long> excelSalaryItemIds = Sets.newHashSet();
|
||||
List<SalaryAcctResultPO> salaryAcctResults = Lists.newArrayList();
|
||||
List<SalaryAcctEmployeePO> newSalaryAcctEmployees = Lists.newArrayList();
|
||||
|
||||
List<ExcelAcctResultPO> excelAcctResults = Lists.newArrayList();
|
||||
|
||||
InputStream fileInputStream = null;
|
||||
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(param.getImageId()));
|
||||
|
||||
Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX);
|
||||
|
||||
|
||||
// 错误提示信息
|
||||
List<Map> excelComments = Lists.newArrayList();
|
||||
// 存在错误的那行数据
|
||||
List<Map<String, Object>> errorDatas = Lists.newArrayList();
|
||||
// 表头
|
||||
List<String> headers = ExcelSupport.getSheetHeader(sheet, 0);
|
||||
;
|
||||
// 处理数值
|
||||
List<Map<String, Object>> data = ExcelParseHelper.parse2Map(sheet, 1);
|
||||
if (CollectionUtils.isEmpty(headers)) {
|
||||
throw new RuntimeException("表头为空");
|
||||
}
|
||||
if (CollectionUtils.isEmpty(data)) {
|
||||
throw new RuntimeException("");
|
||||
}
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
int usernameIndex = 0;
|
||||
boolean isError = false;
|
||||
Map<String, Object> map = data.get(i);
|
||||
Long employeeId = 0L;
|
||||
Long taxAgentId = 0L;
|
||||
List<SalaryAcctResultPO> salaryAcctResultsOfOneEmp = Lists.newArrayListWithExpectedSize(headers.size() - 1);
|
||||
List<ExcelAcctResultPO> excelAcctResultsOfOneEmp = Lists.newArrayListWithExpectedSize(headers.size() - 1);
|
||||
for (int j = 0; j < headers.size(); j++) {
|
||||
String header = headers.get(j);
|
||||
String dataKey = header;
|
||||
if (dataKey == null) {
|
||||
continue;
|
||||
}
|
||||
String dataValue = (String) map.getOrDefault(dataKey.toString(), "");
|
||||
if (StringUtils.equals(SalaryI18nUtil.getI18nLabel(85429, "姓名"), dataKey.toString())) {
|
||||
usernameIndex = j;
|
||||
if (StringUtils.isEmpty(dataValue)) {
|
||||
isError = true;
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", SalaryI18nUtil.getI18nLabel(102838, "姓名不能为空"));
|
||||
excelComments.add(errorMessageMap);
|
||||
//salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(102838, "姓名不能为空"), i, i, j, j);
|
||||
} else {
|
||||
employeeId = salaryEmployeeMap.getOrDefault(dataValue, 0L);
|
||||
if (employeeId == null || employeeId <= 0) {
|
||||
isError = true;
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", SalaryI18nUtil.getI18nLabel(100579, "姓名错误,系统内不存在该姓名"));
|
||||
excelComments.add(errorMessageMap);
|
||||
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(100579, "姓名错误,系统内不存在该姓名"), i, i, j, j);
|
||||
// }
|
||||
// }
|
||||
// } else if (StringUtils.equals(SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), dataKey.toString())) {
|
||||
// if (StringUtils.isEmpty(dataValue)) {
|
||||
// isError = true;
|
||||
}
|
||||
}
|
||||
} else if (StringUtils.equals(SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"), dataKey.toString())) {
|
||||
if (StringUtils.isEmpty(dataValue)) {
|
||||
isError = true;
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", SalaryI18nUtil.getI18nLabel(100579, SalaryI18nUtil.getI18nLabel(102839, "个税扣缴义务人不能为空")));
|
||||
excelComments.add(errorMessageMap);
|
||||
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(102839, "个税扣缴义务人不能为空"), i, i, j, j);
|
||||
// } else {
|
||||
// taxAgentId = taxAgentNameMap.getOrDefault(dataValue, 0L);
|
||||
// if (taxAgentId == null || taxAgentId <= 0) {
|
||||
// isError = true;
|
||||
} else {
|
||||
taxAgentId = taxAgentNameMap.getOrDefault(dataValue, 0L);
|
||||
if (taxAgentId == null || taxAgentId <= 0) {
|
||||
isError = true;
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", SalaryI18nUtil.getI18nLabel(100579, SalaryI18nUtil.getI18nLabel(102840, "个税扣缴义务人错误,系统内不存在该个税扣缴义务人")));
|
||||
excelComments.add(errorMessageMap);
|
||||
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(102840, "个税扣缴义务人错误,系统内不存在该个税扣缴义务人"), i, i, j, j);
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// Long salaryItemId = salaryItemMap.get(dataKey.toString());
|
||||
// if (salaryItemId == null || salaryItemId <= 0) {
|
||||
// isError = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Long salaryItemId = salaryItemMap.get(dataKey.toString());
|
||||
if (salaryItemId == null || salaryItemId <= 0) {
|
||||
isError = true;
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", SalaryI18nUtil.getI18nLabel(100579, SalaryI18nUtil.getI18nLabel(102840, "本次核算所用账套不包含该薪资项目")));
|
||||
excelComments.add(errorMessageMap);
|
||||
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(102841, "表头错误,本次核算所用账套不包含该薪资项目"), i, i, j, j);
|
||||
// } else {
|
||||
// excelSalaryItemIds.add(salaryItemId);
|
||||
// if (StringUtils.equals("importExcelAcctResult", importType)) {
|
||||
// ExcelAcctResultPO excelAcctResult = ExcelAcctResultPO.builder()
|
||||
} else {
|
||||
excelSalaryItemIds.add(salaryItemId);
|
||||
if (StringUtils.equals("importExcelAcctResult", importType)) {
|
||||
ExcelAcctResultPO excelAcctResult = ExcelAcctResultPO.builder()
|
||||
// .id(IdGenerator.generate())
|
||||
// .salaryAcctRecordId(salaryAcctRecordPO.getId())
|
||||
// .salarySobId(salaryAcctRecordPO.getSalarySobId())
|
||||
// .salaryItemId(salaryItemId)
|
||||
// .resultValue(dataValue)
|
||||
// .creator(currentEmployeeId)
|
||||
// .createTime(now)
|
||||
// .updateTime(now)
|
||||
// .deleteType(0)
|
||||
// .tenantKey(tenantKey)
|
||||
// .build();
|
||||
// excelAcctResultsOfOneEmp.add(excelAcctResult);
|
||||
// }
|
||||
// if (StringUtils.equals("importSalaryAcctResult", importType)) {
|
||||
// SalaryAcctResultPO salaryAcctResult = SalaryAcctResultPO.builder()
|
||||
.salaryAcctRecordId(salaryAcctRecordPO.getId())
|
||||
.salarySobId(salaryAcctRecordPO.getSalarySobId())
|
||||
.salaryItemId(salaryItemId)
|
||||
.resultValue(dataValue)
|
||||
.creator(currentEmployeeId)
|
||||
.createTime(now)
|
||||
.updateTime(now)
|
||||
.deleteType(0)
|
||||
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
||||
.build();
|
||||
excelAcctResultsOfOneEmp.add(excelAcctResult);
|
||||
}
|
||||
if (StringUtils.equals("importSalaryAcctResult", importType)) {
|
||||
SalaryAcctResultPO salaryAcctResult = SalaryAcctResultPO.builder()
|
||||
// .id(IdGenerator.generate())
|
||||
// .salaryAcctRecordId(salaryAcctRecordPO.getId())
|
||||
// .salarySobId(salaryAcctRecordPO.getSalarySobId())
|
||||
// .salaryItemId(salaryItemId)
|
||||
// .resultValue(dataValue)
|
||||
// .creator(currentEmployeeId)
|
||||
// .createTime(now)
|
||||
// .updateTime(now)
|
||||
// .deleteType(0)
|
||||
// .tenantKey(tenantKey)
|
||||
// .build();
|
||||
// salaryAcctResultsOfOneEmp.add(salaryAcctResult);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// // (如果是线下对比)如果个税扣缴义务人+人员目前不在核算人员里面,不支持导入
|
||||
// if (StringUtils.equals("importExcelAcctResult", importType)
|
||||
// && (employeeId != null && employeeId > 0)
|
||||
// && (taxAgentId != null && taxAgentId > 0)
|
||||
// && i == data.size() - 1
|
||||
// && !salaryAcctEmployeeMap.containsKey(employeeId + "-" + taxAgentId)) {
|
||||
// isError = true;
|
||||
.salaryAcctRecordId(salaryAcctRecordPO.getId())
|
||||
.salarySobId(salaryAcctRecordPO.getSalarySobId())
|
||||
.salaryItemId(salaryItemId)
|
||||
.resultValue(dataValue)
|
||||
.creator(currentEmployeeId)
|
||||
.createTime(now)
|
||||
.updateTime(now)
|
||||
.deleteType(0)
|
||||
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
||||
.build();
|
||||
salaryAcctResultsOfOneEmp.add(salaryAcctResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
// (如果是线下对比)如果个税扣缴义务人+人员目前不在核算人员里面,不支持导入
|
||||
if (StringUtils.equals("importExcelAcctResult", importType)
|
||||
&& (employeeId != null && employeeId > 0)
|
||||
&& (taxAgentId != null && taxAgentId > 0)
|
||||
&& i == data.size() - 1
|
||||
&& !salaryAcctEmployeeMap.containsKey(employeeId + "-" + taxAgentId)) {
|
||||
isError = true;
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", SalaryI18nUtil.getI18nLabel(100579, SalaryI18nUtil.getI18nLabel(102840, "本次薪资核算不包含该人员")));
|
||||
excelComments.add(errorMessageMap);
|
||||
// salaryBatchService.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(102842, "本次薪资核算不包含该人员"), i, i, usernameIndex, usernameIndex);
|
||||
// }
|
||||
// }
|
||||
// // 每处理50个数据更新一次进度
|
||||
// index++;
|
||||
}
|
||||
}
|
||||
// 每处理50个数据更新一次进度
|
||||
index++;
|
||||
// if (index % 50 == 0 || index >= total) {
|
||||
// salaryBatchService.sendImportRate(message.getBizId(), total, index);
|
||||
// }
|
||||
// if (isError) {
|
||||
// failCount++;
|
||||
// errorDatas.add(map);
|
||||
// continue;
|
||||
// }
|
||||
// SalaryAcctEmployeePO salaryAcctEmployee = salaryAcctEmployeeMap.get(employeeId + "-" + taxAgentId);
|
||||
// Long salaryAcctEmpId = Optional.ofNullable(salaryAcctEmployee).map(SalaryAcctEmployeePO::getId).orElse(0L);
|
||||
// if (StringUtils.equals("importExcelAcctResult", importType)) {
|
||||
// for (ExcelAcctResultPO excelAcctResultPO : excelAcctResultsOfOneEmp) {
|
||||
// excelAcctResultPO.setEmployeeId(employeeId);
|
||||
// excelAcctResultPO.setTaxAgentId(taxAgentId);
|
||||
// excelAcctResultPO.setSalaryAcctEmpId(salaryAcctEmpId);
|
||||
// }
|
||||
// excelAcctResults.addAll(excelAcctResultsOfOneEmp);
|
||||
// }
|
||||
// if (StringUtils.equals("importSalaryAcctResult", importType)) {
|
||||
// if (salaryAcctEmpId <= 0) {
|
||||
// SalaryAcctEmployeePO acctEmployee = SalaryAcctEmployeePO.builder()
|
||||
if (isError) {
|
||||
failCount++;
|
||||
errorDatas.add(map);
|
||||
continue;
|
||||
}
|
||||
SalaryAcctEmployeePO salaryAcctEmployee = salaryAcctEmployeeMap.get(employeeId + "-" + taxAgentId);
|
||||
Long salaryAcctEmpId = Optional.ofNullable(salaryAcctEmployee).map(SalaryAcctEmployeePO::getId).orElse(0L);
|
||||
if (StringUtils.equals("importExcelAcctResult", importType)) {
|
||||
for (ExcelAcctResultPO excelAcctResultPO : excelAcctResultsOfOneEmp) {
|
||||
excelAcctResultPO.setEmployeeId(employeeId);
|
||||
excelAcctResultPO.setTaxAgentId(taxAgentId);
|
||||
excelAcctResultPO.setSalaryAcctEmpId(salaryAcctEmpId);
|
||||
}
|
||||
excelAcctResults.addAll(excelAcctResultsOfOneEmp);
|
||||
}
|
||||
if (StringUtils.equals("importSalaryAcctResult", importType)) {
|
||||
if (salaryAcctEmpId <= 0) {
|
||||
SalaryAcctEmployeePO acctEmployee = SalaryAcctEmployeePO.builder()
|
||||
// .id(IdGenerator.generate())
|
||||
// .employeeId(employeeId)
|
||||
// .salaryAcctRecordId(salaryAcctRecordId)
|
||||
// .salarySobId(salaryAcctRecordPO.getSalarySobId())
|
||||
// .salaryMonth(salaryAcctRecordPO.getSalaryMonth())
|
||||
// .taxAgentId(taxAgentId)
|
||||
// .creator(currentEmployeeId)
|
||||
// .createTime(now)
|
||||
// .updateTime(now)
|
||||
// .deleteType(0)
|
||||
// .tenantKey(tenantKey)
|
||||
// .build();
|
||||
// newSalaryAcctEmployees.add(acctEmployee);
|
||||
// salaryAcctEmpId = acctEmployee.getId();
|
||||
// }
|
||||
// for (SalaryAcctResultPO salaryAcctResultPO : salaryAcctResultsOfOneEmp) {
|
||||
// salaryAcctResultPO.setEmployeeId(employeeId);
|
||||
// salaryAcctResultPO.setTaxAgentId(taxAgentId);
|
||||
// salaryAcctResultPO.setSalaryAcctEmpId(salaryAcctEmpId);
|
||||
// }
|
||||
// salaryAcctEmpIds.add(salaryAcctEmpId);
|
||||
// salaryAcctResults.addAll(salaryAcctResultsOfOneEmp);
|
||||
// }
|
||||
// successCount++;
|
||||
// }
|
||||
// // 如果sheet包含错误数据
|
||||
.employeeId(employeeId)
|
||||
.salaryAcctRecordId(salaryAcctRecordId)
|
||||
.salarySobId(salaryAcctRecordPO.getSalarySobId())
|
||||
.salaryMonth(salaryAcctRecordPO.getSalaryMonth())
|
||||
.taxAgentId(taxAgentId)
|
||||
.creator(currentEmployeeId)
|
||||
.createTime(now)
|
||||
.updateTime(now)
|
||||
.deleteType(0)
|
||||
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
||||
.build();
|
||||
newSalaryAcctEmployees.add(acctEmployee);
|
||||
salaryAcctEmpId = acctEmployee.getId();
|
||||
}
|
||||
for (SalaryAcctResultPO salaryAcctResultPO : salaryAcctResultsOfOneEmp) {
|
||||
salaryAcctResultPO.setEmployeeId(employeeId);
|
||||
salaryAcctResultPO.setTaxAgentId(taxAgentId);
|
||||
salaryAcctResultPO.setSalaryAcctEmpId(salaryAcctEmpId);
|
||||
}
|
||||
salaryAcctEmpIds.add(salaryAcctEmpId);
|
||||
salaryAcctResults.addAll(salaryAcctResultsOfOneEmp);
|
||||
}
|
||||
successCount++;
|
||||
}
|
||||
// 如果sheet包含错误数据
|
||||
// if (CollectionUtils.isNotEmpty(errorDatas)) {
|
||||
// salaryBatchService.createErrorExcelSheet(headers, errorDatas, excelSheet.getName(), excelComments, errorExcelSheets);
|
||||
// }
|
||||
// if (StringUtils.equals("importExcelAcctResult", importType)) {
|
||||
// getSalaryComparisonResultService(user).deleteBySalaryAcctRecordIds(Collections.singleton(salaryAcctRecordId));
|
||||
// if (CollectionUtils.isNotEmpty(excelAcctResults)) {
|
||||
// getSalaryComparisonResultService(user).batchSave(excelAcctResults);
|
||||
// }
|
||||
// }
|
||||
// if (StringUtils.equals("importSalaryAcctResult", importType)) {
|
||||
// if (CollectionUtils.isNotEmpty(salaryAcctEmpIds)) {
|
||||
// getSalaryAcctResultService(user).deleteByAcctEmployeeIdsAndSalaryItemIds(salaryAcctEmpIds, excelSalaryItemIds);
|
||||
// }
|
||||
// if (CollectionUtils.isNotEmpty(salaryAcctResults)) {
|
||||
// getSalaryAcctResultService(user).batchSave(salaryAcctResults);
|
||||
// }
|
||||
// if (CollectionUtils.isNotEmpty(newSalaryAcctEmployees)) {
|
||||
// getSalaryAcctEmployeeService(user).batchSave(newSalaryAcctEmployees);
|
||||
// }
|
||||
// }
|
||||
// // 发送导入回调信息
|
||||
if (StringUtils.equals("importExcelAcctResult", importType)) {
|
||||
getSalaryComparisonResultService(user).deleteBySalaryAcctRecordIds(Collections.singleton(salaryAcctRecordId));
|
||||
if (CollectionUtils.isNotEmpty(excelAcctResults)) {
|
||||
getSalaryComparisonResultService(user).batchSave(excelAcctResults);
|
||||
}
|
||||
}
|
||||
if (StringUtils.equals("importSalaryAcctResult", importType)) {
|
||||
if (CollectionUtils.isNotEmpty(salaryAcctEmpIds)) {
|
||||
getSalaryAcctResultService(user).deleteByAcctEmployeeIdsAndSalaryItemIds(salaryAcctEmpIds, excelSalaryItemIds);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(salaryAcctResults)) {
|
||||
getSalaryAcctResultService(user).batchSave(salaryAcctResults);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(newSalaryAcctEmployees)) {
|
||||
getSalaryAcctEmployeeService(user).batchSave(newSalaryAcctEmployees);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 发送导入回调信息
|
||||
// salaryBatchService.sendImportCallBackInfo(message, successCount, failCount, errorExcelSheets);
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Map<String, Object> exportCheckResult(
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.engine.salary.entity.salaryacct.param.SalaryAcctRecordQueryParam;
|
|||
import com.engine.salary.entity.salaryacct.param.SalaryAcctRecordSaveParam;
|
||||
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
|
||||
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
|
||||
import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO;
|
||||
import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO;
|
||||
import com.engine.salary.entity.salarysob.po.SalarySobPO;
|
||||
import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum;
|
||||
|
|
@ -58,7 +59,10 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
|
|||
return (SalaryAcctEmployeeService) ServiceUtil.getService(SalaryAcctEmployeeServiceImpl.class, user);
|
||||
}
|
||||
|
||||
private SalaryAcctResultService salaryAcctResultService;
|
||||
|
||||
private SalaryAcctResultService getSalaryAcctResultService(User user) {
|
||||
return (SalaryAcctResultService) ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user);
|
||||
}
|
||||
|
||||
// private SalaryCheckResultService salaryCheckResultService;
|
||||
//
|
||||
|
|
@ -306,7 +310,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
|
|||
//todo 删除薪资核算人员
|
||||
// getSalaryAcctEmployeeService(user).deleteBySalaryAcctRecordIds(ids);
|
||||
// // 删除薪资核算结果
|
||||
// salaryAcctResultService.deleteBySalaryAcctRecordIds(ids);
|
||||
// getSalaryAcctResultService(user).deleteBySalaryAcctRecordIds(ids);
|
||||
// // 删除校验异常
|
||||
// salaryCheckResultService.deleteBySalaryAcctRecordIds(ids);
|
||||
// // 删除校验异常明细
|
||||
|
|
@ -349,11 +353,10 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
|
|||
// if (CollectionUtils.isNotEmpty(salaryCheckResultPOS)) {
|
||||
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98784, "核算结果尚未通过校验规则,请确认是否需要忽略校验异常后再归档"));
|
||||
// }
|
||||
//todo 查询薪资核算结果
|
||||
// List<SalaryAcctResultPO> salaryAcctResultPOS = salaryAcctResultService.listBySalaryAcctRecordIds(Collections.singleton(salaryAcctRecordId));
|
||||
// if (CollectionUtils.isEmpty(salaryAcctResultPOS)) {
|
||||
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99691, "尚未核算,请先核算后再归档"));
|
||||
// }
|
||||
List<SalaryAcctResultPO> salaryAcctResultPOS = getSalaryAcctResultService(user).listBySalaryAcctRecordIds(Collections.singleton(salaryAcctRecordId));
|
||||
if (CollectionUtils.isEmpty(salaryAcctResultPOS)) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99691, "尚未核算,请先核算后再归档"));
|
||||
}
|
||||
// 更新薪资核算记录的状态
|
||||
salaryAcctRecordPO.setStatus(SalaryAcctRecordStatusEnum.ARCHIVED.getValue());
|
||||
salaryAcctRecordPO.setUpdateTime(new Date());
|
||||
|
|
|
|||
Loading…
Reference in New Issue