统计数据导出
This commit is contained in:
@@ -8,10 +8,11 @@ import com.czg.account.vo.HandoverProductListVo;
|
|||||||
import com.czg.account.vo.HandoverTotalVo;
|
import com.czg.account.vo.HandoverTotalVo;
|
||||||
import com.czg.annotation.SaAdminCheckPermission;
|
import com.czg.annotation.SaAdminCheckPermission;
|
||||||
import com.czg.constants.SystemConstants;
|
import com.czg.constants.SystemConstants;
|
||||||
|
import com.czg.excel.ExcelExportUtil;
|
||||||
import com.czg.log.annotation.OperationLog;
|
import com.czg.log.annotation.OperationLog;
|
||||||
import com.czg.resp.CzgResult;
|
import com.czg.resp.CzgResult;
|
||||||
import com.mybatisflex.core.paginate.Page;
|
import com.mybatisflex.core.paginate.Page;
|
||||||
import com.pig4cloud.plugin.excel.annotation.ResponseExcel;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@@ -62,12 +63,12 @@ public class HandoverRecordController {
|
|||||||
*
|
*
|
||||||
* @param id 交班记录ID
|
* @param id 交班记录ID
|
||||||
*/
|
*/
|
||||||
@ResponseExcel(name = "交班售出商品明细")
|
|
||||||
@GetMapping("/export/{id}")
|
@GetMapping("/export/{id}")
|
||||||
@OperationLog("交班记录-导出")
|
@OperationLog("交班记录-导出")
|
||||||
@SaAdminCheckPermission(parentName = "交班记录", value = "handoverRecord:export", name = "交班记录-导出")
|
@SaAdminCheckPermission(parentName = "交班记录", value = "handoverRecord:export", name = "交班记录-导出")
|
||||||
public List<HandoverProductListVo> export(@PathVariable Long id) {
|
public void export(@PathVariable Long id, HttpServletResponse response) {
|
||||||
return handoverRecordService.getHandoverProductListById(id);
|
List<HandoverProductListVo> list = handoverRecordService.getHandoverProductListById(id);
|
||||||
|
ExcelExportUtil.exportToResponse(list, HandoverProductListVo.class, "交班售出商品明细", response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.czg.controller.admin;
|
package com.czg.controller.admin;
|
||||||
|
|
||||||
|
import com.czg.excel.ExcelExportUtil;
|
||||||
import com.czg.log.annotation.OperationLog;
|
import com.czg.log.annotation.OperationLog;
|
||||||
import com.czg.order.entity.ShopProdStatistic;
|
import com.czg.order.entity.ShopProdStatistic;
|
||||||
import com.czg.order.param.SaleSummaryCountParam;
|
import com.czg.order.param.SaleSummaryCountParam;
|
||||||
@@ -7,8 +8,8 @@ import com.czg.order.service.ShopProdStatisticService;
|
|||||||
import com.czg.order.vo.SaleSummaryCountVo;
|
import com.czg.order.vo.SaleSummaryCountVo;
|
||||||
import com.czg.resp.CzgResult;
|
import com.czg.resp.CzgResult;
|
||||||
import com.czg.sa.StpKit;
|
import com.czg.sa.StpKit;
|
||||||
import com.pig4cloud.plugin.excel.annotation.ResponseExcel;
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@@ -59,13 +60,12 @@ public class SaleSummaryController {
|
|||||||
return CzgResult.success(list);
|
return CzgResult.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ResponseExcel(name = "销售统计明细")
|
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
public List<ShopProdStatistic> summaryExport(SaleSummaryCountParam param) {
|
public void summaryExport(SaleSummaryCountParam param, HttpServletResponse response) {
|
||||||
if (param.getShopId() == null) {
|
if (param.getShopId() == null) {
|
||||||
param.setShopId(StpKit.USER.getShopId());
|
param.setShopId(StpKit.USER.getShopId());
|
||||||
}
|
}
|
||||||
return prodStatisticService.getArchiveTradeData(param);
|
ExcelExportUtil.exportToResponse(prodStatisticService.getArchiveTradeData(param), ShopProdStatistic.class, "销售统计明细", response);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.czg.controller.admin;
|
package com.czg.controller.admin;
|
||||||
|
|
||||||
import com.czg.handel.ExcelMergeHandler;
|
import com.czg.excel.ExcelExportUtil;
|
||||||
import com.czg.handel.TableRefundCellHandel;
|
|
||||||
import com.czg.log.annotation.OperationLog;
|
import com.czg.log.annotation.OperationLog;
|
||||||
import com.czg.order.entity.ShopTableOrderStatistic;
|
import com.czg.order.entity.ShopTableOrderStatistic;
|
||||||
import com.czg.order.param.DataSummaryTradeParam;
|
import com.czg.order.param.DataSummaryTradeParam;
|
||||||
@@ -11,8 +10,8 @@ import com.czg.order.service.TableSummaryService;
|
|||||||
import com.czg.order.vo.TableSummaryExportVo;
|
import com.czg.order.vo.TableSummaryExportVo;
|
||||||
import com.czg.resp.CzgResult;
|
import com.czg.resp.CzgResult;
|
||||||
import com.czg.sa.StpKit;
|
import com.czg.sa.StpKit;
|
||||||
import com.pig4cloud.plugin.excel.annotation.ResponseExcel;
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@@ -54,15 +53,14 @@ public class TableSummaryController {
|
|||||||
/**
|
/**
|
||||||
* 导出
|
* 导出
|
||||||
*/
|
*/
|
||||||
@ResponseExcel(name = "台桌统计", writeHandler = {ExcelMergeHandler.class, TableRefundCellHandel.class})
|
|
||||||
@GetMapping("export")
|
@GetMapping("export")
|
||||||
@OperationLog("导出")
|
@OperationLog("导出")
|
||||||
//@SaAdminCheckPermission("tableSummary:export")
|
//@SaAdminCheckPermission("tableSummary:export")
|
||||||
public List<TableSummaryExportVo> summaryExport(TableSummaryParam param) {
|
public void summaryExport(TableSummaryParam param, HttpServletResponse response) {
|
||||||
if (param.getShopId() == null) {
|
if (param.getShopId() == null) {
|
||||||
param.setShopId(StpKit.USER.getShopId());
|
param.setShopId(StpKit.USER.getShopId());
|
||||||
}
|
}
|
||||||
return tableSummaryService.summaryExportList(param);
|
tableSummaryService.summaryExportList(param, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,151 +0,0 @@
|
|||||||
package com.czg.handel;
|
|
||||||
|
|
||||||
import cn.idev.excel.metadata.Head;
|
|
||||||
import cn.idev.excel.metadata.data.WriteCellData;
|
|
||||||
import cn.idev.excel.write.handler.CellWriteHandler;
|
|
||||||
import cn.idev.excel.write.metadata.holder.WriteSheetHolder;
|
|
||||||
import cn.idev.excel.write.metadata.holder.WriteTableHolder;
|
|
||||||
import org.apache.poi.ss.usermodel.*;
|
|
||||||
import org.apache.poi.ss.util.CellRangeAddress;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author tankaikai
|
|
||||||
* @since 2025-04-01 18:41
|
|
||||||
*/
|
|
||||||
public class ExcelMergeHandler implements CellWriteHandler {
|
|
||||||
// 要合并的列索引数组
|
|
||||||
private int[] mergeColumnIndex = {0, 1, 2, 3, 8, 9};
|
|
||||||
// 合并开始的行索引
|
|
||||||
private int mergeRowIndex = 1;
|
|
||||||
|
|
||||||
public ExcelMergeHandler() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构造函数
|
|
||||||
*
|
|
||||||
* @param mergeRowIndex 合并开始的行索引
|
|
||||||
* @param mergeColumnIndex 要合并的列索引数组
|
|
||||||
*/
|
|
||||||
public ExcelMergeHandler(int mergeRowIndex, int[] mergeColumnIndex) {
|
|
||||||
this.mergeRowIndex = mergeRowIndex;
|
|
||||||
this.mergeColumnIndex = mergeColumnIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<WriteCellData<?>> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
|
|
||||||
// 当前行索引
|
|
||||||
int curRowIndex = cell.getRowIndex();
|
|
||||||
// 当前列索引
|
|
||||||
int curColIndex = cell.getColumnIndex();
|
|
||||||
|
|
||||||
// 如果当前行大于合并开始行且当前列在需要合并的列中
|
|
||||||
if (curRowIndex > mergeRowIndex && isMergeColumn(curColIndex)) {
|
|
||||||
// 进行合并操作
|
|
||||||
mergeWithPrevRow(writeSheetHolder, cell, curRowIndex, curColIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查当前列是否在需要合并的列中
|
|
||||||
*
|
|
||||||
* @param curColIndex 当前列索引
|
|
||||||
* @return 如果是需要合并的列返回true,否则返回false
|
|
||||||
*/
|
|
||||||
private boolean isMergeColumn(int curColIndex) {
|
|
||||||
for (int columnIndex : mergeColumnIndex) {
|
|
||||||
if (curColIndex == columnIndex) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 当前单元格向上合并
|
|
||||||
*
|
|
||||||
* @param writeSheetHolder 当前工作表持有者
|
|
||||||
* @param cell 当前单元格
|
|
||||||
* @param curRowIndex 当前行索引
|
|
||||||
* @param curColIndex 当前列索引
|
|
||||||
*/
|
|
||||||
private void mergeWithPrevRow(WriteSheetHolder writeSheetHolder, Cell cell, int curRowIndex, int curColIndex) {
|
|
||||||
// 获取当前单元格的数据
|
|
||||||
Object curData = getCellData(cell);
|
|
||||||
// 获取前一个单元格的数据
|
|
||||||
Cell preCell = cell.getSheet().getRow(curRowIndex - 1).getCell(curColIndex);
|
|
||||||
Object preData = getCellData(preCell);
|
|
||||||
|
|
||||||
// 判断当前单元格和前一个单元格的数据以及主键是否相同
|
|
||||||
if (curData.equals(preData) && isSamePrimaryKey(cell, curRowIndex)) {
|
|
||||||
// 获取工作表
|
|
||||||
Sheet sheet = writeSheetHolder.getSheet();
|
|
||||||
// 合并单元格
|
|
||||||
mergeCells(sheet, curRowIndex, curColIndex);
|
|
||||||
CellStyle style = preCell.getCellStyle();
|
|
||||||
// 设置水平居中
|
|
||||||
style.setAlignment(HorizontalAlignment.CENTER);
|
|
||||||
// 设置垂直居中
|
|
||||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
||||||
preCell.setCellStyle(style);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取单元格的数据
|
|
||||||
*
|
|
||||||
* @param cell 单元格
|
|
||||||
* @return 单元格数据
|
|
||||||
*/
|
|
||||||
private Object getCellData(Cell cell) {
|
|
||||||
return cell.getCellType() == CellType.STRING ? cell.getStringCellValue() : cell.getNumericCellValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断当前单元格和前一个单元格的主键是否相同
|
|
||||||
*
|
|
||||||
* @param cell 当前单元格
|
|
||||||
* @param curRowIndex 当前行索引
|
|
||||||
* @return 如果主键相同返回true,否则返回false
|
|
||||||
*/
|
|
||||||
private boolean isSamePrimaryKey(Cell cell, int curRowIndex) {
|
|
||||||
String currentPrimaryKey = cell.getRow().getCell(0).getStringCellValue();
|
|
||||||
String previousPrimaryKey = cell.getSheet().getRow(curRowIndex - 1).getCell(0).getStringCellValue();
|
|
||||||
return currentPrimaryKey.equals(previousPrimaryKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 合并单元格
|
|
||||||
*
|
|
||||||
* @param sheet 工作表
|
|
||||||
* @param curRowIndex 当前行索引
|
|
||||||
* @param curColIndex 当前列索引
|
|
||||||
*/
|
|
||||||
private void mergeCells(Sheet sheet, int curRowIndex, int curColIndex) {
|
|
||||||
// 获取已合并的区域
|
|
||||||
List<CellRangeAddress> mergeRegions = sheet.getMergedRegions();
|
|
||||||
boolean isMerged = false;
|
|
||||||
|
|
||||||
// 检查前一个单元格是否已经被合并
|
|
||||||
for (int i = 0; i < mergeRegions.size() && !isMerged; i++) {
|
|
||||||
CellRangeAddress cellRangeAddr = mergeRegions.get(i);
|
|
||||||
if (cellRangeAddr.isInRange(curRowIndex - 1, curColIndex)) {
|
|
||||||
sheet.removeMergedRegion(i);
|
|
||||||
cellRangeAddr.setLastRow(curRowIndex);
|
|
||||||
sheet.addMergedRegion(cellRangeAddr);
|
|
||||||
isMerged = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果前一个单元格未被合并,则新增合并区域
|
|
||||||
if (!isMerged) {
|
|
||||||
CellRangeAddress cellRangeAddress = new CellRangeAddress(curRowIndex - 1, curRowIndex, curColIndex, curColIndex);
|
|
||||||
sheet.addMergedRegion(cellRangeAddress);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
package com.czg.handel;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
|
||||||
import cn.idev.excel.metadata.Head;
|
|
||||||
import cn.idev.excel.metadata.data.WriteCellData;
|
|
||||||
import cn.idev.excel.write.handler.CellWriteHandler;
|
|
||||||
import cn.idev.excel.write.metadata.holder.WriteSheetHolder;
|
|
||||||
import cn.idev.excel.write.metadata.holder.WriteTableHolder;
|
|
||||||
import org.apache.poi.ss.usermodel.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 台桌统计退单单元格处理器
|
|
||||||
*
|
|
||||||
* @author tankaikai
|
|
||||||
* @since 2025-04-02 09:50
|
|
||||||
*/
|
|
||||||
public class TableRefundCellHandel implements CellWriteHandler {
|
|
||||||
// 要处理的列索引数组
|
|
||||||
private int[] yellowColumnIndex = {10, 11};
|
|
||||||
|
|
||||||
public TableRefundCellHandel() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<WriteCellData<?>> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
|
|
||||||
// 当前行索引
|
|
||||||
int curRowIndex = cell.getRowIndex();
|
|
||||||
// 当前列索引
|
|
||||||
int curColIndex = cell.getColumnIndex();
|
|
||||||
if (curRowIndex == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 如果是指定要处理的列,则要进行加黄操作
|
|
||||||
if (ArrayUtil.contains(yellowColumnIndex, curColIndex)) {
|
|
||||||
Cell preCell = cell.getSheet().getRow(curRowIndex - 1).getCell(curColIndex);
|
|
||||||
if (preCell.getCellType() == CellType.NUMERIC) {
|
|
||||||
if (preCell.getNumericCellValue() < 0) {
|
|
||||||
//System.out.println("设置黄色背景:" + curRowIndex + "行," + curColIndex + "列" + preCell.getNumericCellValue());
|
|
||||||
CellStyle style = preCell.getSheet().getWorkbook().createCellStyle();
|
|
||||||
style.cloneStyleFrom(preCell.getCellStyle());
|
|
||||||
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
|
||||||
style.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
|
|
||||||
// 设置水平居中
|
|
||||||
style.setAlignment(HorizontalAlignment.CENTER);
|
|
||||||
// 设置垂直居中
|
|
||||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
||||||
preCell.setCellStyle(style);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -52,10 +52,6 @@
|
|||||||
<artifactId>cash-common-service</artifactId>
|
<artifactId>cash-common-service</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.pig4cloud.excel</groupId>
|
|
||||||
<artifactId>excel-spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -37,14 +37,19 @@ public class ShopProdCategoryController {
|
|||||||
@Resource
|
@Resource
|
||||||
private ShopSyncService shopSyncService;
|
private ShopSyncService shopSyncService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页
|
||||||
|
*/
|
||||||
@GetMapping("page")
|
@GetMapping("page")
|
||||||
@OperationLog("商品分类-分页")
|
@OperationLog("商品分类-分页")
|
||||||
//@SaAdminCheckPermission("shopProdCategory:page")
|
|
||||||
public CzgResult<Page<ShopProdCategoryDTO>> getShopProdCategoryPage(ShopProdCategoryDTO param) {
|
public CzgResult<Page<ShopProdCategoryDTO>> getShopProdCategoryPage(ShopProdCategoryDTO param) {
|
||||||
Page<ShopProdCategoryDTO> data = shopProdCategoryService.getShopProdCategoryPage(param);
|
Page<ShopProdCategoryDTO> data = shopProdCategoryService.getShopProdCategoryPage(param);
|
||||||
return CzgResult.success(data);
|
return CzgResult.success(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表
|
||||||
|
*/
|
||||||
@GetMapping("list")
|
@GetMapping("list")
|
||||||
@OperationLog("商品分类-列表")
|
@OperationLog("商品分类-列表")
|
||||||
//@SaAdminCheckPermission("shopProdCategory:list")
|
//@SaAdminCheckPermission("shopProdCategory:list")
|
||||||
@@ -53,12 +58,18 @@ public class ShopProdCategoryController {
|
|||||||
return CzgResult.success(data);
|
return CzgResult.success(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出
|
||||||
|
*/
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
@OperationLog("商品分类-导出")
|
@OperationLog("商品分类-导出")
|
||||||
public void exportShopProdCategory(ShopProdCategoryDTO param, HttpServletResponse response) {
|
public void exportShopProdCategory(ShopProdCategoryDTO param, HttpServletResponse response) {
|
||||||
shopProdCategoryService.exportShopProdCategory(param, response);
|
shopProdCategoryService.exportShopProdCategory(param, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 详情
|
||||||
|
*/
|
||||||
@GetMapping("{id}")
|
@GetMapping("{id}")
|
||||||
@OperationLog("商品分类-详情")
|
@OperationLog("商品分类-详情")
|
||||||
//@SaAdminCheckPermission("shopProdCategory:info")
|
//@SaAdminCheckPermission("shopProdCategory:info")
|
||||||
@@ -68,6 +79,9 @@ public class ShopProdCategoryController {
|
|||||||
return CzgResult.success(data);
|
return CzgResult.success(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增
|
||||||
|
*/
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@OperationLog("商品分类-新增")
|
@OperationLog("商品分类-新增")
|
||||||
//@SaAdminCheckPermission("shopProdCategory:add")
|
//@SaAdminCheckPermission("shopProdCategory:add")
|
||||||
@@ -77,6 +91,9 @@ public class ShopProdCategoryController {
|
|||||||
return CzgResult.success();
|
return CzgResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
*/
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@OperationLog("商品分类-修改")
|
@OperationLog("商品分类-修改")
|
||||||
//@SaAdminCheckPermission("shopProdCategory:update")
|
//@SaAdminCheckPermission("shopProdCategory:update")
|
||||||
@@ -86,6 +103,9 @@ public class ShopProdCategoryController {
|
|||||||
return CzgResult.success();
|
return CzgResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*/
|
||||||
@DeleteMapping("{id}")
|
@DeleteMapping("{id}")
|
||||||
@OperationLog("商品分类-删除")
|
@OperationLog("商品分类-删除")
|
||||||
//@SaAdminCheckPermission("shopProdCategory:delete")
|
//@SaAdminCheckPermission("shopProdCategory:delete")
|
||||||
@@ -96,6 +116,9 @@ public class ShopProdCategoryController {
|
|||||||
return CzgResult.success();
|
return CzgResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 禁用
|
||||||
|
*/
|
||||||
@PostMapping("disable/{id}")
|
@PostMapping("disable/{id}")
|
||||||
@OperationLog("商品分类-禁用")
|
@OperationLog("商品分类-禁用")
|
||||||
//@SaAdminCheckPermission("shopProdCategory:able")
|
//@SaAdminCheckPermission("shopProdCategory:able")
|
||||||
@@ -107,6 +130,9 @@ public class ShopProdCategoryController {
|
|||||||
return CzgResult.success();
|
return CzgResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启用
|
||||||
|
*/
|
||||||
@PostMapping("enable/{id}")
|
@PostMapping("enable/{id}")
|
||||||
@OperationLog("商品分类-启用")
|
@OperationLog("商品分类-启用")
|
||||||
//@SaAdminCheckPermission("shopProdCategory:able")
|
//@SaAdminCheckPermission("shopProdCategory:able")
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import java.util.List;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品单位
|
* 管理端/商品单位
|
||||||
*
|
*
|
||||||
* @author Tankaikai tankaikai@aliyun.com
|
* @author Tankaikai tankaikai@aliyun.com
|
||||||
* @since 1.0 2025-02-10
|
* @since 1.0 2025-02-10
|
||||||
@@ -37,7 +37,9 @@ public class ShopProdUnitController {
|
|||||||
@Resource
|
@Resource
|
||||||
private ShopSyncService shopSyncService;
|
private ShopSyncService shopSyncService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页
|
||||||
|
*/
|
||||||
@GetMapping("page")
|
@GetMapping("page")
|
||||||
@OperationLog("商品单位-分页")
|
@OperationLog("商品单位-分页")
|
||||||
//@SaAdminCheckPermission("shopProdUnit:page")
|
//@SaAdminCheckPermission("shopProdUnit:page")
|
||||||
@@ -46,6 +48,9 @@ public class ShopProdUnitController {
|
|||||||
return CzgResult.success(data);
|
return CzgResult.success(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表
|
||||||
|
*/
|
||||||
@GetMapping("list")
|
@GetMapping("list")
|
||||||
@OperationLog("商品单位-列表")
|
@OperationLog("商品单位-列表")
|
||||||
//@SaAdminCheckPermission("shopProdUnit:list")
|
//@SaAdminCheckPermission("shopProdUnit:list")
|
||||||
@@ -54,12 +59,18 @@ public class ShopProdUnitController {
|
|||||||
return CzgResult.success(data);
|
return CzgResult.success(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出
|
||||||
|
*/
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
@OperationLog("商品单位-导出")
|
@OperationLog("商品单位-导出")
|
||||||
public void exportProduct(ShopProdUnitDTO param, HttpServletResponse response) {
|
public void exportProduct(ShopProdUnitDTO param, HttpServletResponse response) {
|
||||||
shopProdUnitService.exportShopProdUnit(param, response);
|
shopProdUnitService.exportShopProdUnit(param, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 详情
|
||||||
|
*/
|
||||||
@GetMapping("{id}")
|
@GetMapping("{id}")
|
||||||
@OperationLog("商品单位-详情")
|
@OperationLog("商品单位-详情")
|
||||||
//@SaAdminCheckPermission("shopProdUnit:info")
|
//@SaAdminCheckPermission("shopProdUnit:info")
|
||||||
@@ -69,6 +80,9 @@ public class ShopProdUnitController {
|
|||||||
return CzgResult.success(data);
|
return CzgResult.success(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增
|
||||||
|
*/
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@OperationLog("商品单位-新增")
|
@OperationLog("商品单位-新增")
|
||||||
//@SaAdminCheckPermission("shopProdUnit:add")
|
//@SaAdminCheckPermission("shopProdUnit:add")
|
||||||
@@ -78,6 +92,9 @@ public class ShopProdUnitController {
|
|||||||
return CzgResult.success();
|
return CzgResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
*/
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@OperationLog("商品单位-修改")
|
@OperationLog("商品单位-修改")
|
||||||
//@SaAdminCheckPermission("shopProdUnit:update")
|
//@SaAdminCheckPermission("shopProdUnit:update")
|
||||||
@@ -87,6 +104,9 @@ public class ShopProdUnitController {
|
|||||||
return CzgResult.success();
|
return CzgResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*/
|
||||||
@DeleteMapping("{id}")
|
@DeleteMapping("{id}")
|
||||||
@OperationLog("商品单位-删除")
|
@OperationLog("商品单位-删除")
|
||||||
//@SaAdminCheckPermission("shopProdUnit:delete")
|
//@SaAdminCheckPermission("shopProdUnit:delete")
|
||||||
@@ -97,6 +117,9 @@ public class ShopProdUnitController {
|
|||||||
return CzgResult.success();
|
return CzgResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 禁用
|
||||||
|
*/
|
||||||
@PostMapping("disable/{id}")
|
@PostMapping("disable/{id}")
|
||||||
@OperationLog("商品单位-禁用")
|
@OperationLog("商品单位-禁用")
|
||||||
//@SaAdminCheckPermission("shopProdUnit:able")
|
//@SaAdminCheckPermission("shopProdUnit:able")
|
||||||
@@ -108,6 +131,9 @@ public class ShopProdUnitController {
|
|||||||
return CzgResult.success();
|
return CzgResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启用
|
||||||
|
*/
|
||||||
@PostMapping("enable/{id}")
|
@PostMapping("enable/{id}")
|
||||||
@OperationLog("商品单位-启用")
|
@OperationLog("商品单位-启用")
|
||||||
//@SaAdminCheckPermission("shopProdUnit:able")
|
//@SaAdminCheckPermission("shopProdUnit:able")
|
||||||
|
|||||||
@@ -30,10 +30,7 @@
|
|||||||
<groupId>com.mybatis-flex</groupId>
|
<groupId>com.mybatis-flex</groupId>
|
||||||
<artifactId>mybatis-flex-processor</artifactId>
|
<artifactId>mybatis-flex-processor</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.pig4cloud.excel</groupId>
|
|
||||||
<artifactId>excel-spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.dubbo</groupId>
|
<groupId>org.apache.dubbo</groupId>
|
||||||
<artifactId>dubbo-spring-boot-starter</artifactId>
|
<artifactId>dubbo-spring-boot-starter</artifactId>
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
package com.czg.account.vo;
|
package com.czg.account.vo;
|
||||||
|
|
||||||
import cn.idev.excel.annotation.ExcelIgnore;
|
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||||
import cn.idev.excel.annotation.ExcelProperty;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import cn.idev.excel.annotation.write.style.ColumnWidth;
|
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||||
import com.alibaba.fastjson2.annotation.JSONField;
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
import com.pig4cloud.plugin.excel.annotation.ExcelLine;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
@@ -26,7 +25,6 @@ public class HandoverProductListVo implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 导入时候回显行号
|
* 导入时候回显行号
|
||||||
*/
|
*/
|
||||||
@ExcelLine
|
|
||||||
@ExcelIgnore
|
@ExcelIgnore
|
||||||
@JSONField(serialize = false)
|
@JSONField(serialize = false)
|
||||||
private Long lineNum;
|
private Long lineNum;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.czg.order.entity;
|
package com.czg.order.entity;
|
||||||
|
|
||||||
import cn.idev.excel.annotation.ExcelIgnore;
|
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||||
import cn.idev.excel.annotation.ExcelProperty;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import cn.idev.excel.annotation.write.style.ColumnWidth;
|
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||||
import com.mybatisflex.annotation.Column;
|
import com.mybatisflex.annotation.Column;
|
||||||
import com.mybatisflex.annotation.Id;
|
import com.mybatisflex.annotation.Id;
|
||||||
import com.mybatisflex.annotation.KeyType;
|
import com.mybatisflex.annotation.KeyType;
|
||||||
@@ -59,42 +59,42 @@ public class ShopProdStatistic implements Serializable {
|
|||||||
* 销售数量
|
* 销售数量
|
||||||
*/
|
*/
|
||||||
@ExcelProperty("销量")
|
@ExcelProperty("销量")
|
||||||
@ColumnWidth(5)
|
@ColumnWidth(15)
|
||||||
private BigDecimal saleCount;
|
private BigDecimal saleCount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 销售金额
|
* 销售金额
|
||||||
*/
|
*/
|
||||||
@ExcelProperty("销售金额")
|
@ExcelProperty("销售金额")
|
||||||
@ColumnWidth(7)
|
@ColumnWidth(15)
|
||||||
private BigDecimal saleAmount;
|
private BigDecimal saleAmount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退单量
|
* 退单量
|
||||||
*/
|
*/
|
||||||
@ExcelProperty("退单量")
|
@ExcelProperty("退单量")
|
||||||
@ColumnWidth(5)
|
@ColumnWidth(15)
|
||||||
private BigDecimal refundCount;
|
private BigDecimal refundCount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退单金额
|
* 退单金额
|
||||||
*/
|
*/
|
||||||
@ExcelProperty("退款金额")
|
@ExcelProperty("退款金额")
|
||||||
@ColumnWidth(7)
|
@ColumnWidth(15)
|
||||||
private BigDecimal refundAmount;
|
private BigDecimal refundAmount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实际销售数量(过滤掉退单后的数量)
|
* 实际销售数量(过滤掉退单后的数量)
|
||||||
*/
|
*/
|
||||||
@ExcelProperty("实际销量")
|
@ExcelProperty("实际销量")
|
||||||
@ColumnWidth(5)
|
@ColumnWidth(15)
|
||||||
private BigDecimal validSaleCount;
|
private BigDecimal validSaleCount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实际销售金额(过滤掉退单后的金额)
|
* 实际销售金额(过滤掉退单后的金额)
|
||||||
*/
|
*/
|
||||||
@ExcelProperty("实际销售额")
|
@ExcelProperty("实际销售额")
|
||||||
@ColumnWidth(7)
|
@ColumnWidth(15)
|
||||||
private BigDecimal validSaleAmount;
|
private BigDecimal validSaleAmount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.czg.order.service;
|
|||||||
|
|
||||||
import com.czg.order.param.TableSummaryParam;
|
import com.czg.order.param.TableSummaryParam;
|
||||||
import com.czg.order.vo.TableSummaryExportVo;
|
import com.czg.order.vo.TableSummaryExportVo;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -14,7 +15,7 @@ import java.util.List;
|
|||||||
public interface TableSummaryService {
|
public interface TableSummaryService {
|
||||||
|
|
||||||
|
|
||||||
List<TableSummaryExportVo> summaryExportList(TableSummaryParam param);
|
void summaryExportList(TableSummaryParam param, HttpServletResponse response);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
package com.czg.order.vo;
|
package com.czg.order.vo;
|
||||||
|
|
||||||
import cn.idev.excel.annotation.ExcelIgnore;
|
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||||
import cn.idev.excel.annotation.ExcelProperty;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import cn.idev.excel.annotation.write.style.ColumnWidth;
|
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||||
import com.alibaba.fastjson2.annotation.JSONField;
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
import com.pig4cloud.plugin.excel.annotation.ExcelLine;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
@@ -25,7 +24,6 @@ public class TableSummaryExportVo implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 导入时候回显行号
|
* 导入时候回显行号
|
||||||
*/
|
*/
|
||||||
@ExcelLine
|
|
||||||
@ExcelIgnore
|
@ExcelIgnore
|
||||||
@JSONField(serialize = false)
|
@JSONField(serialize = false)
|
||||||
private Long lineNum;
|
private Long lineNum;
|
||||||
@@ -36,18 +34,20 @@ public class TableSummaryExportVo implements Serializable {
|
|||||||
private String tableConcatDate;
|
private String tableConcatDate;
|
||||||
@ExcelIgnore
|
@ExcelIgnore
|
||||||
private String tableCode;
|
private String tableCode;
|
||||||
/**
|
|
||||||
* 台桌
|
|
||||||
*/
|
|
||||||
@ExcelProperty("台桌")
|
|
||||||
@ColumnWidth(10)
|
|
||||||
private String tableName;
|
|
||||||
/**
|
/**
|
||||||
* 日期
|
* 日期
|
||||||
*/
|
*/
|
||||||
@ExcelProperty("日期")
|
@ExcelProperty("日期")
|
||||||
@ColumnWidth(10)
|
@ColumnWidth(15)
|
||||||
private String createDate;
|
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.ExcelWriterBuilder;
|
||||||
import com.alibaba.excel.write.builder.ExcelWriterSheetBuilder;
|
import com.alibaba.excel.write.builder.ExcelWriterSheetBuilder;
|
||||||
import com.alibaba.excel.write.handler.SheetWriteHandler;
|
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.WriteSheet;
|
||||||
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
|
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
|
||||||
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
|
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
|
||||||
@@ -26,6 +27,7 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* EasyExcel导出工具类
|
* EasyExcel导出工具类
|
||||||
|
*
|
||||||
* @author yjjie
|
* @author yjjie
|
||||||
* @date 2026/1/28 10:48
|
* @date 2026/1/28 10:48
|
||||||
*/
|
*/
|
||||||
@@ -34,14 +36,18 @@ public class ExcelExportUtil {
|
|||||||
|
|
||||||
private static final ExcelExportConfig DEFAULT_CONFIG = new ExcelExportConfig();
|
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
|
* 导出Excel到HttpServletResponse
|
||||||
*
|
*
|
||||||
* @param data 数据列表
|
* @param data 数据列表
|
||||||
* @param clazz 数据类型
|
* @param clazz 数据类型
|
||||||
* @param fileName 文件名(不含扩展名)
|
* @param fileName 文件名(不含扩展名)
|
||||||
* @param response HttpServletResponse
|
* @param response HttpServletResponse
|
||||||
* @param <T> 数据类型
|
* @param <T> 数据类型
|
||||||
*/
|
*/
|
||||||
public static <T> void exportToResponse(List<T> data, Class<T> clazz,
|
public static <T> void exportToResponse(List<T> data, Class<T> clazz,
|
||||||
String fileName, HttpServletResponse response) {
|
String fileName, HttpServletResponse response) {
|
||||||
@@ -51,12 +57,12 @@ public class ExcelExportUtil {
|
|||||||
/**
|
/**
|
||||||
* 导出Excel到HttpServletResponse(自定义配置)
|
* 导出Excel到HttpServletResponse(自定义配置)
|
||||||
*
|
*
|
||||||
* @param data 数据列表
|
* @param data 数据列表
|
||||||
* @param clazz 数据类型
|
* @param clazz 数据类型
|
||||||
* @param fileName 文件名(不含扩展名)
|
* @param fileName 文件名(不含扩展名)
|
||||||
* @param config 配置信息
|
* @param config 配置信息
|
||||||
* @param response HttpServletResponse
|
* @param response HttpServletResponse
|
||||||
* @param <T> 数据类型
|
* @param <T> 数据类型
|
||||||
*/
|
*/
|
||||||
public static <T> void exportToResponse(List<T> data, Class<T> clazz,
|
public static <T> void exportToResponse(List<T> data, Class<T> clazz,
|
||||||
String fileName, ExcelExportConfig config,
|
String fileName, ExcelExportConfig config,
|
||||||
@@ -86,10 +92,10 @@ public class ExcelExportUtil {
|
|||||||
/**
|
/**
|
||||||
* 导出Excel到文件
|
* 导出Excel到文件
|
||||||
*
|
*
|
||||||
* @param data 数据列表
|
* @param data 数据列表
|
||||||
* @param clazz 数据类型
|
* @param clazz 数据类型
|
||||||
* @param filePath 文件路径
|
* @param filePath 文件路径
|
||||||
* @param <T> 数据类型
|
* @param <T> 数据类型
|
||||||
*/
|
*/
|
||||||
public static <T> void exportToFile(List<T> data, Class<T> clazz, String filePath) {
|
public static <T> void exportToFile(List<T> data, Class<T> clazz, String filePath) {
|
||||||
exportToFile(data, clazz, filePath, DEFAULT_CONFIG);
|
exportToFile(data, clazz, filePath, DEFAULT_CONFIG);
|
||||||
@@ -98,11 +104,11 @@ public class ExcelExportUtil {
|
|||||||
/**
|
/**
|
||||||
* 导出Excel到文件(自定义配置)
|
* 导出Excel到文件(自定义配置)
|
||||||
*
|
*
|
||||||
* @param data 数据列表
|
* @param data 数据列表
|
||||||
* @param clazz 数据类型
|
* @param clazz 数据类型
|
||||||
* @param filePath 文件路径
|
* @param filePath 文件路径
|
||||||
* @param config 配置信息
|
* @param config 配置信息
|
||||||
* @param <T> 数据类型
|
* @param <T> 数据类型
|
||||||
*/
|
*/
|
||||||
public static <T> void exportToFile(List<T> data, Class<T> clazz,
|
public static <T> void exportToFile(List<T> data, Class<T> clazz,
|
||||||
String filePath, ExcelExportConfig config) {
|
String filePath, ExcelExportConfig config) {
|
||||||
@@ -124,11 +130,11 @@ public class ExcelExportUtil {
|
|||||||
/**
|
/**
|
||||||
* 带样式的Excel导出到Response
|
* 带样式的Excel导出到Response
|
||||||
*
|
*
|
||||||
* @param data 数据列表
|
* @param data 数据列表
|
||||||
* @param clazz 数据类型
|
* @param clazz 数据类型
|
||||||
* @param fileName 文件名
|
* @param fileName 文件名
|
||||||
* @param response HttpServletResponse
|
* @param response HttpServletResponse
|
||||||
* @param <T> 数据类型
|
* @param <T> 数据类型
|
||||||
*/
|
*/
|
||||||
public static <T> void exportWithStyleToResponse(List<T> data, Class<T> clazz,
|
public static <T> void exportWithStyleToResponse(List<T> data, Class<T> clazz,
|
||||||
String fileName, HttpServletResponse response) {
|
String fileName, HttpServletResponse response) {
|
||||||
@@ -162,11 +168,11 @@ public class ExcelExportUtil {
|
|||||||
* 大数据量分批导出(避免内存溢出)
|
* 大数据量分批导出(避免内存溢出)
|
||||||
*
|
*
|
||||||
* @param dataSupplier 数据提供者(分页获取数据)
|
* @param dataSupplier 数据提供者(分页获取数据)
|
||||||
* @param clazz 数据类型
|
* @param clazz 数据类型
|
||||||
* @param fileName 文件名
|
* @param fileName 文件名
|
||||||
* @param response HttpServletResponse
|
* @param response HttpServletResponse
|
||||||
* @param batchSize 每批大小
|
* @param batchSize 每批大小
|
||||||
* @param <T> 数据类型
|
* @param <T> 数据类型
|
||||||
*/
|
*/
|
||||||
public static <T> void exportBigDataToResponse(DataSupplier<T> dataSupplier,
|
public static <T> void exportBigDataToResponse(DataSupplier<T> dataSupplier,
|
||||||
Class<T> clazz, String fileName,
|
Class<T> clazz, String fileName,
|
||||||
@@ -254,13 +260,13 @@ public class ExcelExportUtil {
|
|||||||
* 带合并单元格的导出到Response
|
* 带合并单元格的导出到Response
|
||||||
* 多sheet导出到response
|
* 多sheet导出到response
|
||||||
*
|
*
|
||||||
* @param sheetDataList 数据列表
|
* @param sheetDataList 数据列表
|
||||||
* @param fileName 文件名
|
* @param fileName 文件名
|
||||||
* @param response HttpServletResponse
|
* @param response HttpServletResponse
|
||||||
*/
|
*/
|
||||||
public static void exportMultipleSheetsToResponse(List<SheetData> sheetDataList,
|
public static void exportMultipleSheetsToResponse(List<SheetData> sheetDataList,
|
||||||
String fileName,
|
String fileName,
|
||||||
HttpServletResponse response) {
|
HttpServletResponse response) {
|
||||||
if (CollectionUtil.isEmpty(sheetDataList)) {
|
if (CollectionUtil.isEmpty(sheetDataList)) {
|
||||||
throw new CzgException("数据列表不能为空");
|
throw new CzgException("数据列表不能为空");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -250,13 +250,6 @@
|
|||||||
<artifactId>spring-data-redis</artifactId>
|
<artifactId>spring-data-redis</artifactId>
|
||||||
<version>${spring-data-redis.version}</version>
|
<version>${spring-data-redis.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- excel 导入导出工具类:https://github.com/pig-mesh/excel-spring-boot-starter -->
|
|
||||||
<!-- 参考文档:https://www.yuque.com/pig4cloud/excel -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.pig4cloud.excel</groupId>
|
|
||||||
<artifactId>excel-spring-boot-starter</artifactId>
|
|
||||||
<version>3.4.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/io.netty/netty-all -->
|
<!-- https://mvnrepository.com/artifact/io.netty/netty-all -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package com.czg.service.account.service.impl;
|
package com.czg.service.account.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.czg.account.service.GeoService;
|
import com.czg.account.service.GeoService;
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.client.RestClient;
|
import org.springframework.web.client.RestClient;
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ public class GeoServiceImpl implements GeoService {
|
|||||||
param.put("key", "7a7f2e4790ea222660a027352ee3af39");
|
param.put("key", "7a7f2e4790ea222660a027352ee3af39");
|
||||||
param.put("keywords", keywords);
|
param.put("keywords", keywords);
|
||||||
param.put("subdistrict", "1");
|
param.put("subdistrict", "1");
|
||||||
if (StringUtils.isNotBlank(subdistrict)) {
|
if (StrUtil.isNotBlank(subdistrict)) {
|
||||||
param.put("subdistrict", "2");
|
param.put("subdistrict", "2");
|
||||||
}
|
}
|
||||||
param.put("extensions", "base");
|
param.put("extensions", "base");
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ import com.czg.config.RedisCst;
|
|||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
import com.czg.sa.StpKit;
|
import com.czg.sa.StpKit;
|
||||||
import com.czg.service.RedisService;
|
import com.czg.service.RedisService;
|
||||||
|
import com.czg.utils.CzgRandomUtils;
|
||||||
import com.mybatisflex.core.query.QueryWrapper;
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||||
import com.czg.account.entity.ShopSong;
|
import com.czg.account.entity.ShopSong;
|
||||||
import com.czg.account.service.ShopSongService;
|
import com.czg.account.service.ShopSongService;
|
||||||
import com.czg.service.account.mapper.ShopSongMapper;
|
import com.czg.service.account.mapper.ShopSongMapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.lang3.RandomStringUtils;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,7 +23,7 @@ import org.springframework.stereotype.Service;
|
|||||||
* @since 2025-03-01
|
* @since 2025-03-01
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class ShopSongServiceImpl extends ServiceImpl<ShopSongMapper, ShopSong> implements ShopSongService{
|
public class ShopSongServiceImpl extends ServiceImpl<ShopSongMapper, ShopSong> implements ShopSongService {
|
||||||
@Resource
|
@Resource
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
||||||
@@ -49,18 +49,12 @@ public class ShopSongServiceImpl extends ServiceImpl<ShopSongMapper, ShopSong> i
|
|||||||
public String getSongUrl(Long shopId) {
|
public String getSongUrl(Long shopId) {
|
||||||
String code;
|
String code;
|
||||||
String key = RedisCst.getSongUrlKey(shopId);
|
String key = RedisCst.getSongUrlKey(shopId);
|
||||||
if(redisService.hasKey(key)){
|
if (redisService.hasKey(key)) {
|
||||||
code = (String) redisService.get(key);
|
code = (String) redisService.get(key);
|
||||||
}else {
|
} else {
|
||||||
code = RandomStringUtils.randomAlphanumeric(12);
|
code = CzgRandomUtils.randomString(12);
|
||||||
redisService.set(key, code);
|
redisService.set(key, code);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
String string = RandomStringUtils.randomAlphanumeric(12);
|
|
||||||
System.out.println(string);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,21 @@
|
|||||||
package com.czg.service.order.service.impl;
|
package com.czg.service.order.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.alibaba.excel.write.handler.SheetWriteHandler;
|
||||||
|
import com.czg.excel.ExcelExportUtil;
|
||||||
|
import com.czg.excel.SheetData;
|
||||||
import com.czg.order.param.TableSummaryParam;
|
import com.czg.order.param.TableSummaryParam;
|
||||||
import com.czg.order.service.TableSummaryService;
|
import com.czg.order.service.TableSummaryService;
|
||||||
import com.czg.order.vo.TableSummaryExportVo;
|
import com.czg.order.vo.TableSummaryExportVo;
|
||||||
import com.czg.service.order.mapper.ShopTableOrderStatisticMapper;
|
import com.czg.service.order.mapper.ShopTableOrderStatisticMapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -29,7 +34,7 @@ public class TableSummaryServiceImpl implements TableSummaryService {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TableSummaryExportVo> summaryExportList(TableSummaryParam param) {
|
public void summaryExportList(TableSummaryParam param, HttpServletResponse response) {
|
||||||
if (param.getBeginDate() == null && param.getEndDate() == null) {
|
if (param.getBeginDate() == null && param.getEndDate() == null) {
|
||||||
// 获取当前日期
|
// 获取当前日期
|
||||||
LocalDate currentDate = LocalDate.now();
|
LocalDate currentDate = LocalDate.now();
|
||||||
@@ -48,7 +53,8 @@ public class TableSummaryServiceImpl implements TableSummaryService {
|
|||||||
}
|
}
|
||||||
List<TableSummaryExportVo> list = shopTableOrderStatisticMapper.findSummaryExportList(param);
|
List<TableSummaryExportVo> list = shopTableOrderStatisticMapper.findSummaryExportList(param);
|
||||||
if (CollUtil.isEmpty(list)) {
|
if (CollUtil.isEmpty(list)) {
|
||||||
return List.of();
|
ExcelExportUtil.exportToResponse(new ArrayList<>(), TableSummaryExportVo.class, "台桌统计", response);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
record TableSummary(String tableKey, BigDecimal totalSales, Map<Long, BigDecimal> productSales) {}
|
record TableSummary(String tableKey, BigDecimal totalSales, Map<Long, BigDecimal> productSales) {}
|
||||||
|
|
||||||
@@ -85,10 +91,106 @@ public class TableSummaryServiceImpl implements TableSummaryService {
|
|||||||
vo.setSalesAmount(summary.productSales().getOrDefault(vo.getProductId(), BigDecimal.ZERO));
|
vo.setSalesAmount(summary.productSales().getOrDefault(vo.getProductId(), BigDecimal.ZERO));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// 追加个空行用于处理表格样式
|
|
||||||
TableSummaryExportVo nullVo = new TableSummaryExportVo();
|
List<SheetWriteHandler> strategies = calculateMergeCells(list);
|
||||||
list.add(nullVo);
|
ExcelExportUtil.exportMultipleSheetsToResponse(
|
||||||
return list;
|
List.of(new SheetData()
|
||||||
|
.setData(list)
|
||||||
|
.setSheetName("台桌统计")
|
||||||
|
.setHandlers(strategies)
|
||||||
|
.setClazz(TableSummaryExportVo.class)),
|
||||||
|
"台桌统计",
|
||||||
|
response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算需要合并的单元格信息
|
||||||
|
*/
|
||||||
|
private List<SheetWriteHandler> calculateMergeCells(List<TableSummaryExportVo> list) {
|
||||||
|
List<SheetWriteHandler> mergeInfos = new ArrayList<>();
|
||||||
|
|
||||||
|
if (CollUtil.isEmpty(list)) {
|
||||||
|
return mergeInfos;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按createDate分组
|
||||||
|
Map<String, List<TableSummaryExportVo>> byCreateDate = list.stream()
|
||||||
|
.collect(Collectors.groupingBy(TableSummaryExportVo::getCreateDate));
|
||||||
|
|
||||||
|
List<String> keyList = byCreateDate.keySet().stream().sorted().toList();
|
||||||
|
|
||||||
|
// Excel行号从1开始(假设第0行是标题)
|
||||||
|
int startRow = 1;
|
||||||
|
|
||||||
|
for (String key : keyList) {
|
||||||
|
List<TableSummaryExportVo> dateGroup = byCreateDate.get(key);
|
||||||
|
int dateGroupSize = dateGroup.size();
|
||||||
|
|
||||||
|
// 合并createDate列(假设是第1列)
|
||||||
|
if (dateGroupSize > 1) {
|
||||||
|
mergeInfos.add(ExcelExportUtil.createMergeStrategy(startRow, startRow + dateGroupSize - 1, 0, 0));
|
||||||
|
mergeInfos.add(ExcelExportUtil.createMergeStrategy(startRow, startRow + dateGroupSize - 1, 9, 9));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 在销售额组内按tableName分组
|
||||||
|
Map<String, List<TableSummaryExportVo>> byTableName = dateGroup.stream()
|
||||||
|
.collect(Collectors.groupingBy(TableSummaryExportVo::getTableName));
|
||||||
|
|
||||||
|
List<String> nameKeyList = byTableName.keySet().stream().sorted().toList();
|
||||||
|
|
||||||
|
int currentRow = startRow;
|
||||||
|
for (String nameKey : nameKeyList) {
|
||||||
|
int nameGroupSize = byTableName.get(nameKey).size();
|
||||||
|
|
||||||
|
// 合并tableName列(假设是第4列,根据实际Excel列调整)
|
||||||
|
if (nameGroupSize > 1) {
|
||||||
|
mergeInfos.add(ExcelExportUtil.createMergeStrategy(currentRow, currentRow + nameGroupSize - 1, 1, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 移动到下一组
|
||||||
|
currentRow += nameGroupSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 在日期组内按totalSalesAmount分组(同台桌同日期)
|
||||||
|
Map<BigDecimal, List<TableSummaryExportVo>> byTotalSales = dateGroup.stream()
|
||||||
|
.collect(Collectors.groupingBy(TableSummaryExportVo::getTotalSalesAmount));
|
||||||
|
|
||||||
|
List<BigDecimal> salesKeyList = byTotalSales.keySet().stream().sorted().toList();
|
||||||
|
|
||||||
|
int nameRow = startRow;
|
||||||
|
|
||||||
|
for (BigDecimal saleKey : salesKeyList) {
|
||||||
|
List<TableSummaryExportVo> salesGroup = byTotalSales.get(saleKey);
|
||||||
|
int salesGroupSize = salesGroup.size();
|
||||||
|
|
||||||
|
// 合并totalSalesAmount列(假设是第8列,根据实际Excel列调整)
|
||||||
|
if (salesGroupSize > 1) {
|
||||||
|
mergeInfos.add(ExcelExportUtil.createMergeStrategy(nameRow, nameRow + salesGroupSize - 1, 9, 9));
|
||||||
|
}
|
||||||
|
|
||||||
|
// // 在销售额组内按tableName分组
|
||||||
|
// Map<String, List<TableSummaryExportVo>> byTableName = salesGroup.stream()
|
||||||
|
// .collect(Collectors.groupingBy(TableSummaryExportVo::getTableName));
|
||||||
|
//
|
||||||
|
// List<String> nameKeyList = byTableName.keySet().stream().sorted().toList();
|
||||||
|
//
|
||||||
|
// for (List<TableSummaryExportVo> nameGroup : byTableName.values()) {
|
||||||
|
// int nameGroupSize = nameGroup.size();
|
||||||
|
//
|
||||||
|
// // 合并tableName列(假设是第4列,根据实际Excel列调整)
|
||||||
|
// if (nameGroupSize > 1) {
|
||||||
|
// mergeInfos.add(ExcelExportUtil.createMergeStrategy(currentRow, currentRow + nameGroupSize - 1, 1, 1));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 移动到下一组
|
||||||
|
// currentRow += nameGroupSize;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
startRow += dateGroupSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mergeInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -327,8 +327,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addMergeHandler(List<SheetWriteHandler> handlers, int firstRow, int lastRow, int firstCol, int lastCol) {
|
private void addMergeHandler(List<SheetWriteHandler> handlers, int firstRow, int lastRow, int firstCol, int lastCol) {
|
||||||
OnceAbsoluteMergeStrategy strategy = new OnceAbsoluteMergeStrategy(firstRow, lastRow, firstCol, lastCol);
|
handlers.add(ExcelExportUtil.createMergeStrategy(firstRow, lastRow, firstCol, lastCol));
|
||||||
handlers.add(strategy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user