处理大数据内存溢出
This commit is contained in:
parent
4798f5d4a6
commit
db391f01c4
|
|
@ -24,6 +24,7 @@ import com.engine.salary.util.SalaryI18nUtil;
|
|||
import com.engine.salary.util.excel.ExcelUtilPlus;
|
||||
import com.engine.salary.util.page.PageInfo;
|
||||
import com.engine.salary.util.page.SalaryPageUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
@ -137,6 +138,7 @@ public class SalaryStatisticsEmployeeWrapper extends Service {
|
|||
|
||||
/**
|
||||
* 获取员工发薪明细列表
|
||||
*
|
||||
* @param queryParam
|
||||
*/
|
||||
public Map<String, Object> salaryList(SalaryStatisticsEmployeeSalaryQueryParam queryParam) {
|
||||
|
|
@ -147,7 +149,7 @@ public class SalaryStatisticsEmployeeWrapper extends Service {
|
|||
// 获取发薪人员
|
||||
PageInfo<SalaryAcctEmployeePO> salaryAcctEmployeePageInfo = getSalaryStatisticsEmployeeService(user).listSalaryAcctEmp(queryParam);
|
||||
// 获取薪资核算结果
|
||||
SalaryStatisticsEmployeeDetailResultDTO salaryStatisticsEmployeeDetailResult = getSalaryStatisticsEmployeeService(user).getDetailSalaryAcctResultByAcctEmp(salaryAcctEmployeePageInfo.getList());
|
||||
SalaryStatisticsEmployeeDetailResultDTO salaryStatisticsEmployeeDetailResult = getSalaryStatisticsEmployeeService(user).getDetailSalaryAcctResultByAcctEmp(salaryAcctEmployeePageInfo.getList());
|
||||
List<Map<String, Object>> records = getSalaryStatisticsEmployeeService(user).listDetailPage(salaryStatisticsEmployeeDetailResult, null);
|
||||
|
||||
Map<String, Object> countResultMap = Maps.newHashMap();
|
||||
|
|
@ -183,7 +185,7 @@ public class SalaryStatisticsEmployeeWrapper extends Service {
|
|||
// 结果
|
||||
if (queryParam.isExport()) {
|
||||
resultMap.put("columns", weaTableColumns);
|
||||
resultMap.put("salaryItems",salaryStatisticsEmployeeDetailResult.getSalaryItemList());
|
||||
resultMap.put("salaryItems", salaryStatisticsEmployeeDetailResult.getSalaryItemList());
|
||||
resultMap.put("countResult", countResultMap);
|
||||
} else {
|
||||
WeaTable table = new WeaTable();
|
||||
|
|
@ -205,6 +207,7 @@ public class SalaryStatisticsEmployeeWrapper extends Service {
|
|||
|
||||
/**
|
||||
* 获取员工发薪明细列表
|
||||
*
|
||||
* @param queryParam
|
||||
*/
|
||||
public Map<String, Object> salaryListSum(SalaryStatisticsEmployeeSalaryQueryParam queryParam) {
|
||||
|
|
@ -215,25 +218,37 @@ public class SalaryStatisticsEmployeeWrapper extends Service {
|
|||
queryParam.setExport(true);
|
||||
// 获取发薪人员
|
||||
PageInfo<SalaryAcctEmployeePO> salaryAcctEmployeePageInfo = getSalaryStatisticsEmployeeService(user).listSalaryAcctEmp(queryParam);
|
||||
// 获取薪资核算结果
|
||||
SalaryStatisticsEmployeeDetailResultDTO salaryStatisticsEmployeeDetailResult = getSalaryStatisticsEmployeeService(user).getDetailSalaryAcctResultByAcctEmp(salaryAcctEmployeePageInfo.getList());
|
||||
List<Map<String, Object>> records = getSalaryStatisticsEmployeeService(user).listDetailPage(salaryStatisticsEmployeeDetailResult, null);
|
||||
List<SalaryAcctEmployeePO> employeePOS = salaryAcctEmployeePageInfo.getList();
|
||||
|
||||
Map<String, Object> sumResultMap = Maps.newHashMap();
|
||||
if (CollectionUtils.isNotEmpty(records)) {
|
||||
List<SalaryItemPO> salaryItems = salaryStatisticsEmployeeDetailResult.getSalaryItemList();
|
||||
for (SalaryItemPO item : salaryItems) {
|
||||
BigDecimal sumBigDecimal = new BigDecimal(SalaryStatisticsReportBO.ZERO);
|
||||
String itemKey = item.getId() + SalaryConstant.DYNAMIC_SUFFIX;
|
||||
for (Map<String, Object> record : records) {
|
||||
if (record.containsKey(itemKey)) {
|
||||
if (Objects.nonNull(record.get(itemKey)) && StringUtils.isNotEmpty(record.get(itemKey).toString()) && NumberUtils.isCreatable(record.get(itemKey).toString())) {
|
||||
sumBigDecimal = sumBigDecimal.add(new BigDecimal(record.get(itemKey).toString()));
|
||||
|
||||
List<List<SalaryAcctEmployeePO>> empParts = Lists.partition(employeePOS, 500);
|
||||
|
||||
for (int i = 0; i < empParts.size(); i++) {
|
||||
// 获取薪资核算结果
|
||||
SalaryStatisticsEmployeeDetailResultDTO salaryStatisticsEmployeeDetailResult = getSalaryStatisticsEmployeeService(user).getDetailSalaryAcctResultByAcctEmp(empParts.get(i));
|
||||
List<Map<String, Object>> records = getSalaryStatisticsEmployeeService(user).listDetailPage(salaryStatisticsEmployeeDetailResult, null);
|
||||
|
||||
if (CollectionUtils.isNotEmpty(records)) {
|
||||
List<SalaryItemPO> salaryItems = salaryStatisticsEmployeeDetailResult.getSalaryItemList();
|
||||
for (SalaryItemPO item : salaryItems) {
|
||||
BigDecimal sumBigDecimal = new BigDecimal(SalaryStatisticsReportBO.ZERO);
|
||||
String itemKey = item.getId() + SalaryConstant.DYNAMIC_SUFFIX;
|
||||
for (Map<String, Object> record : records) {
|
||||
if (record.containsKey(itemKey)) {
|
||||
if (Objects.nonNull(record.get(itemKey)) && StringUtils.isNotEmpty(record.get(itemKey).toString()) && NumberUtils.isCreatable(record.get(itemKey).toString())) {
|
||||
sumBigDecimal = sumBigDecimal.add(new BigDecimal(record.get(itemKey).toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Object o = sumResultMap.get(itemKey + "_n");
|
||||
if (o != null) {
|
||||
sumBigDecimal = sumBigDecimal.add((BigDecimal) o);
|
||||
}
|
||||
sumResultMap.put(itemKey + "_n", sumBigDecimal);
|
||||
// 薪资项目合计
|
||||
sumResultMap.put(itemKey, ReportDataUtil.thousandthConvert(sumBigDecimal.toString()));
|
||||
}
|
||||
// 薪资项目合计
|
||||
sumResultMap.put(itemKey, ReportDataUtil.thousandthConvert(sumBigDecimal.toString()));
|
||||
}
|
||||
}
|
||||
resultMap.put("sumRow", sumResultMap);
|
||||
|
|
@ -263,12 +278,12 @@ public class SalaryStatisticsEmployeeWrapper extends Service {
|
|||
// 合计
|
||||
List<Object> sumRow = new ArrayList<>();
|
||||
sumRow.add("总计");
|
||||
for (int i=1; i<columns.size(); i++) {
|
||||
for (int i = 1; i < columns.size(); i++) {
|
||||
sumRow.add(Util.null2String(countResult.get(columns.get(i).getColumn())));
|
||||
}
|
||||
rowList.add(sumRow);
|
||||
|
||||
return ExcelUtilPlus.genWorkbookV2(rowList,"薪资明细",true);
|
||||
return ExcelUtilPlus.genWorkbookV2(rowList, "薪资明细", true);
|
||||
}
|
||||
|
||||
// public Map<String, Object> exportDetailList(SalaryStatisticsEmployeeDetailQueryParam queryParam) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue