处理报表导出异常

This commit is contained in:
钱涛 2024-10-23 17:41:28 +08:00
parent b5e6059298
commit e3c6b08e6f
2 changed files with 7 additions and 10 deletions

View File

@ -34,7 +34,6 @@ 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.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@ -437,14 +436,11 @@ public class SalaryStatisticsReportWrapper extends Service {
// 获取列头
List<WeaTableColumnGroup> weaTableColumns = (List<WeaTableColumnGroup>) result.get("columns");
PageInfo<Map<String, Object>> page = (PageInfo<Map<String, Object>>) result.get("pageInfo");
// 组装合计
Map<String, Object> countResultMap = SalaryStatisticsReportBO.buildTotal(page, salaryStatisticsItemList, (long) user.getUID());
Map<String, Object> countResultMap = (Map<String, Object>) result.get("countResult");
List<Map<String, Object>> list = page.getList();
if (CollectionUtils.isNotEmpty(list) && MapUtils.isNotEmpty(countResultMap)) {
list.add(countResultMap);
}
// 获取数据
List<Map<String, String>> records = list.stream().map(m -> m.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue() + StringUtils.EMPTY))).collect(Collectors.toList());
List<Map<String, Object>> records = list.stream().map(m -> m.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue()))).collect(Collectors.toList());
records.add(countResultMap);
List rows = new ArrayList<>();
rows.add(weaTableColumns);
@ -466,7 +462,7 @@ public class SalaryStatisticsReportWrapper extends Service {
List<String> numberItemIds = salaryItemPOList.stream().filter(item -> item.getDataType().equals(SalaryDataTypeEnum.NUMBER.getValue())).map(salaryItemPO -> salaryItemPO.getId().toString()).collect(Collectors.toList());
Map<String, SalaryStatisticsItemPO> salaryStatisticsItemMap = SalaryEntityUtil.convert2Map(salaryStatisticsItemList, statisticsItemPO -> statisticsItemPO.getId().toString());
for (Map<String, String> map : records) {
for (Map<String, Object> map : records) {
List<Object> row = Lists.newArrayListWithExpectedSize(records.size());
head.forEach(k -> {
// 获取是数值还是文本
@ -476,7 +472,7 @@ public class SalaryStatisticsReportWrapper extends Service {
SalaryStatisticsItemPO salaryStatisticsItemPO = salaryStatisticsItemMap.get(salaryItemId);
if (salaryStatisticsItemPO != null) {
Optional<String> textItemOptional = Arrays.stream(salaryStatisticsItemPO.getItemValue().split(",")).filter(itemId -> !numberItemIds.contains(itemId)).findFirst();
row.add((!textItemOptional.isPresent() && NumberUtils.isCreatable(map.getOrDefault(k, StringUtils.EMPTY).replace(",", ""))) ? new BigDecimal(map.get(k).replace(",", "")) : map.getOrDefault(k, StringUtils.EMPTY));
row.add((!textItemOptional.isPresent() && NumberUtils.isCreatable(Utils.null2String(map.get(k)))) ? new BigDecimal(Utils.null2String(map.get(k))) : map.getOrDefault(k, StringUtils.EMPTY));
} else {
row.add(map.getOrDefault(k, StringUtils.EMPTY));
}

View File

@ -38,6 +38,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.User;
import java.util.*;
@ -452,7 +453,7 @@ public class SalaryEmployeeServiceImpl extends Service implements SalaryEmployee
String field = setting.getField();
String value = rs.getString(field);
setting.setValue(value);
extendData.put(field, value);
extendData.put(field, Util.formatMultiLang(value));
});
String id = rs.getString(primaryKey);