Merge remote-tracking branch 'remotes/origin/feature/v4-salaryExcelFormat-0328' into release/2.7.3.2304.01
# Conflicts: # src/com/engine/salary/service/SalaryAcctExcelService.java # src/com/engine/salary/service/impl/SalaryAcctExcelServiceImpl.java
This commit is contained in:
commit
521db08cde
|
|
@ -105,6 +105,9 @@ public interface SalaryAcctExcelService {
|
|||
|
||||
Map<String, Object> preview(SalaryAcctImportParam param);
|
||||
|
||||
Map<String, Object> previewImportSalaryAcctResult(SalaryAcctImportParam param);
|
||||
|
||||
|
||||
void cacheImportField(List<Long> salaryItems);
|
||||
|
||||
//
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ 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.excel.ExcelUtilPlus;
|
||||
import com.engine.salary.util.page.Column;
|
||||
import com.engine.salary.util.valid.ValidUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
|
|
@ -53,8 +54,11 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCell;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import weaver.file.ImageFileManager;
|
||||
import weaver.hrm.User;
|
||||
|
|
@ -165,8 +169,8 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
|
|||
// 3.表数据
|
||||
List<List<Object>> lists = convert2ExcelRow(salaryAcctEmployees);
|
||||
rows.addAll(lists);
|
||||
return ExcelUtil.genWorkbookV2(rows, sheetName);
|
||||
|
||||
// return ExcelUtil.genWorkbookV2(rows, sheetName);
|
||||
return ExcelUtilPlus.genWorkbookV2(rows, sheetName);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -198,8 +202,8 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
|
|||
// 3.表数据
|
||||
List<List<Object>> lists = convert2ExcelRow(salaryAcctEmployees);
|
||||
rows.addAll(lists);
|
||||
return ExcelUtil.genWorkbookV2(rows, sheetName);
|
||||
|
||||
// return ExcelUtil.genWorkbookV2(rows, sheetName);
|
||||
return ExcelUtilPlus.genWorkbookV2(rows, sheetName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -230,7 +234,8 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
|
|||
// 3.表数据
|
||||
List<List<Object>> lists = convert2ExcelRow(salaryAcctEmployees);
|
||||
rows.addAll(lists);
|
||||
return ExcelUtil.genWorkbookV2(rows, sheetName);
|
||||
// return ExcelUtil.genWorkbookV2(rows, sheetName);
|
||||
return ExcelUtilPlus.genWorkbookV2(rows, sheetName);
|
||||
}
|
||||
|
||||
private List<List<Object>> convert2ExcelRow(List<SalaryAcctEmployeePO> salaryAcctEmployees) {
|
||||
|
|
@ -279,11 +284,12 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
|
|||
// 查询列表的表头
|
||||
List<WeaTableColumnGroup> weaTableColumns = listWeaTableColumn(salaryAcctRecordPO);
|
||||
parseHeader(headerColumnGroup, weaTableColumns);
|
||||
// excel导出的表头
|
||||
String[] headers = headerColumnGroup.stream()
|
||||
.map(WeaTableColumn::getText)
|
||||
.toArray(String[]::new);
|
||||
List<Object> headerList = new ArrayList<>(Arrays.asList(headers));
|
||||
// // excel导出的表头
|
||||
// String[] headers = headerColumnGroup.stream()
|
||||
// .map(WeaTableColumn::getText)
|
||||
// .toArray(String[]::new);
|
||||
// List<Object> headerList = new ArrayList<>(Arrays.asList(headers));
|
||||
List<Object> headerList = new ArrayList<>(weaTableColumns);
|
||||
// 查询薪资核算结果
|
||||
List<Map<String, Object>> resultMapList = getSalaryAcctResultService(user).listByParam(queryParam);
|
||||
|
||||
|
|
@ -310,9 +316,11 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
|
|||
}
|
||||
|
||||
String sheetName = "薪资核算结果";
|
||||
return ExcelUtil.genWorkbookV2(rows, sheetName, total);
|
||||
// return ExcelUtil.genWorkbookV2(rows, sheetName, total);
|
||||
return ExcelUtilPlus.genWorkbookWithChildTitleColumn(rows, sheetName, total);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构建薪资核算结果列表的表头
|
||||
*
|
||||
|
|
@ -415,38 +423,86 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
|
|||
if (Objects.isNull(salaryAcctRecordPO)) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
|
||||
}
|
||||
// 模板表头(默认必带"个税扣缴义务人"、"姓名")
|
||||
List<Object> headerList = Lists.newArrayList(SalaryI18nUtil.getI18nLabel(85429, "姓名"),
|
||||
"部门",
|
||||
SalaryI18nUtil.getI18nLabel(86186, "手机号"),
|
||||
SalaryI18nUtil.getI18nLabel(86317, "工号"),
|
||||
SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"));
|
||||
List<String> dataIndexList = Lists.newArrayList("username", "departmentName", "mobile", "workcode", "taxAgentName");
|
||||
// // 模板表头(默认必带"个税扣缴义务人"、"姓名")
|
||||
// List<Object> headerList = Lists.newArrayList(SalaryI18nUtil.getI18nLabel(85429, "姓名"),
|
||||
// "部门",
|
||||
// SalaryI18nUtil.getI18nLabel(86186, "手机号"),
|
||||
// SalaryI18nUtil.getI18nLabel(86317, "工号"),
|
||||
// SalaryI18nUtil.getI18nLabel(86184, "个税扣缴义务人"));
|
||||
// List<String> dataIndexList = Lists.newArrayList("username", "departmentName", "mobile", "workcode", "taxAgentName");
|
||||
// // 查询薪资项目
|
||||
// List<SalaryItemPO> salaryItemPOS = getSalaryItemService(user).listByIds(param.getSalaryItemIds());
|
||||
// for (SalaryItemPO salaryItemPO : salaryItemPOS) {
|
||||
// headerList.add(salaryItemPO.getName());
|
||||
// dataIndexList.add("" + salaryItemPO.getId());
|
||||
// }
|
||||
//
|
||||
// // 查询薪资核算结果
|
||||
// List<Map<String, Object>> resultMapList = getSalaryAcctResultService(user).listByParam(param);
|
||||
// // excel导出的数据
|
||||
// List<List<Object>> rows = Lists.newArrayListWithExpectedSize(resultMapList.size());
|
||||
// rows.add(headerList);
|
||||
// for (Map<String, Object> map : resultMapList) {
|
||||
// List<Object> row = Lists.newArrayListWithExpectedSize(headerList.size());
|
||||
// for (String dataIndex : dataIndexList) {
|
||||
// row.add(map.getOrDefault(dataIndex, StringUtils.EMPTY));
|
||||
// }
|
||||
// rows.add(row);
|
||||
// }
|
||||
// return ExcelUtil.genWorkbookV2(rows, sheetName);
|
||||
|
||||
// 查询薪资项目
|
||||
List<Object> headerRangeList = new ArrayList<>();
|
||||
List<SalaryItemPO> salaryItemPOS = getSalaryItemService(user).listByIds(param.getSalaryItemIds());
|
||||
for (SalaryItemPO salaryItemPO : salaryItemPOS) {
|
||||
headerList.add(salaryItemPO.getName());
|
||||
dataIndexList.add("" + salaryItemPO.getId());
|
||||
headerRangeList.add(salaryItemPO.getId().toString());
|
||||
}
|
||||
headerRangeList.add("username");
|
||||
headerRangeList.add("mobile");
|
||||
headerRangeList.add("workcode");
|
||||
headerRangeList.add("taxAgentName");
|
||||
headerRangeList.add("departmentName");
|
||||
// 查询列表的表头
|
||||
List<WeaTableColumnGroup> weaTableColumns = listWeaTableColumn(salaryAcctRecordPO);
|
||||
List<WeaTableColumnGroup> finalWeaTableColumns = new ArrayList<>();
|
||||
for (WeaTableColumnGroup tableColumn : weaTableColumns) {
|
||||
WeaTableColumnGroup columnGroupItem = (WeaTableColumnGroup) tableColumn;
|
||||
if (columnGroupItem.getChildren() != null) {
|
||||
List<WeaTableColumnGroup> childrenColumns = columnGroupItem.getChildren().stream().filter(f -> headerRangeList.contains(f.getColumn())).collect(Collectors.toList());
|
||||
if (childrenColumns.size() > 0) {
|
||||
columnGroupItem.setChildren(childrenColumns);
|
||||
finalWeaTableColumns.add(columnGroupItem);
|
||||
}
|
||||
} else if (headerRangeList.contains(columnGroupItem.getColumn())) {
|
||||
finalWeaTableColumns.add(columnGroupItem);
|
||||
}
|
||||
|
||||
}
|
||||
// excel导出的表头
|
||||
List<WeaTableColumnGroup> headerColumnGroup = Lists.newArrayList();
|
||||
// 查询列表的表头
|
||||
parseHeader(headerColumnGroup, finalWeaTableColumns);
|
||||
|
||||
List<Object> headerList = new ArrayList<>(finalWeaTableColumns);
|
||||
// 查询薪资核算结果
|
||||
List<Map<String, Object>> resultMapList = getSalaryAcctResultService(user).listByParam(param);
|
||||
// excel导出的数据
|
||||
List<List<Object>> rows = Lists.newArrayListWithExpectedSize(resultMapList.size());
|
||||
List<List<Object>> rows = new ArrayList<>();
|
||||
rows.add(headerList);
|
||||
for (Map<String, Object> map : resultMapList) {
|
||||
List<Object> row = Lists.newArrayListWithExpectedSize(headerList.size());
|
||||
for (String dataIndex : dataIndexList) {
|
||||
row.add(map.getOrDefault(dataIndex, StringUtils.EMPTY));
|
||||
List<Object> row = Lists.newArrayListWithExpectedSize(headerColumnGroup.size());
|
||||
for (WeaTableColumnGroup weaTableColumn : headerColumnGroup) {
|
||||
row.add(map.getOrDefault(weaTableColumn.getColumn(), StringUtils.EMPTY));
|
||||
}
|
||||
rows.add(row);
|
||||
}
|
||||
|
||||
String sheetName = "薪资核算导入模板";
|
||||
return ExcelUtil.genWorkbookV2(rows, sheetName);
|
||||
return ExcelUtilPlus.genWorkbookWithChildTitleColumn(rows, sheetName, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public XSSFWorkbook exportComparisonResult(SalaryComparisonResultQueryParam queryParam) {
|
||||
ValidUtil.doValidator(queryParam);
|
||||
|
|
@ -501,7 +557,8 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
|
|||
|
||||
String sheetName = "线下对比结果";
|
||||
|
||||
return ExcelUtil.genWorkbookV2(rows, sheetName);
|
||||
// return ExcelUtil.genWorkbookV2(rows, sheetName);
|
||||
return ExcelUtilPlus.genWorkbookV2(rows, sheetName);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -549,7 +606,8 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
|
|||
rows.add(headerList);
|
||||
String sheetName = "线下对比结果导入模板";
|
||||
|
||||
return ExcelUtil.genWorkbookV2(rows, sheetName);
|
||||
// return ExcelUtil.genWorkbookV2(rows, sheetName);
|
||||
return ExcelUtilPlus.genWorkbookV2(rows, sheetName);
|
||||
}
|
||||
|
||||
public Map<String, Object> importSalaryAcctResult(SalaryAcctImportParam param) {
|
||||
|
|
@ -588,6 +646,27 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
|
|||
Util_DataCache.setObjVal(cacheKey, JsonUtil.toJsonString(salaryItems));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> previewImportSalaryAcctResult(SalaryAcctImportParam param) {
|
||||
|
||||
//1、参数校验
|
||||
ValidUtil.doValidator(param);
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
||||
InputStream fileInputStream = null;
|
||||
try {
|
||||
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(param.getImageId()));
|
||||
Sheet sheet = ExcelSupport.parseFile(fileInputStream, 0, EXCEL_TYPE_XLSX);
|
||||
map.put("headers", ExcelSupport.getSheetHeader(sheet, 1));
|
||||
map.put("list", ExcelParseHelper.parse2List(sheet, 2, 1));
|
||||
return map;
|
||||
|
||||
} finally {
|
||||
IOUtils.closeQuietly(fileInputStream);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Object> batchImport(SalaryAcctImportParam param, String importType) {
|
||||
Map<String, Object> apidatas = new HashMap<String, Object>();
|
||||
ValidUtil.doValidator(param);
|
||||
|
|
@ -661,10 +740,23 @@ public class SalaryAcctExcelServiceImpl extends Service implements SalaryAcctExc
|
|||
// 存在错误的那行数据
|
||||
List<Map<String, Object>> errorDatas = Lists.newArrayList();
|
||||
// 表头
|
||||
List<String> headers = ExcelSupport.getSheetHeader(sheet, 0);
|
||||
// List<String> headers = ExcelSupport.getSheetHeader(sheet, 0);
|
||||
List<String> headers;
|
||||
if (StringUtils.equals("importSalaryAcctResult", importType)) {
|
||||
headers = ExcelSupport.getSheetHeader(sheet, 1);
|
||||
} else {
|
||||
headers = ExcelSupport.getSheetHeader(sheet, 0);
|
||||
}
|
||||
|
||||
// 处理数值
|
||||
// List<Map<String, Object>> data = ExcelParseHelper.parse2Map(sheet, 1);
|
||||
List<Map<String, Object>> data;
|
||||
if (StringUtils.equals("importSalaryAcctResult", importType)) {
|
||||
data = ExcelParseHelper.parse2Map(sheet, 2, 1);
|
||||
} else {
|
||||
data = ExcelParseHelper.parse2Map(sheet, 1);
|
||||
}
|
||||
|
||||
// 处理数值
|
||||
List<Map<String, Object>> data = ExcelParseHelper.parse2Map(sheet, 1);
|
||||
if (CollectionUtils.isEmpty(headers)) {
|
||||
throw new RuntimeException("表头为空");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,10 +27,7 @@ import com.engine.salary.service.*;
|
|||
import com.engine.salary.util.SalaryEntityUtil;
|
||||
import com.engine.salary.util.SalaryI18nUtil;
|
||||
import com.engine.salary.util.db.MapperProxyFactory;
|
||||
import com.engine.salary.util.excel.ExcelComment;
|
||||
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.excel.*;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
@ -406,7 +403,8 @@ public class SalaryArchiveExcelServiceImpl extends Service implements SalaryArch
|
|||
// SalaryArchiveExcelBO.createExcelComment(excelComments, SalaryI18nUtil.getI18nLabel(109736, "格式样例为'2022-01-01'、'2022/1/1'"), 0, 0, i + 1, i + 1);
|
||||
}
|
||||
|
||||
return ExcelUtil.genWorkbookV2(rows, finalNameI18n, excelComments);
|
||||
// return ExcelUtil.genWorkbookV2(rows, finalNameI18n, excelComments);
|
||||
return ExcelUtilPlus.genWorkbookV2(rows, finalNameI18n, excelComments);
|
||||
}
|
||||
|
||||
// /**
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import com.engine.salary.util.db.MapperProxyFactory;
|
|||
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.excel.ExcelUtilPlus;
|
||||
import com.engine.salary.util.page.PageInfo;
|
||||
import com.engine.salary.util.page.SalaryPageUtil;
|
||||
import com.engine.salary.util.valid.ValidUtil;
|
||||
|
|
@ -520,7 +521,8 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe
|
|||
});
|
||||
// 3.表数据
|
||||
|
||||
return ExcelUtil.genWorkbookV2(rows, sheetName);
|
||||
// return ExcelUtil.genWorkbookV2(rows, sheetName);
|
||||
return ExcelUtilPlus.genWorkbookV2(rows, sheetName);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -174,6 +174,31 @@ public class ExcelParseHelper {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将sheet数据转为map
|
||||
*
|
||||
* @param rowIndex 从哪行开始解析
|
||||
* @param headerRowIndex 抽取列数的参考行
|
||||
* @return
|
||||
*/
|
||||
public static List<Map<String, Object>> parse2Map(Sheet sheet, int rowIndex, int headerRowIndex) {
|
||||
int rowCount = sheet.getPhysicalNumberOfRows(); // 总行数
|
||||
int cellCount = sheet.getRow(headerRowIndex).getPhysicalNumberOfCells(); // 总列数
|
||||
|
||||
List<String> sheetHeader = ExcelSupport.getSheetHeader(sheet, headerRowIndex);
|
||||
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
for (; rowIndex < rowCount; rowIndex++) {
|
||||
Map<String, Object> cellResult = new HashMap<>();
|
||||
for (int j = 0; j < cellCount; j++) {
|
||||
String key = sheetHeader.get(j);
|
||||
cellResult.put(key, ExcelSupport.getCellValue(sheet, rowIndex, j));
|
||||
}
|
||||
result.add(cellResult);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将sheet数据转为List
|
||||
*
|
||||
|
|
@ -195,6 +220,27 @@ public class ExcelParseHelper {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将sheet数据转为List
|
||||
* @param rowIndex 从哪行开始解析
|
||||
* @param headerRowIndex 抽取列数的参考行
|
||||
* @return
|
||||
*/
|
||||
public static List<List<String>> parse2List(Sheet sheet, int rowIndex, int headerRowIndex) {
|
||||
int rowCount = sheet.getPhysicalNumberOfRows(); // 总行数
|
||||
int cellCount = sheet.getRow(headerRowIndex).getPhysicalNumberOfCells(); // 总列数
|
||||
|
||||
List<List<String>> result = new ArrayList<List<String>>();
|
||||
for (; rowIndex < rowCount; rowIndex++) {
|
||||
List<String> cellResult = new ArrayList<String>();
|
||||
for (int j = 0; j < cellCount; j++) {
|
||||
cellResult.add(ExcelSupport.getCellValue(sheet, rowIndex, j));
|
||||
}
|
||||
result.add(cellResult);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 为对象的每一个属性赋值
|
||||
|
|
|
|||
|
|
@ -0,0 +1,532 @@
|
|||
package com.engine.salary.util.excel;
|
||||
|
||||
import com.engine.salary.component.WeaTableColumnGroup;
|
||||
import com.engine.salary.util.SalaryDateUtil;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.usermodel.*;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class ExcelUtilPlus {
|
||||
/**
|
||||
* 生成excel
|
||||
*
|
||||
* @param rowList
|
||||
* @return
|
||||
*/
|
||||
public static XSSFWorkbook genWorkbook(List<List<String>> rowList, String sheetName) {
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
|
||||
// 设置title样式
|
||||
XSSFCellStyle titleCellStyle = workbook.createCellStyle();
|
||||
XSSFFont titleFont = workbook.createFont();
|
||||
titleFont.setFontName("仿宋");
|
||||
titleFont.setFontHeightInPoints((short) 15);
|
||||
titleCellStyle.setFont(titleFont);
|
||||
titleCellStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
titleCellStyle.setFillForegroundColor(IndexedColors.GREEN.getIndex());//背景色
|
||||
titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
|
||||
|
||||
// 设置主体样式
|
||||
XSSFCellStyle cellStyle = workbook.createCellStyle();
|
||||
XSSFFont font = workbook.createFont();
|
||||
font.setFontName("宋体");
|
||||
font.setFontHeightInPoints((short) 10);// 设置字体大小
|
||||
cellStyle.setFont(font);// 选择需要用到的字体格式
|
||||
cellStyle.setWrapText(true);
|
||||
|
||||
XSSFSheet sheet = workbook.createSheet(sheetName);
|
||||
//自适应宽度
|
||||
sheet.autoSizeColumn(0, true);
|
||||
//默认列宽
|
||||
sheet.setDefaultColumnWidth(20);
|
||||
//默认行高
|
||||
sheet.setDefaultRowHeightInPoints(18);
|
||||
|
||||
for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) {
|
||||
List<String> infoList = rowList.get(rowIndex);
|
||||
XSSFRow row = sheet.createRow(rowIndex);
|
||||
for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) {
|
||||
XSSFCell cell = row.createCell(cellIndex);
|
||||
cell.setCellType(CellType.STRING);
|
||||
if (rowIndex == 0) {
|
||||
cell.setCellStyle(titleCellStyle);
|
||||
} else {
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
cell.setCellValue(infoList.get(cellIndex));
|
||||
// sheet.setColumnWidth(cellIndex, 35 * 256);
|
||||
}
|
||||
}
|
||||
return workbook;
|
||||
}
|
||||
|
||||
|
||||
public static XSSFWorkbook genWorkbookV2(List<List<Object>> rowList, String sheetName) {
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
|
||||
// 设置title样式
|
||||
XSSFCellStyle titleCellStyle = workbook.createCellStyle();
|
||||
XSSFFont titleFont = workbook.createFont();
|
||||
titleFont.setBold(true);
|
||||
titleFont.setFontName("仿宋");
|
||||
titleFont.setFontHeightInPoints((short) 15);
|
||||
titleCellStyle.setFont(titleFont);
|
||||
titleCellStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
titleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色
|
||||
titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
titleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
titleCellStyle.setBorderLeft(BorderStyle.THIN);
|
||||
titleCellStyle.setBorderRight(BorderStyle.THIN);
|
||||
titleCellStyle.setBorderTop(BorderStyle.THIN);
|
||||
titleCellStyle.setBorderBottom(BorderStyle.THIN);
|
||||
|
||||
|
||||
// 设置主体样式
|
||||
XSSFCellStyle cellStyle = workbook.createCellStyle();
|
||||
XSSFFont font = workbook.createFont();
|
||||
font.setFontName("宋体");
|
||||
font.setFontHeightInPoints((short) 10);// 设置字体大小
|
||||
cellStyle.setFont(font);// 选择需要用到的字体格式
|
||||
cellStyle.setWrapText(true);
|
||||
cellStyle.setBorderLeft(BorderStyle.THIN);
|
||||
cellStyle.setBorderRight(BorderStyle.THIN);
|
||||
cellStyle.setBorderTop(BorderStyle.THIN);
|
||||
cellStyle.setBorderBottom(BorderStyle.THIN);
|
||||
|
||||
XSSFSheet sheet = workbook.createSheet(sheetName);
|
||||
//自适应宽度
|
||||
sheet.autoSizeColumn(0, true);
|
||||
//默认列宽
|
||||
sheet.setDefaultColumnWidth(20);
|
||||
//默认行高
|
||||
sheet.setDefaultRowHeightInPoints(18);
|
||||
//遍历设置列宽
|
||||
List<Object> header = rowList.get(0);
|
||||
for (int i = 0; i < header.size(); i++) {
|
||||
sheet.setColumnWidth(i,Math.max(12, header.get(i).toString().length()*4)*256);
|
||||
}
|
||||
|
||||
for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) {
|
||||
List<Object> infoList = rowList.get(rowIndex);
|
||||
XSSFRow row = sheet.createRow(rowIndex);
|
||||
float height = 18;
|
||||
float finalHeight = 18;
|
||||
|
||||
for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) {
|
||||
XSSFCell cell = row.createCell(cellIndex);
|
||||
if (rowIndex == 0) {
|
||||
cell.setCellStyle(titleCellStyle);
|
||||
} else {
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
Object o = infoList.get(cellIndex);
|
||||
if (o instanceof String) {
|
||||
cell.setCellType(CellType.STRING);
|
||||
cell.setCellValue(String.valueOf(o));
|
||||
} else if (o instanceof Boolean) {
|
||||
cell.setCellType(CellType.BOOLEAN);
|
||||
cell.setCellValue(String.valueOf(o));
|
||||
} else if (o instanceof Date) {
|
||||
cell.setCellType(CellType.STRING);
|
||||
cell.setCellValue(SalaryDateUtil.getFormatLocalDate((Date) o));
|
||||
} else {
|
||||
cell.setCellType(CellType.STRING);
|
||||
cell.setCellValue(o == null ? "" : o.toString());
|
||||
}
|
||||
|
||||
//判断是否要调整高度
|
||||
int width = sheet.getColumnWidth(cellIndex) / 256;
|
||||
finalHeight = getFinalHeight(o, width, finalHeight, height);
|
||||
}
|
||||
row.setHeightInPoints(finalHeight);
|
||||
}
|
||||
return workbook;
|
||||
}
|
||||
|
||||
|
||||
public static XSSFWorkbook genWorkbookV2(List<List<Object>> rowList, String sheetName, List<ExcelComment> comments) {
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
|
||||
// 设置title样式
|
||||
XSSFCellStyle titleCellStyle = workbook.createCellStyle();
|
||||
XSSFFont titleFont = workbook.createFont();
|
||||
titleFont.setBold(true);
|
||||
titleFont.setFontName("仿宋");
|
||||
titleFont.setFontHeightInPoints((short) 15);
|
||||
titleCellStyle.setFont(titleFont);
|
||||
titleCellStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
titleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色
|
||||
titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
titleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
titleCellStyle.setBorderLeft(BorderStyle.THIN);
|
||||
titleCellStyle.setBorderRight(BorderStyle.THIN);
|
||||
titleCellStyle.setBorderTop(BorderStyle.THIN);
|
||||
titleCellStyle.setBorderBottom(BorderStyle.THIN);
|
||||
|
||||
|
||||
// 设置主体样式
|
||||
XSSFCellStyle cellStyle = workbook.createCellStyle();
|
||||
XSSFFont font = workbook.createFont();
|
||||
font.setFontName("宋体");
|
||||
font.setFontHeightInPoints((short) 10);// 设置字体大小
|
||||
cellStyle.setFont(font);// 选择需要用到的字体格式
|
||||
cellStyle.setWrapText(true);
|
||||
cellStyle.setBorderLeft(BorderStyle.THIN);
|
||||
cellStyle.setBorderRight(BorderStyle.THIN);
|
||||
cellStyle.setBorderTop(BorderStyle.THIN);
|
||||
cellStyle.setBorderBottom(BorderStyle.THIN);
|
||||
|
||||
XSSFSheet sheet = workbook.createSheet(sheetName);
|
||||
//自适应宽度
|
||||
sheet.autoSizeColumn(0, true);
|
||||
//默认列宽
|
||||
sheet.setDefaultColumnWidth(20);
|
||||
//默认行高
|
||||
sheet.setDefaultRowHeightInPoints(18);
|
||||
|
||||
//遍历设置列宽
|
||||
List<Object> header = rowList.get(0);
|
||||
for (int i = 0; i < header.size(); i++) {
|
||||
sheet.setColumnWidth(i,Math.max(12, header.get(i).toString().length()*4)*256);
|
||||
}
|
||||
|
||||
for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) {
|
||||
List<Object> infoList = rowList.get(rowIndex);
|
||||
XSSFRow row = sheet.createRow(rowIndex);
|
||||
float height = 18;
|
||||
float finalHeight = 18;
|
||||
|
||||
for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) {
|
||||
XSSFCell cell = row.createCell(cellIndex);
|
||||
if (rowIndex == 0) {
|
||||
cell.setCellStyle(titleCellStyle);
|
||||
} else {
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
Object o = infoList.get(cellIndex);
|
||||
if (o instanceof String) {
|
||||
cell.setCellType(CellType.STRING);
|
||||
cell.setCellValue(String.valueOf(o));
|
||||
} else if (o instanceof Boolean) {
|
||||
cell.setCellType(CellType.BOOLEAN);
|
||||
cell.setCellValue(String.valueOf(o));
|
||||
} else if (o instanceof Date) {
|
||||
cell.setCellType(CellType.STRING);
|
||||
cell.setCellValue(SalaryDateUtil.getFormatLocalDate((Date) o));
|
||||
} else {
|
||||
cell.setCellType(CellType.STRING);
|
||||
cell.setCellValue(String.valueOf(o));
|
||||
}
|
||||
|
||||
//判断是否要调整高度
|
||||
int width = sheet.getColumnWidth(cellIndex) / 256;
|
||||
finalHeight = getFinalHeight(o, width, finalHeight, height);
|
||||
}
|
||||
row.setHeightInPoints(finalHeight);
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(comments)) {
|
||||
for (ExcelComment c : comments) {
|
||||
XSSFDrawing patr = sheet.createDrawingPatriarch();
|
||||
XSSFComment cellComment = patr.createCellComment(new XSSFClientAnchor(c.dx1, c.dy1, c.dx2, c.dy2, c.col1, c.row1, c.col2, c.row2));
|
||||
cellComment.setString(c.content);
|
||||
}
|
||||
}
|
||||
return workbook;
|
||||
}
|
||||
|
||||
public static XSSFWorkbook genWorkbookV2(List<List<Object>> rowList, String sheetName, boolean lastRowRed) {
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
|
||||
// 设置title样式
|
||||
XSSFCellStyle titleCellStyle = workbook.createCellStyle();
|
||||
XSSFFont titleFont = workbook.createFont();
|
||||
titleFont.setBold(true);
|
||||
titleFont.setFontName("仿宋");
|
||||
titleFont.setFontHeightInPoints((short) 15);
|
||||
titleCellStyle.setFont(titleFont);
|
||||
titleCellStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
titleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色
|
||||
titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
titleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
titleCellStyle.setBorderLeft(BorderStyle.THIN);
|
||||
titleCellStyle.setBorderRight(BorderStyle.THIN);
|
||||
titleCellStyle.setBorderTop(BorderStyle.THIN);
|
||||
titleCellStyle.setBorderBottom(BorderStyle.THIN);
|
||||
|
||||
// 设置主体样式
|
||||
XSSFCellStyle cellStyle = workbook.createCellStyle();
|
||||
XSSFFont font = workbook.createFont();
|
||||
font.setFontName("宋体");
|
||||
font.setFontHeightInPoints((short) 10);// 设置字体大小
|
||||
cellStyle.setFont(font);// 选择需要用到的字体格式
|
||||
cellStyle.setWrapText(true);
|
||||
|
||||
cellStyle.setBorderLeft(BorderStyle.THIN);
|
||||
cellStyle.setBorderRight(BorderStyle.THIN);
|
||||
cellStyle.setBorderTop(BorderStyle.THIN);
|
||||
cellStyle.setBorderBottom(BorderStyle.THIN);
|
||||
|
||||
XSSFCellStyle redCellStyle = workbook.createCellStyle();
|
||||
XSSFFont redFont = workbook.createFont();
|
||||
redFont.setFontName("宋体");
|
||||
redFont.setFontHeightInPoints((short) 10);// 设置字体大小
|
||||
redFont.setColor(new XSSFColor(new Color(0xFF3333), null));
|
||||
redFont.setBold(true);
|
||||
redCellStyle.setWrapText(true);
|
||||
redCellStyle.setFont(redFont);// 选择需要用到的字体格式
|
||||
|
||||
redCellStyle.setBorderLeft(BorderStyle.THIN);
|
||||
redCellStyle.setBorderRight(BorderStyle.THIN);
|
||||
redCellStyle.setBorderTop(BorderStyle.THIN);
|
||||
redCellStyle.setBorderBottom(BorderStyle.THIN);
|
||||
|
||||
XSSFSheet sheet = workbook.createSheet(sheetName);
|
||||
//自适应宽度
|
||||
sheet.autoSizeColumn(0, true);
|
||||
//默认列宽
|
||||
sheet.setDefaultColumnWidth(20);
|
||||
//默认行高
|
||||
sheet.setDefaultRowHeightInPoints(18);
|
||||
|
||||
//遍历设置列宽
|
||||
List<Object> header = rowList.get(0);
|
||||
for (int i = 0; i < header.size(); i++) {
|
||||
sheet.setColumnWidth(i,Math.max(12, header.get(i).toString().length()*4)*256);
|
||||
}
|
||||
|
||||
for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) {
|
||||
List<Object> infoList = rowList.get(rowIndex);
|
||||
XSSFRow row = sheet.createRow(rowIndex);
|
||||
float height = 18;
|
||||
float finalHeight = 18;
|
||||
|
||||
for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) {
|
||||
XSSFCell cell = row.createCell(cellIndex);
|
||||
if (rowIndex == 0) {
|
||||
cell.setCellStyle(titleCellStyle);
|
||||
} else {
|
||||
if (lastRowRed && rowIndex == rowList.size() - 1) {
|
||||
cell.setCellStyle(redCellStyle);
|
||||
} else {
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
}
|
||||
Object o = infoList.get(cellIndex);
|
||||
if (o instanceof String) {
|
||||
cell.setCellType(CellType.STRING);
|
||||
cell.setCellValue(String.valueOf(o));
|
||||
} else if (o instanceof Boolean) {
|
||||
cell.setCellType(CellType.BOOLEAN);
|
||||
cell.setCellValue(String.valueOf(o));
|
||||
} else if (o instanceof Date) {
|
||||
cell.setCellType(CellType.STRING);
|
||||
cell.setCellValue(SalaryDateUtil.getFormatLocalDate((Date) o));
|
||||
} else {
|
||||
cell.setCellType(CellType.STRING);
|
||||
cell.setCellValue(o == null ? "" : o.toString());
|
||||
}
|
||||
|
||||
//判断是否要调整高度
|
||||
int width = sheet.getColumnWidth(cellIndex) / 256;
|
||||
finalHeight = getFinalHeight(o, width, finalHeight, height);
|
||||
}
|
||||
row.setHeightInPoints(finalHeight);
|
||||
}
|
||||
return workbook;
|
||||
}
|
||||
|
||||
public static XSSFWorkbook genWorkbookWithChildTitleColumn(List<List<Object>> rowList, String sheetName, boolean lastRowRed) {
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
|
||||
// 设置title样式
|
||||
XSSFCellStyle titleCellStyle = workbook.createCellStyle();
|
||||
XSSFFont titleFont = workbook.createFont();
|
||||
titleFont.setBold(true);
|
||||
titleFont.setFontName("仿宋");
|
||||
titleFont.setFontHeightInPoints((short) 15);
|
||||
titleCellStyle.setFont(titleFont);
|
||||
titleCellStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
titleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色
|
||||
titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
titleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
titleCellStyle.setBorderLeft(BorderStyle.THIN);
|
||||
titleCellStyle.setBorderRight(BorderStyle.THIN);
|
||||
titleCellStyle.setBorderTop(BorderStyle.THIN);
|
||||
titleCellStyle.setBorderBottom(BorderStyle.THIN);
|
||||
|
||||
XSSFCellStyle childTitleCellStyle = workbook.createCellStyle();
|
||||
childTitleCellStyle.setFont(titleFont);
|
||||
childTitleCellStyle.setAlignment(HorizontalAlignment.LEFT);
|
||||
childTitleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色
|
||||
childTitleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
childTitleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
childTitleCellStyle.setBorderLeft(BorderStyle.THIN);
|
||||
childTitleCellStyle.setBorderRight(BorderStyle.THIN);
|
||||
childTitleCellStyle.setBorderTop(BorderStyle.THIN);
|
||||
childTitleCellStyle.setBorderBottom(BorderStyle.THIN);
|
||||
|
||||
|
||||
|
||||
// 设置主体样式
|
||||
XSSFCellStyle cellStyle = workbook.createCellStyle();
|
||||
XSSFFont font = workbook.createFont();
|
||||
font.setFontName("宋体");
|
||||
font.setFontHeightInPoints((short) 10);// 设置字体大小
|
||||
cellStyle.setFont(font);// 选择需要用到的字体格式
|
||||
cellStyle.setWrapText(true);
|
||||
|
||||
cellStyle.setBorderLeft(BorderStyle.THIN);
|
||||
cellStyle.setBorderRight(BorderStyle.THIN);
|
||||
cellStyle.setBorderTop(BorderStyle.THIN);
|
||||
cellStyle.setBorderBottom(BorderStyle.THIN);
|
||||
|
||||
XSSFCellStyle redCellStyle = workbook.createCellStyle();
|
||||
XSSFFont redFont = workbook.createFont();
|
||||
redFont.setFontName("宋体");
|
||||
redFont.setFontHeightInPoints((short) 10);// 设置字体大小
|
||||
redFont.setColor(new XSSFColor(new Color(0xFF3333), null));
|
||||
redFont.setBold(true);
|
||||
redCellStyle.setWrapText(true);
|
||||
redCellStyle.setFont(redFont);// 选择需要用到的字体格式
|
||||
|
||||
redCellStyle.setBorderLeft(BorderStyle.THIN);
|
||||
redCellStyle.setBorderRight(BorderStyle.THIN);
|
||||
redCellStyle.setBorderTop(BorderStyle.THIN);
|
||||
redCellStyle.setBorderBottom(BorderStyle.THIN);
|
||||
|
||||
XSSFSheet sheet = workbook.createSheet(sheetName);
|
||||
//自适应宽度
|
||||
sheet.autoSizeColumn(0, true);
|
||||
//默认列宽
|
||||
sheet.setDefaultColumnWidth(20);
|
||||
//默认行高
|
||||
sheet.setDefaultRowHeightInPoints(18);
|
||||
|
||||
//处理合并单元格
|
||||
XSSFRow row0 = sheet.createRow(0);
|
||||
XSSFRow row1 = sheet.createRow(1);
|
||||
|
||||
List<Object> header = rowList.get(0);
|
||||
int startIndex = 0;
|
||||
for (int i = 0; i < header.size(); i++) {
|
||||
WeaTableColumnGroup columnGroupItem = (WeaTableColumnGroup) header.get(i);
|
||||
if (columnGroupItem.getChildren() == null) {
|
||||
sheet.addMergedRegion(new CellRangeAddress(0, 1, startIndex, startIndex));
|
||||
|
||||
XSSFCell rowZeroCell = row0.createCell(startIndex, CellType.STRING);
|
||||
rowZeroCell.setCellValue(columnGroupItem.getText().toString());
|
||||
rowZeroCell.setCellStyle(titleCellStyle);
|
||||
XSSFCell rowOneCell = row1.createCell(startIndex, CellType.STRING);
|
||||
rowOneCell.setCellValue(columnGroupItem.getText().toString());
|
||||
rowOneCell.setCellStyle(titleCellStyle);
|
||||
//设置列宽
|
||||
sheet.setColumnWidth(startIndex,Math.max(12, columnGroupItem.getText().length()*4)*256);
|
||||
startIndex++;
|
||||
} else {
|
||||
List<WeaTableColumnGroup> childrenList = columnGroupItem.getChildren();
|
||||
int endIndex = startIndex + childrenList.size() - 1;
|
||||
|
||||
if (endIndex > startIndex) {
|
||||
sheet.addMergedRegion(new CellRangeAddress(0, 0, startIndex, endIndex));
|
||||
}
|
||||
|
||||
XSSFCell cell = row0.createCell(startIndex, CellType.STRING);
|
||||
cell.setCellValue(columnGroupItem.getText().toString());
|
||||
cell.setCellStyle(childTitleCellStyle);
|
||||
|
||||
for (int j = 0; j < childrenList.size(); j++) {
|
||||
WeaTableColumnGroup childrenItem = (WeaTableColumnGroup) childrenList.get(j);
|
||||
|
||||
XSSFCell subHeader = row1.createCell(startIndex + j, CellType.STRING);
|
||||
subHeader.setCellValue(childrenItem.getText().toString());
|
||||
subHeader.setCellStyle(titleCellStyle);
|
||||
//设置列宽
|
||||
sheet.setColumnWidth(startIndex + j,Math.max(12, childrenItem.getText().length()*4)*256);
|
||||
}
|
||||
|
||||
startIndex += childrenList.size();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (int rowIndex = 1; rowIndex < rowList.size(); rowIndex++) {
|
||||
List<Object> infoList = rowList.get(rowIndex);
|
||||
XSSFRow row = sheet.createRow(rowIndex + 1);
|
||||
float height = 18;
|
||||
float finalHeight = 18;
|
||||
|
||||
for (int cellIndex = 0; cellIndex < infoList.size(); cellIndex++) {
|
||||
XSSFCell cell = row.createCell(cellIndex);
|
||||
|
||||
if (rowIndex == 0) {
|
||||
cell.setCellStyle(titleCellStyle);
|
||||
} else {
|
||||
if (lastRowRed && rowIndex == rowList.size() - 1) {
|
||||
cell.setCellStyle(redCellStyle);
|
||||
} else {
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
}
|
||||
Object o = infoList.get(cellIndex);
|
||||
if (o instanceof String) {
|
||||
cell.setCellType(CellType.STRING);
|
||||
cell.setCellValue(String.valueOf(o));
|
||||
} else if (o instanceof Boolean) {
|
||||
cell.setCellType(CellType.BOOLEAN);
|
||||
cell.setCellValue(String.valueOf(o));
|
||||
} else if (o instanceof Date) {
|
||||
cell.setCellType(CellType.STRING);
|
||||
cell.setCellValue(SalaryDateUtil.getFormatLocalDate((Date) o));
|
||||
} else {
|
||||
cell.setCellType(CellType.STRING);
|
||||
cell.setCellValue(o == null ? "" : o.toString());
|
||||
}
|
||||
|
||||
//判断是否要调整高度
|
||||
int width = sheet.getColumnWidth(cellIndex) / 256;
|
||||
finalHeight = getFinalHeight(o, width, finalHeight, height);
|
||||
}
|
||||
row.setHeightInPoints(finalHeight);
|
||||
}
|
||||
return workbook;
|
||||
}
|
||||
|
||||
public static float getFinalHeight(Object o, int width, float finalHeight, float height) {
|
||||
if (o != null && getStrlength(o.toString()) > width) {
|
||||
float remainder = getStrlength(o.toString()) % width;
|
||||
int multiple = getStrlength(o.toString()) / width;
|
||||
int finalMultiple = remainder > 0 ? (multiple + 1) : multiple;
|
||||
float compareHeight = height * finalMultiple;
|
||||
finalHeight = Math.max(finalHeight, compareHeight);
|
||||
}
|
||||
return finalHeight;
|
||||
}
|
||||
|
||||
public static int getStrlength(String str) {
|
||||
int strLength = 0;
|
||||
String chinese = "[\u0391-\uFFE5]";
|
||||
/* 获取字段值的长度,如果含中文字符,则每个中文字符长度为2,否则为1 */
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
/* 从字符串中获取一个字符 */
|
||||
String temp = str.substring(i, i + 1);
|
||||
/* 判断是否为中文字符 */
|
||||
if (temp.matches(chinese)) {
|
||||
/* 中文字符长度为2 */
|
||||
strLength += 2;
|
||||
} else {
|
||||
/* 其他字符长度为1 */
|
||||
strLength += 1;
|
||||
}
|
||||
}
|
||||
return strLength;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -547,7 +547,7 @@ public class SalaryAcctController {
|
|||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String importSalaryAcctResultPreview(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctImportParam param) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return new ResponseResult<SalaryAcctImportParam, Map<String, Object>>(user).run(getSalaryAcctExcelService(user)::preview, param);
|
||||
return new ResponseResult<SalaryAcctImportParam, Map<String, Object>>(user).run(getSalaryAcctExcelService(user)::previewImportSalaryAcctResult, param);
|
||||
}
|
||||
|
||||
// **********************************薪资核算结果 end*********************************/
|
||||
|
|
|
|||
Loading…
Reference in New Issue