|
@@ -34,9 +34,12 @@ public class ExcelStyleHandler implements CellWriteHandler {
|
|
|
/** 总数据行数 */
|
|
/** 总数据行数 */
|
|
|
private int totalRows = 0;
|
|
private int totalRows = 0;
|
|
|
|
|
|
|
|
|
|
+ private int fileType;
|
|
|
|
|
+
|
|
|
/** 每行数据列数(根据实际Excel模板列数调整) */
|
|
/** 每行数据列数(根据实际Excel模板列数调整) */
|
|
|
private static final int TOTAL_COLUMNS = 18;
|
|
private static final int TOTAL_COLUMNS = 18;
|
|
|
|
|
|
|
|
|
|
+ private static final int TOTAL_COLUMNS2 = 16;
|
|
|
/** 是否已经执行过合并 */
|
|
/** 是否已经执行过合并 */
|
|
|
private boolean mergeCompleted = false;
|
|
private boolean mergeCompleted = false;
|
|
|
|
|
|
|
@@ -44,8 +47,9 @@ public class ExcelStyleHandler implements CellWriteHandler {
|
|
|
this.templateRowIndex = templateRowIndex;
|
|
this.templateRowIndex = templateRowIndex;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public ExcelStyleHandler(List<TouristExportVisitorVO> visitorList) {
|
|
|
|
|
|
|
+ public ExcelStyleHandler(List<TouristExportVisitorVO> visitorList, int fileType) {
|
|
|
this.visitorList = visitorList;
|
|
this.visitorList = visitorList;
|
|
|
|
|
+ this.fileType = fileType;
|
|
|
this.totalRows = visitorList != null ? visitorList.size() : 0;
|
|
this.totalRows = visitorList != null ? visitorList.size() : 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -200,9 +204,14 @@ public class ExcelStyleHandler implements CellWriteHandler {
|
|
|
// 统计处理的单元格数量
|
|
// 统计处理的单元格数量
|
|
|
processedCellCount++;
|
|
processedCellCount++;
|
|
|
|
|
|
|
|
- System.out.println("processedCellCount: " + processedCellCount);
|
|
|
|
|
|
|
+ int totalCells = 0;
|
|
|
// 当最后一个单元格写入完成后,执行合并
|
|
// 当最后一个单元格写入完成后,执行合并
|
|
|
- int totalCells = totalRows * TOTAL_COLUMNS;
|
|
|
|
|
|
|
+ if(fileType == 1) {
|
|
|
|
|
+ totalCells = totalRows * TOTAL_COLUMNS;
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+ totalCells = totalRows * TOTAL_COLUMNS2;
|
|
|
|
|
+ }
|
|
|
if (!mergeCompleted && processedCellCount >= totalCells) {
|
|
if (!mergeCompleted && processedCellCount >= totalCells) {
|
|
|
mergeCompleted = true;
|
|
mergeCompleted = true;
|
|
|
performMerge(context.getWriteSheetHolder().getSheet());
|
|
performMerge(context.getWriteSheetHolder().getSheet());
|
|
@@ -250,10 +259,12 @@ public class ExcelStyleHandler implements CellWriteHandler {
|
|
|
mergeCell(sheet, currentRowIndex, preRowIndex, 5, 5);
|
|
mergeCell(sheet, currentRowIndex, preRowIndex, 5, 5);
|
|
|
// 应收款列(第5列)
|
|
// 应收款列(第5列)
|
|
|
mergeCell(sheet, currentRowIndex, preRowIndex, 6, 6);
|
|
mergeCell(sheet, currentRowIndex, preRowIndex, 6, 6);
|
|
|
- // 实收款列(第6列)
|
|
|
|
|
- mergeCell(sheet, currentRowIndex, preRowIndex, 7, 7);
|
|
|
|
|
- // 定金列(第7列)
|
|
|
|
|
- mergeCell(sheet, currentRowIndex, preRowIndex, 8, 8);
|
|
|
|
|
|
|
+ if (fileType == 1) {
|
|
|
|
|
+ // 实收款列(第6列)
|
|
|
|
|
+ mergeCell(sheet, currentRowIndex, preRowIndex, 7, 7);
|
|
|
|
|
+ // 定金列(第7列)
|
|
|
|
|
+ mergeCell(sheet, currentRowIndex, preRowIndex, 8, 8);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// ===== 第8-10列(房间信息):按 roomIndexId 合并(同一订单内) =====
|
|
// ===== 第8-10列(房间信息):按 roomIndexId 合并(同一订单内) =====
|
|
@@ -262,12 +273,20 @@ public class ExcelStyleHandler implements CellWriteHandler {
|
|
|
if (currentRoomIndex.equals(preRoomIndex)
|
|
if (currentRoomIndex.equals(preRoomIndex)
|
|
|
&& currentVisitor.getOrderNo() != null
|
|
&& currentVisitor.getOrderNo() != null
|
|
|
&& currentVisitor.getOrderNo().equals(preVisitor.getOrderNo())) {
|
|
&& currentVisitor.getOrderNo().equals(preVisitor.getOrderNo())) {
|
|
|
- // 序号列(第8列)
|
|
|
|
|
- mergeCell(sheet, currentRowIndex, preRowIndex, 9, 9);
|
|
|
|
|
- // 房型列(第9列)
|
|
|
|
|
- mergeCell(sheet, currentRowIndex, preRowIndex, 10, 10);
|
|
|
|
|
- // 入住类型列(第10列)
|
|
|
|
|
- mergeCell(sheet, currentRowIndex, preRowIndex, 11, 11);
|
|
|
|
|
|
|
+ if (fileType == 1) {
|
|
|
|
|
+ // 序号列(第8列)
|
|
|
|
|
+ mergeCell(sheet, currentRowIndex, preRowIndex, 9, 9);
|
|
|
|
|
+ // 房型列(第9列)
|
|
|
|
|
+ mergeCell(sheet, currentRowIndex, preRowIndex, 10, 10);
|
|
|
|
|
+ // 入住类型列(第10列)
|
|
|
|
|
+ mergeCell(sheet, currentRowIndex, preRowIndex, 11, 11);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ mergeCell(sheet, currentRowIndex, preRowIndex, 7, 7);
|
|
|
|
|
+ // 房型列(第9列)
|
|
|
|
|
+ mergeCell(sheet, currentRowIndex, preRowIndex, 8, 8);
|
|
|
|
|
+ // 入住类型列(第10列)
|
|
|
|
|
+ mergeCell(sheet, currentRowIndex, preRowIndex, 9, 9);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|