统计数据导出
This commit is contained in:
@@ -30,10 +30,7 @@
|
||||
<groupId>com.mybatis-flex</groupId>
|
||||
<artifactId>mybatis-flex-processor</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud.excel</groupId>
|
||||
<artifactId>excel-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo-spring-boot-starter</artifactId>
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.czg.account.vo;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelIgnore;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import cn.idev.excel.annotation.write.style.ColumnWidth;
|
||||
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.pig4cloud.plugin.excel.annotation.ExcelLine;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
@@ -26,7 +25,6 @@ public class HandoverProductListVo implements Serializable {
|
||||
/**
|
||||
* 导入时候回显行号
|
||||
*/
|
||||
@ExcelLine
|
||||
@ExcelIgnore
|
||||
@JSONField(serialize = false)
|
||||
private Long lineNum;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.czg.order.entity;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelIgnore;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import cn.idev.excel.annotation.write.style.ColumnWidth;
|
||||
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
@@ -59,42 +59,42 @@ public class ShopProdStatistic implements Serializable {
|
||||
* 销售数量
|
||||
*/
|
||||
@ExcelProperty("销量")
|
||||
@ColumnWidth(5)
|
||||
@ColumnWidth(15)
|
||||
private BigDecimal saleCount;
|
||||
|
||||
/**
|
||||
* 销售金额
|
||||
*/
|
||||
@ExcelProperty("销售金额")
|
||||
@ColumnWidth(7)
|
||||
@ColumnWidth(15)
|
||||
private BigDecimal saleAmount;
|
||||
|
||||
/**
|
||||
* 退单量
|
||||
*/
|
||||
@ExcelProperty("退单量")
|
||||
@ColumnWidth(5)
|
||||
@ColumnWidth(15)
|
||||
private BigDecimal refundCount;
|
||||
|
||||
/**
|
||||
* 退单金额
|
||||
*/
|
||||
@ExcelProperty("退款金额")
|
||||
@ColumnWidth(7)
|
||||
@ColumnWidth(15)
|
||||
private BigDecimal refundAmount;
|
||||
|
||||
/**
|
||||
* 实际销售数量(过滤掉退单后的数量)
|
||||
*/
|
||||
@ExcelProperty("实际销量")
|
||||
@ColumnWidth(5)
|
||||
@ColumnWidth(15)
|
||||
private BigDecimal validSaleCount;
|
||||
|
||||
/**
|
||||
* 实际销售金额(过滤掉退单后的金额)
|
||||
*/
|
||||
@ExcelProperty("实际销售额")
|
||||
@ColumnWidth(7)
|
||||
@ColumnWidth(15)
|
||||
private BigDecimal validSaleAmount;
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.czg.order.service;
|
||||
|
||||
import com.czg.order.param.TableSummaryParam;
|
||||
import com.czg.order.vo.TableSummaryExportVo;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -14,7 +15,7 @@ import java.util.List;
|
||||
public interface TableSummaryService {
|
||||
|
||||
|
||||
List<TableSummaryExportVo> summaryExportList(TableSummaryParam param);
|
||||
void summaryExportList(TableSummaryParam param, HttpServletResponse response);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.czg.order.vo;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelIgnore;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import cn.idev.excel.annotation.write.style.ColumnWidth;
|
||||
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.pig4cloud.plugin.excel.annotation.ExcelLine;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
@@ -25,7 +24,6 @@ public class TableSummaryExportVo implements Serializable {
|
||||
/**
|
||||
* 导入时候回显行号
|
||||
*/
|
||||
@ExcelLine
|
||||
@ExcelIgnore
|
||||
@JSONField(serialize = false)
|
||||
private Long lineNum;
|
||||
@@ -36,18 +34,20 @@ public class TableSummaryExportVo implements Serializable {
|
||||
private String tableConcatDate;
|
||||
@ExcelIgnore
|
||||
private String tableCode;
|
||||
/**
|
||||
* 台桌
|
||||
*/
|
||||
@ExcelProperty("台桌")
|
||||
@ColumnWidth(10)
|
||||
private String tableName;
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
@ExcelProperty("日期")
|
||||
@ColumnWidth(10)
|
||||
@ColumnWidth(15)
|
||||
private String createDate;
|
||||
|
||||
/**
|
||||
* 台桌
|
||||
*/
|
||||
@ExcelProperty("台桌")
|
||||
@ColumnWidth(13)
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 商品分类
|
||||
*/
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.write.builder.ExcelWriterBuilder;
|
||||
import com.alibaba.excel.write.builder.ExcelWriterSheetBuilder;
|
||||
import com.alibaba.excel.write.handler.SheetWriteHandler;
|
||||
import com.alibaba.excel.write.merge.OnceAbsoluteMergeStrategy;
|
||||
import com.alibaba.excel.write.metadata.WriteSheet;
|
||||
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
|
||||
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
|
||||
@@ -26,6 +27,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* EasyExcel导出工具类
|
||||
*
|
||||
* @author yjjie
|
||||
* @date 2026/1/28 10:48
|
||||
*/
|
||||
@@ -34,14 +36,18 @@ public class ExcelExportUtil {
|
||||
|
||||
private static final ExcelExportConfig DEFAULT_CONFIG = new ExcelExportConfig();
|
||||
|
||||
public static OnceAbsoluteMergeStrategy createMergeStrategy(int firstRow, int lastRow, int firstCol, int lastCol) {
|
||||
return new OnceAbsoluteMergeStrategy(firstRow, lastRow, firstCol, lastCol);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出Excel到HttpServletResponse
|
||||
*
|
||||
* @param data 数据列表
|
||||
* @param clazz 数据类型
|
||||
* @param data 数据列表
|
||||
* @param clazz 数据类型
|
||||
* @param fileName 文件名(不含扩展名)
|
||||
* @param response HttpServletResponse
|
||||
* @param <T> 数据类型
|
||||
* @param <T> 数据类型
|
||||
*/
|
||||
public static <T> void exportToResponse(List<T> data, Class<T> clazz,
|
||||
String fileName, HttpServletResponse response) {
|
||||
@@ -51,12 +57,12 @@ public class ExcelExportUtil {
|
||||
/**
|
||||
* 导出Excel到HttpServletResponse(自定义配置)
|
||||
*
|
||||
* @param data 数据列表
|
||||
* @param clazz 数据类型
|
||||
* @param data 数据列表
|
||||
* @param clazz 数据类型
|
||||
* @param fileName 文件名(不含扩展名)
|
||||
* @param config 配置信息
|
||||
* @param config 配置信息
|
||||
* @param response HttpServletResponse
|
||||
* @param <T> 数据类型
|
||||
* @param <T> 数据类型
|
||||
*/
|
||||
public static <T> void exportToResponse(List<T> data, Class<T> clazz,
|
||||
String fileName, ExcelExportConfig config,
|
||||
@@ -86,10 +92,10 @@ public class ExcelExportUtil {
|
||||
/**
|
||||
* 导出Excel到文件
|
||||
*
|
||||
* @param data 数据列表
|
||||
* @param clazz 数据类型
|
||||
* @param data 数据列表
|
||||
* @param clazz 数据类型
|
||||
* @param filePath 文件路径
|
||||
* @param <T> 数据类型
|
||||
* @param <T> 数据类型
|
||||
*/
|
||||
public static <T> void exportToFile(List<T> data, Class<T> clazz, String filePath) {
|
||||
exportToFile(data, clazz, filePath, DEFAULT_CONFIG);
|
||||
@@ -98,11 +104,11 @@ public class ExcelExportUtil {
|
||||
/**
|
||||
* 导出Excel到文件(自定义配置)
|
||||
*
|
||||
* @param data 数据列表
|
||||
* @param clazz 数据类型
|
||||
* @param data 数据列表
|
||||
* @param clazz 数据类型
|
||||
* @param filePath 文件路径
|
||||
* @param config 配置信息
|
||||
* @param <T> 数据类型
|
||||
* @param config 配置信息
|
||||
* @param <T> 数据类型
|
||||
*/
|
||||
public static <T> void exportToFile(List<T> data, Class<T> clazz,
|
||||
String filePath, ExcelExportConfig config) {
|
||||
@@ -124,11 +130,11 @@ public class ExcelExportUtil {
|
||||
/**
|
||||
* 带样式的Excel导出到Response
|
||||
*
|
||||
* @param data 数据列表
|
||||
* @param clazz 数据类型
|
||||
* @param data 数据列表
|
||||
* @param clazz 数据类型
|
||||
* @param fileName 文件名
|
||||
* @param response HttpServletResponse
|
||||
* @param <T> 数据类型
|
||||
* @param <T> 数据类型
|
||||
*/
|
||||
public static <T> void exportWithStyleToResponse(List<T> data, Class<T> clazz,
|
||||
String fileName, HttpServletResponse response) {
|
||||
@@ -162,11 +168,11 @@ public class ExcelExportUtil {
|
||||
* 大数据量分批导出(避免内存溢出)
|
||||
*
|
||||
* @param dataSupplier 数据提供者(分页获取数据)
|
||||
* @param clazz 数据类型
|
||||
* @param fileName 文件名
|
||||
* @param response HttpServletResponse
|
||||
* @param batchSize 每批大小
|
||||
* @param <T> 数据类型
|
||||
* @param clazz 数据类型
|
||||
* @param fileName 文件名
|
||||
* @param response HttpServletResponse
|
||||
* @param batchSize 每批大小
|
||||
* @param <T> 数据类型
|
||||
*/
|
||||
public static <T> void exportBigDataToResponse(DataSupplier<T> dataSupplier,
|
||||
Class<T> clazz, String fileName,
|
||||
@@ -254,13 +260,13 @@ public class ExcelExportUtil {
|
||||
* 带合并单元格的导出到Response
|
||||
* 多sheet导出到response
|
||||
*
|
||||
* @param sheetDataList 数据列表
|
||||
* @param fileName 文件名
|
||||
* @param response HttpServletResponse
|
||||
* @param sheetDataList 数据列表
|
||||
* @param fileName 文件名
|
||||
* @param response HttpServletResponse
|
||||
*/
|
||||
public static void exportMultipleSheetsToResponse(List<SheetData> sheetDataList,
|
||||
String fileName,
|
||||
HttpServletResponse response) {
|
||||
String fileName,
|
||||
HttpServletResponse response) {
|
||||
if (CollectionUtil.isEmpty(sheetDataList)) {
|
||||
throw new CzgException("数据列表不能为空");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user