毛利润报表

This commit is contained in:
zjf committed 2025-09-23 20:35:07 +08:00
1 parent c11648d3fc
commit af4c32b649
6 files changed
+2063

No files matched your search

@@ -0,0 +1,145 @@
package com.bsd.pjcloud.supermarket.dto.profit;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
* 毛利润报表查询DTO
*
* @author pjcloud
* @date 2025-01-27 16:00:00
*/
@Data
@Schema(description = "毛利润报表查询DTO")
public class ProfitMarginReportQueryDTO {
/**
* 查询类型:hour-按小时, day-按天, month-按月, product-按商品
*/
@Schema(description = "查询类型:hour-按小时, day-按天, month-按月, product-按商品", example = "day")
private String queryType;
/**
* 开始时间
*/
@Schema(description = "开始时间")
private LocalDateTime startTime;
/**
* 结束时间
*/
@Schema(description = "结束时间")
private LocalDateTime endTime;
/**
* 开始日期
*/
@Schema(description = "开始日期")
private LocalDate startDate;
/**
* 结束日期
*/
@Schema(description = "结束日期")
private LocalDate endDate;
/**
* 商品分类ID
*/
@Schema(description = "商品分类ID")
private Long categoryId;
/**
* 商品名称(模糊查询)
*/
@Schema(description = "商品名称(模糊查询)")
private String productName;
/**
* 商品编码(模糊查询)
*/
@Schema(description = "商品编码(模糊查询)")
private String productCode;
/**
* 销售员ID
*/
@Schema(description = "销售员ID")
private Long salespersonId;
/**
* 仓库ID
*/
@Schema(description = "仓库ID")
private String warehouseId;
/**
* 排名数量限制
*/
@Schema(description = "排名数量限制", example = "10")
private Integer topLimit;
/**
* 毛利率范围筛选 - 最低毛利率(%)
*/
@Schema(description = "毛利率范围筛选 - 最低毛利率(%)", example = "10.0")
private BigDecimal minMarginRate;
/**
* 毛利率范围筛选 - 最高毛利率(%)
*/
@Schema(description = "毛利率范围筛选 - 最高毛利率(%)", example = "50.0")
private BigDecimal maxMarginRate;
/**
* 毛利润范围筛选 - 最低毛利润(元)
*/
@Schema(description = "毛利润范围筛选 - 最低毛利润(元)", example = "100.0")
private BigDecimal minProfitAmount;
/**
* 毛利润范围筛选 - 最高毛利润(元)
*/
@Schema(description = "毛利润范围筛选 - 最高毛利润(元)", example = "1000.0")
private BigDecimal maxProfitAmount;
/**
* 排序字段:profit_amount-毛利润, margin_rate-毛利率, sales_amount-销售额
*/
@Schema(description = "排序字段:profit_amount-毛利润, margin_rate-毛利率, sales_amount-销售额", example = "profit_amount")
private String sortField;
/**
* 排序方向:asc-升序, desc-降序
*/
@Schema(description = "排序方向:asc-升序, desc-降序", example = "desc")
private String sortOrder;
/**
* 是否只显示有毛利润的商品
*/
@Schema(description = "是否只显示有毛利润的商品", example = "true")
private Boolean onlyProfitable;
/**
* 是否只显示亏损的商品
*/
@Schema(description = "是否只显示亏损的商品", example = "false")
private Boolean onlyLoss;
/**
* 页码(从1开始)
*/
@Schema(description = "页码(从1开始)", example = "1")
private Integer pageNum = 1;
/**
* 每页大小
*/
@Schema(description = "每页大小", example = "1000")
private Integer pageSize = 1000;
}
@@ -0,0 +1,369 @@
package com.bsd.pjcloud.supermarket.vo.profit;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
/**
* 毛利润报表VO
*
* @author pjcloud
* @date 2025-01-27 16:00:00
*/
@Data
@Schema(description = "毛利润报表VO")
public class ProfitMarginReportVO {
/**
* 报表生成时间
*/
@Schema(description = "报表生成时间")
private LocalDateTime reportTime;
/**
* 查询时间段
*/
@Schema(description = "查询时间段")
private String timeRange;
/**
* 毛利润汇总信息
*/
@Schema(description = "毛利润汇总信息")
private ProfitSummaryVO profitSummary;
/**
* 商品毛利润排名
*/
@Schema(description = "商品毛利润排名")
private List<ProductProfitVO> productProfitRanking;
/**
* 分类毛利润分析
*/
@Schema(description = "分类毛利润分析")
private List<CategoryProfitVO> categoryProfitAnalysis;
/**
* 时段毛利润趋势
*/
@Schema(description = "时段毛利润趋势")
private List<TimePeriodProfitVO> timePeriodProfitTrend;
/**
* 高毛利润商品
*/
@Schema(description = "高毛利润商品")
private List<ProductProfitVO> highProfitProducts;
/**
* 低毛利润/亏损商品
*/
@Schema(description = "低毛利润/亏损商品")
private List<ProductProfitVO> lowProfitProducts;
/**
* 毛利润汇总信息VO
*/
@Data
@Schema(description = "毛利润汇总信息VO")
public static class ProfitSummaryVO {
/**
* 总销售额(元)
*/
@Schema(description = "总销售额(元)")
private BigDecimal totalSalesAmount;
/**
* 总成本(元)
*/
@Schema(description = "总成本(元)")
private BigDecimal totalCostAmount;
/**
* 总毛利润(元)
*/
@Schema(description = "总毛利润(元)")
private BigDecimal totalProfitAmount;
/**
* 平均毛利率(%)
*/
@Schema(description = "平均毛利率(%)")
private BigDecimal averageMarginRate;
/**
* 销售商品种类数
*/
@Schema(description = "销售商品种类数")
private Integer productCount;
/**
* 销售笔数
*/
@Schema(description = "销售笔数")
private Integer salesCount;
/**
* 盈利商品数
*/
@Schema(description = "盈利商品数")
private Integer profitableProductCount;
/**
* 亏损商品数
*/
@Schema(description = "亏损商品数")
private Integer lossProductCount;
}
/**
* 商品毛利润VO
*/
@Data
@Schema(description = "商品毛利润VO")
public static class ProductProfitVO {
/**
* 排名
*/
@Schema(description = "排名")
private Integer ranking;
/**
* 商品ID
*/
@Schema(description = "商品ID")
private Long productId;
/**
* 商品名称
*/
@Schema(description = "商品名称")
private String productName;
/**
* 商品编码
*/
@Schema(description = "商品编码")
private String productCode;
/**
* 商品分类ID
*/
@Schema(description = "商品分类ID")
private Long categoryId;
/**
* 商品分类名称
*/
@Schema(description = "商品分类名称")
private String categoryName;
/**
* 销售数量
*/
@Schema(description = "销售数量")
private Double salesQuantity;
/**
* 销售单价(元)
*/
@Schema(description = "销售单价(元)")
private BigDecimal salesPrice;
/**
* 成本单价(元)
*/
@Schema(description = "成本单价(元)")
private BigDecimal costPrice;
/**
* 销售额(元)
*/
@Schema(description = "销售额(元)")
private BigDecimal salesAmount;
/**
* 成本总额(元)
*/
@Schema(description = "成本总额(元)")
private BigDecimal costAmount;
/**
* 毛利润(元)
*/
@Schema(description = "毛利润(元)")
private BigDecimal profitAmount;
/**
* 毛利率(%)
*/
@Schema(description = "毛利率(%)")
private BigDecimal marginRate;
/**
* 销售笔数
*/
@Schema(description = "销售笔数")
private Integer salesCount;
/**
* 利润状态:profitable-盈利, loss-亏损, break_even-盈亏平衡
*/
@Schema(description = "利润状态:profitable-盈利, loss-亏损, break_even-盈亏平衡")
private String profitStatus;
/**
* 包装单位
*/
@Schema(description = "包装单位")
private String unit;
/**
* 包装单位名称
*/
@Schema(description = "包装单位名称")
private String unitName;
}
/**
* 分类毛利润VO
*/
@Data
@Schema(description = "分类毛利润VO")
public static class CategoryProfitVO {
/**
* 分类ID
*/
@Schema(description = "分类ID")
private Long categoryId;
/**
* 分类名称
*/
@Schema(description = "分类名称")
private String categoryName;
/**
* 销售商品种类数
*/
@Schema(description = "销售商品种类数")
private Integer productCount;
/**
* 销售数量
*/
@Schema(description = "销售数量")
private Double totalSalesQuantity;
/**
* 销售额(元)
*/
@Schema(description = "销售额(元)")
private BigDecimal totalSalesAmount;
/**
* 成本总额(元)
*/
@Schema(description = "成本总额(元)")
private BigDecimal totalCostAmount;
/**
* 毛利润(元)
*/
@Schema(description = "毛利润(元)")
private BigDecimal totalProfitAmount;
/**
* 平均毛利率(%)
*/
@Schema(description = "平均毛利率(%)")
private BigDecimal averageMarginRate;
/**
* 销售笔数
*/
@Schema(description = "销售笔数")
private Integer salesCount;
/**
* 盈利商品数
*/
@Schema(description = "盈利商品数")
private Integer profitableProductCount;
/**
* 亏损商品数
*/
@Schema(description = "亏损商品数")
private Integer lossProductCount;
}
/**
* 时段毛利润VO
*/
@Data
@Schema(description = "时段毛利润VO")
public static class TimePeriodProfitVO {
/**
* 时间段标识(如:09:00, 2025-01-27)
*/
@Schema(description = "时间段标识")
private String timeLabel;
/**
* 销售额(元)
*/
@Schema(description = "销售额(元)")
private BigDecimal salesAmount;
/**
* 成本总额(元)
*/
@Schema(description = "成本总额(元)")
private BigDecimal costAmount;
/**
* 毛利润(元)
*/
@Schema(description = "毛利润(元)")
private BigDecimal profitAmount;
/**
* 毛利率(%)
*/
@Schema(description = "毛利率(%)")
private BigDecimal marginRate;
/**
* 销售数量
*/
@Schema(description = "销售数量")
private Double salesQuantity;
/**
* 销售笔数
*/
@Schema(description = "销售笔数")
private Integer salesCount;
/**
* 销售商品种类数
*/
@Schema(description = "销售商品种类数")
private Integer productCount;
/**
* 利润增长率(%)
*/
@Schema(description = "利润增长率(%)")
private BigDecimal profitGrowthRate;
}
}
@@ -0,0 +1,94 @@
-- 毛利润报表数据库索引优化建议(OceanBase适配版本)
-- 执行前请先备份数据库!
-- 1. 销售记录表索引优化
-- 复合索引:库存类型 + 订单类型 + 创建时间(OceanBase不支持DESC索引)
CREATE INDEX IF NOT EXISTS idx_inventory_records_type_order_time
ON sm_erp_inventory_records (inventory_type, order_type, create_time);
-- 复合索引:库存类型 + 订单类型 + 库存日期
CREATE INDEX IF NOT EXISTS idx_inventory_records_type_order_date
ON sm_erp_inventory_records (inventory_type, order_type, inventory_date);
-- 单列索引:创建时间(用于时间范围查询)
CREATE INDEX IF NOT EXISTS idx_inventory_records_create_time
ON sm_erp_inventory_records (create_time);
-- 单列索引:库存日期(用于日期范围查询)
CREATE INDEX IF NOT EXISTS idx_inventory_records_inventory_date
ON sm_erp_inventory_records (inventory_date);
-- 单列索引:处理人员ID
CREATE INDEX IF NOT EXISTS idx_inventory_records_handler_user_id
ON sm_erp_inventory_records (handler_user_id);
-- 单列索引:仓库ID
CREATE INDEX IF NOT EXISTS idx_inventory_records_warehouse_id
ON sm_erp_inventory_records (warehouse_id);
-- 2. 销售明细表索引优化
-- 复合索引:库存记录ID + 商品SPU ID
CREATE INDEX IF NOT EXISTS idx_inventory_records_item_inventory_spu
ON sm_erp_inventory_records_item (inventory_id, erp_spu_id);
-- 单列索引:商品SPU ID
CREATE INDEX IF NOT EXISTS idx_inventory_records_item_erp_spu_id
ON sm_erp_inventory_records_item (erp_spu_id);
-- 单列索引:包装单位ID
CREATE INDEX IF NOT EXISTS idx_inventory_records_item_unit_id
ON sm_erp_inventory_records_item (unit_id);
-- 3. 商品表索引优化
-- 复合索引:分类ID + 商品名称
CREATE INDEX IF NOT EXISTS idx_erp_spu_category_name
ON sm_erp_spu (category_id, product_name);
-- 单列索引:商品编码
CREATE INDEX IF NOT EXISTS idx_erp_spu_product_code
ON sm_erp_spu (product_code);
-- 单列索引:商品名称
CREATE INDEX IF NOT EXISTS idx_erp_spu_product_name
ON sm_erp_spu (product_name);
-- 单列索引:分类ID
CREATE INDEX IF NOT EXISTS idx_erp_spu_category_id
ON sm_erp_spu (category_id);
-- 4. 包装单位表索引优化
-- 单列索引:商品SPU ID
CREATE INDEX IF NOT EXISTS idx_erp_unit_erp_spu_id
ON sm_erp_unit (spu_id);
-- 单列索引:进价字段(用于成本计算)
CREATE INDEX IF NOT EXISTS idx_erp_unit_purchase_price
ON sm_erp_unit (purchase_price);
-- 5. 分类表索引优化
-- 单列索引:分类名称
CREATE INDEX IF NOT EXISTS idx_erp_category_name
ON sm_erp_category (name);
-- 执行说明(OceanBase适配):
-- 1. 这些索引会显著提升查询性能
-- 2. 索引会占用额外的存储空间
-- 3. 插入和更新操作会稍微变慢(但影响很小)
-- 4. 建议在业务低峰期执行
-- 5. 执行前请先分析现有索引,避免重复创建
-- 6. OceanBase不支持DESC索引,已移除所有DESC关键字
-- 7. 添加了单独的时间字段索引以优化排序查询
-- OceanBase检查现有索引的SQL:
-- SELECT * FROM information_schema.statistics WHERE table_schema = DATABASE() AND table_name = 'sm_erp_inventory_records';
-- SELECT * FROM information_schema.statistics WHERE table_schema = DATABASE() AND table_name = 'sm_erp_inventory_records_item';
-- SELECT * FROM information_schema.statistics WHERE table_schema = DATABASE() AND table_name = 'sm_erp_spu';
-- SELECT * FROM information_schema.statistics WHERE table_schema = DATABASE() AND table_name = 'sm_erp_unit';
-- SELECT * FROM information_schema.statistics WHERE table_schema = DATABASE() AND table_name = 'sm_erp_category';
-- 或者使用SHOW INDEX(如果支持):
-- SHOW INDEX FROM sm_erp_inventory_records;
-- SHOW INDEX FROM sm_erp_inventory_records_item;
-- SHOW INDEX FROM sm_erp_spu;
-- SHOW INDEX FROM sm_erp_unit;
-- SHOW INDEX FROM sm_erp_category;
@@ -0,0 +1,190 @@
package com.bsd.pjcloud.supermarket.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.supermarket.dto.profit.ProfitMarginReportQueryDTO;
import com.bsd.pjcloud.supermarket.service.ProfitMarginReportService;
import com.bsd.pjcloud.supermarket.vo.profit.ProfitMarginReportVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
/**
* 毛利润报表管理
*
* @author pjcloud
* @date 2025-01-27 16:00:00
*/
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/profitMarginReport")
@Tag(description = "profitMarginReport", name = "毛利润报表管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class ProfitMarginReportController {
private final ProfitMarginReportService profitMarginReportService;
@Operation(summary = "获取毛利润报表", description = "获取完整的毛利润报表,包含汇总、排名、趋势等数据")
@GetMapping("/report")
@PreAuthorize("@pms.hasPermission('supermarket_profitMarginReport_view')")
public R<ProfitMarginReportVO> getProfitMarginReport(
@Parameter(description = "查询条件") ProfitMarginReportQueryDTO queryDTO) {
ProfitMarginReportVO result = profitMarginReportService.getProfitMarginReport(queryDTO);
return R.ok(result);
}
@Operation(summary = "获取商品毛利润排名", description = "获取商品毛利润排名,支持多种排序方式")
@GetMapping("/productProfitRanking")
@PreAuthorize("@pms.hasPermission('supermarket_profitMarginReport_view')")
public R<Page<ProfitMarginReportVO.ProductProfitVO>> getProductProfitRanking(
@Parameter(description = "分页参数") Page<ProfitMarginReportVO.ProductProfitVO> page,
@Parameter(description = "查询条件") ProfitMarginReportQueryDTO queryDTO) {
Page<ProfitMarginReportVO.ProductProfitVO> result =
profitMarginReportService.getProductProfitRanking(page, queryDTO);
return R.ok(result);
}
@Operation(summary = "获取分类毛利润分析", description = "获取各商品分类的毛利润分析数据")
@GetMapping("/categoryProfitAnalysis")
@PreAuthorize("@pms.hasPermission('supermarket_profitMarginReport_view')")
public R<Page<ProfitMarginReportVO.CategoryProfitVO>> getCategoryProfitAnalysis(
@Parameter(description = "分页参数") Page<ProfitMarginReportVO.CategoryProfitVO> page,
@Parameter(description = "查询条件") ProfitMarginReportQueryDTO queryDTO) {
Page<ProfitMarginReportVO.CategoryProfitVO> result =
profitMarginReportService.getCategoryProfitAnalysis(page, queryDTO);
return R.ok(result);
}
@Operation(summary = "获取时段毛利润趋势", description = "获取时段毛利润趋势数据,支持按小时、天、月查询")
@GetMapping("/timePeriodProfitTrend")
@PreAuthorize("@pms.hasPermission('supermarket_profitMarginReport_view')")
public R<Page<ProfitMarginReportVO.TimePeriodProfitVO>> getTimePeriodProfitTrend(
@Parameter(description = "分页参数") Page<ProfitMarginReportVO.TimePeriodProfitVO> page,
@Parameter(description = "查询条件") ProfitMarginReportQueryDTO queryDTO) {
Page<ProfitMarginReportVO.TimePeriodProfitVO> result =
profitMarginReportService.getTimePeriodProfitTrend(page, queryDTO);
return R.ok(result);
}
@Operation(summary = "获取高毛利润商品", description = "获取高毛利润商品列表,毛利率大于30%的商品")
@GetMapping("/highProfitProducts")
@PreAuthorize("@pms.hasPermission('supermarket_profitMarginReport_view')")
public R<Page<ProfitMarginReportVO.ProductProfitVO>> getHighProfitProducts(
@Parameter(description = "分页参数") Page<ProfitMarginReportVO.ProductProfitVO> page,
@Parameter(description = "查询条件") ProfitMarginReportQueryDTO queryDTO) {
Page<ProfitMarginReportVO.ProductProfitVO> result =
profitMarginReportService.getHighProfitProducts(page, queryDTO);
return R.ok(result);
}
@Operation(summary = "获取低毛利润/亏损商品", description = "获取低毛利润或亏损商品列表,毛利率小于10%或亏损的商品")
@GetMapping("/lowProfitProducts")
@PreAuthorize("@pms.hasPermission('supermarket_profitMarginReport_view')")
public R<Page<ProfitMarginReportVO.ProductProfitVO>> getLowProfitProducts(
@Parameter(description = "分页参数") Page<ProfitMarginReportVO.ProductProfitVO> page,
@Parameter(description = "查询条件") ProfitMarginReportQueryDTO queryDTO) {
Page<ProfitMarginReportVO.ProductProfitVO> result =
profitMarginReportService.getLowProfitProducts(page, queryDTO);
return R.ok(result);
}
@Operation(summary = "获取毛利润汇总信息", description = "获取毛利润汇总信息,包含总销售额、总成本、总毛利润等")
@GetMapping("/profitSummary")
@PreAuthorize("@pms.hasPermission('supermarket_profitMarginReport_view')")
public R<ProfitMarginReportVO.ProfitSummaryVO> getProfitSummary(
@Parameter(description = "查询条件") ProfitMarginReportQueryDTO queryDTO) {
ProfitMarginReportVO.ProfitSummaryVO result =
profitMarginReportService.getProfitSummary(queryDTO);
return R.ok(result);
}
@Operation(summary = "导出毛利润报表", description = "导出毛利润报表数据为Excel文件")
@PostMapping("/export")
@SysLog("导出毛利润报表")
@PreAuthorize("@pms.hasPermission('supermarket_profitMarginReport_export')")
public R<String> exportProfitMarginReport(
@Parameter(description = "查询条件") @RequestBody ProfitMarginReportQueryDTO queryDTO) {
// TODO: 实现Excel导出功能
return R.ok("导出功能待实现");
}
@Operation(summary = "调试毛利润报表", description = "调试毛利润报表查询,输出详细日志")
@GetMapping("/debug")
@PreAuthorize("@pms.hasPermission('supermarket_profitMarginReport_view')")
public R<String> debugProfitMarginReport(
@Parameter(description = "查询条件") ProfitMarginReportQueryDTO queryDTO) {
try {
// 调用汇总方法,会输出调试日志
profitMarginReportService.getProfitSummary(queryDTO);
return R.ok("调试完成,请查看日志输出");
} catch (Exception e) {
return R.failed("调试失败: " + e.getMessage());
}
}
@GetMapping("/debug/category")
@PreAuthorize("@pms.hasPermission('supermarket_profitMarginReport_view')")
public R<String> debugCategoryFilter(
@Parameter(description = "分类ID") @RequestParam(required = false) Long categoryId,
@Parameter(description = "商品名称") @RequestParam(required = false) String productName) {
try {
ProfitMarginReportQueryDTO queryDTO = new ProfitMarginReportQueryDTO();
queryDTO.setCategoryId(categoryId);
queryDTO.setProductName(productName);
// 调用汇总方法,会输出调试日志
profitMarginReportService.getProfitSummary(queryDTO);
return R.ok("分类筛选调试完成,请查看日志输出");
} catch (Exception e) {
return R.failed("分类筛选调试失败: " + e.getMessage());
}
}
@GetMapping("/fast")
@PreAuthorize("@pms.hasPermission('supermarket_profitMarginReport_view')")
@Operation(summary = "快速查询毛利润报表", description = "高性能版本的毛利润报表查询,适用于大数据量场景")
public R<ProfitMarginReportVO.ProfitSummaryVO> getProfitSummaryFast(
@Parameter(description = "查询条件") ProfitMarginReportQueryDTO queryDTO) {
try {
// 强制启用分页模式
if (queryDTO.getPageNum() == null) queryDTO.setPageNum(1);
if (queryDTO.getPageSize() == null) queryDTO.setPageSize(500);
ProfitMarginReportVO.ProfitSummaryVO result = profitMarginReportService.getProfitSummary(queryDTO);
return R.ok(result);
} catch (Exception e) {
log.error("快速查询毛利润报表失败", e);
return R.failed("查询失败: " + e.getMessage());
}
}
@GetMapping("/fast/ranking")
@PreAuthorize("@pms.hasPermission('supermarket_profitMarginReport_view')")
@Operation(summary = "快速查询商品毛利润排名", description = "高性能版本的商品毛利润排名查询")
public R<Page<ProfitMarginReportVO.ProductProfitVO>> getProductProfitRankingFast(
@Parameter(description = "查询条件") ProfitMarginReportQueryDTO queryDTO) {
try {
// 强制启用分页模式
if (queryDTO.getPageNum() == null) queryDTO.setPageNum(1);
if (queryDTO.getPageSize() == null) queryDTO.setPageSize(500);
if (queryDTO.getTopLimit() == null) queryDTO.setTopLimit(50);
// 创建分页对象
Page<ProfitMarginReportVO.ProductProfitVO> page = new Page<>(queryDTO.getPageNum(), queryDTO.getPageSize());
Page<ProfitMarginReportVO.ProductProfitVO> result = profitMarginReportService.getProductProfitRanking(page, queryDTO);
return R.ok(result);
} catch (Exception e) {
log.error("快速查询商品毛利润排名失败", e);
return R.failed("查询失败: " + e.getMessage());
}
}
}
@@ -0,0 +1,77 @@
package com.bsd.pjcloud.supermarket.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.supermarket.dto.profit.ProfitMarginReportQueryDTO;
import com.bsd.pjcloud.supermarket.vo.profit.ProfitMarginReportVO;
import java.util.List;
/**
* 毛利润报表服务接口
*
* @author pjcloud
* @date 2025-01-27 16:00:00
*/
public interface ProfitMarginReportService {
/**
* 获取毛利润报表
*
* @param queryDTO 查询条件
* @return 毛利润报表
*/
ProfitMarginReportVO getProfitMarginReport(ProfitMarginReportQueryDTO queryDTO);
/**
* 获取商品毛利润排名
*
* @param page 分页参数
* @param queryDTO 查询条件
* @return 商品毛利润排名
*/
Page<ProfitMarginReportVO.ProductProfitVO> getProductProfitRanking(Page<ProfitMarginReportVO.ProductProfitVO> page, ProfitMarginReportQueryDTO queryDTO);
/**
* 获取分类毛利润分析
*
* @param page 分页参数
* @param queryDTO 查询条件
* @return 分类毛利润分析
*/
Page<ProfitMarginReportVO.CategoryProfitVO> getCategoryProfitAnalysis(Page<ProfitMarginReportVO.CategoryProfitVO> page, ProfitMarginReportQueryDTO queryDTO);
/**
* 获取时段毛利润趋势
*
* @param page 分页参数
* @param queryDTO 查询条件
* @return 时段毛利润趋势
*/
Page<ProfitMarginReportVO.TimePeriodProfitVO> getTimePeriodProfitTrend(Page<ProfitMarginReportVO.TimePeriodProfitVO> page, ProfitMarginReportQueryDTO queryDTO);
/**
* 获取高毛利润商品
*
* @param page 分页参数
* @param queryDTO 查询条件
* @return 高毛利润商品
*/
Page<ProfitMarginReportVO.ProductProfitVO> getHighProfitProducts(Page<ProfitMarginReportVO.ProductProfitVO> page, ProfitMarginReportQueryDTO queryDTO);
/**
* 获取低毛利润/亏损商品
*
* @param page 分页参数
* @param queryDTO 查询条件
* @return 低毛利润/亏损商品
*/
Page<ProfitMarginReportVO.ProductProfitVO> getLowProfitProducts(Page<ProfitMarginReportVO.ProductProfitVO> page, ProfitMarginReportQueryDTO queryDTO);
/**
* 获取毛利润汇总信息
*
* @param queryDTO 查询条件
* @return 毛利润汇总信息
*/
ProfitMarginReportVO.ProfitSummaryVO getProfitSummary(ProfitMarginReportQueryDTO queryDTO);
}