feat(wms,oms):出库排名统计改造为仓单×货品明细列表,按出库数量降序排名

- 字段:种类/仓单编号/入库单号/客户编号/收货人/货名/线路/件数/毛重(吨)/体积(CBM)/退保总额(占位null,数据来源待确认)/出仓日期

- 商品/线路各一套接口,路径名不变;商品接口忽略线路筛选参数,线路接口忽略商品筛选参数;含合计行(件数/毛重吨/体积/仓单数)与Excel导出

- 统计口径不变:出库单创建时间区间+已出库状态(9,12,13)+明细level=1主行;排序按出库数量(销售量)降序,件数/出仓日期/单号次之

- 数据源:WMS查本库出库表;OMS跨库查NGWL_TEST_WMS同名表(OMS库出库单状态不流转,跨库与WMS端数字一致)

- 删除原按商品/线路聚合的排名接口(销售量/交易数/金额字段)
This commit is contained in:
rcx
2026-09-02 15:25:51 +08:00
parent e821619a96
commit 3af78d5d7b
28 changed files with 554 additions and 684 deletions
@@ -1,14 +1,13 @@
package com.mhd.oms.domain.outboundRank.repository.facade;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundLineRankPO;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundMaterialRankPO;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundRankTotalPO;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundDetailRankPO;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundDetailRankTotalPO;
import com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO;
import java.util.List;
/**
* 出库排名统计Service接口
* 出库排名统计(明细)Service接口
*
* @author rcx
* @date 2026-08-31
@@ -16,22 +15,12 @@ import java.util.List;
public interface IExecutionOutboundRankService {
/**
* 商品出库排名列表
* 出库明细列表
*/
List<ExecutionOutboundMaterialRankPO> queryMaterialRankList(ExecutionOutboundRankDO executionOutboundRankDO);
List<ExecutionOutboundDetailRankPO> queryDetailList(ExecutionOutboundRankDO executionOutboundRankDO);
/**
* 线路出库排名列表
* 出库明细合计(不分页)
*/
List<ExecutionOutboundLineRankPO> queryLineRankList(ExecutionOutboundRankDO executionOutboundRankDO);
/**
* 商品出库排名合计(不分页)
*/
ExecutionOutboundRankTotalPO queryMaterialRankTotal(ExecutionOutboundRankDO executionOutboundRankDO);
/**
* 线路出库排名合计(不分页)
*/
ExecutionOutboundRankTotalPO queryLineRankTotal(ExecutionOutboundRankDO executionOutboundRankDO);
ExecutionOutboundDetailRankTotalPO queryDetailTotal(ExecutionOutboundRankDO executionOutboundRankDO);
}
@@ -1,14 +1,13 @@
package com.mhd.oms.domain.outboundRank.repository.mapper;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundLineRankPO;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundMaterialRankPO;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundRankTotalPO;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundDetailRankPO;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundDetailRankTotalPO;
import com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO;
import java.util.List;
/**
* 出库排名统计Mapper接口
* 出库排名统计(明细)Mapper接口
*
* @author rcx
* @date 2026-08-31
@@ -16,22 +15,12 @@ import java.util.List;
public interface ExecutionOutboundRankMapper {
/**
* 商品出库排名列表(按销售量倒序)
* 出库明细列表(一行=仓单×货品,按件数倒序)
*/
List<ExecutionOutboundMaterialRankPO> queryMaterialRankList(ExecutionOutboundRankDO executionOutboundRankDO);
List<ExecutionOutboundDetailRankPO> queryDetailList(ExecutionOutboundRankDO executionOutboundRankDO);
/**
* 线路出库排名列表(按销售量倒序
* 出库明细合计(不分页,当前筛选条件全量合计
*/
List<ExecutionOutboundLineRankPO> queryLineRankList(ExecutionOutboundRankDO executionOutboundRankDO);
/**
* 商品出库排名合计(不分页,当前筛选条件全量合计)
*/
ExecutionOutboundRankTotalPO queryMaterialRankTotal(ExecutionOutboundRankDO executionOutboundRankDO);
/**
* 线路出库排名合计(不分页,当前筛选条件全量合计)
*/
ExecutionOutboundRankTotalPO queryLineRankTotal(ExecutionOutboundRankDO executionOutboundRankDO);
ExecutionOutboundDetailRankTotalPO queryDetailTotal(ExecutionOutboundRankDO executionOutboundRankDO);
}
@@ -2,9 +2,8 @@ package com.mhd.oms.domain.outboundRank.repository.persistence;
import com.mhd.oms.domain.outboundRank.repository.facade.IExecutionOutboundRankService;
import com.mhd.oms.domain.outboundRank.repository.mapper.ExecutionOutboundRankMapper;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundLineRankPO;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundMaterialRankPO;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundRankTotalPO;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundDetailRankPO;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundDetailRankTotalPO;
import com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -12,7 +11,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
/**
* 出库排名统计Service业务层处理
* 出库排名统计(明细)Service业务层处理
*
* @author rcx
* @date 2026-08-31
@@ -24,22 +23,12 @@ public class ExecutionOutboundRankImpl implements IExecutionOutboundRankService
private ExecutionOutboundRankMapper executionOutboundRankMapper;
@Override
public List<ExecutionOutboundMaterialRankPO> queryMaterialRankList(ExecutionOutboundRankDO executionOutboundRankDO) {
return executionOutboundRankMapper.queryMaterialRankList(executionOutboundRankDO);
public List<ExecutionOutboundDetailRankPO> queryDetailList(ExecutionOutboundRankDO executionOutboundRankDO) {
return executionOutboundRankMapper.queryDetailList(executionOutboundRankDO);
}
@Override
public List<ExecutionOutboundLineRankPO> queryLineRankList(ExecutionOutboundRankDO executionOutboundRankDO) {
return executionOutboundRankMapper.queryLineRankList(executionOutboundRankDO);
}
@Override
public ExecutionOutboundRankTotalPO queryMaterialRankTotal(ExecutionOutboundRankDO executionOutboundRankDO) {
return executionOutboundRankMapper.queryMaterialRankTotal(executionOutboundRankDO);
}
@Override
public ExecutionOutboundRankTotalPO queryLineRankTotal(ExecutionOutboundRankDO executionOutboundRankDO) {
return executionOutboundRankMapper.queryLineRankTotal(executionOutboundRankDO);
public ExecutionOutboundDetailRankTotalPO queryDetailTotal(ExecutionOutboundRankDO executionOutboundRankDO) {
return executionOutboundRankMapper.queryDetailTotal(executionOutboundRankDO);
}
}
@@ -0,0 +1,85 @@
package com.mhd.oms.domain.outboundRank.repository.po;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* 出库排名统计(明细)PO(一行 = 仓单×货品,件数/毛重/体积按行汇总)
*
* <p>字段口径:种类=出库单据类型;仓单编号=出库单号;收货人=出库单 TO 栏(为空取联系人);
* 毛重(吨)=明细总毛重KG/1000;出仓日期=出仓日期(为空依次兜底完成时间/创建时间);
* 退保总额为占位字段,后端暂无对应数据来源,恒为 null(候选:货品档案保额 insure_amount,确认后可补)</p>
*
* @author rcx
* @date 2026-08-31
*/
@Data
@ApiModel(value = "出库排名统计明细对象", description = "出库排名统计明细响应对象")
public class ExecutionOutboundDetailRankPO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("种类(出库单据类型)")
@Excel(name = "种类")
private String orderTypeName;
@ApiModelProperty("仓单编号(出库单号)")
@Excel(name = "仓单编号")
private String outOrderNumber;
@ApiModelProperty("入库单号")
@Excel(name = "入库单号")
private String inOrderNumber;
@ApiModelProperty("客户编号")
@Excel(name = "客户编号")
private String customerCode;
@ApiModelProperty("收货人(出库单 TO 栏,为空取联系人)")
@Excel(name = "收货人")
private String receiver;
@ApiModelProperty("商品货号(辅助字段,不导出)")
private String materialCode;
@ApiModelProperty("货名")
@Excel(name = "货名")
private String materialName;
@ApiModelProperty("线路编码(辅助字段,不导出)")
private String lineCode;
@ApiModelProperty("线路")
@Excel(name = "线路")
private String lineName;
@ApiModelProperty("件数")
@Excel(name = "件数")
private BigDecimal pieceCount;
@ApiModelProperty("毛重(吨)")
@Excel(name = "毛重(吨)")
private BigDecimal grossWeightTon;
@ApiModelProperty("体积(CBM)")
@Excel(name = "体积(CBM)")
private BigDecimal totalVolume;
@ApiModelProperty("退保总额(占位字段,后端暂无数据来源,恒为 null)")
@Excel(name = "退保总额")
private BigDecimal depositRefundAmount;
@ApiModelProperty("出仓日期(出仓日期为空时依次兜底完成时间/创建时间)")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@Excel(name = "出仓日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date outboundDate;
}
@@ -0,0 +1,36 @@
package com.mhd.oms.domain.outboundRank.repository.po;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 出库排名统计(明细)合计PO
*
* <p>当前筛选条件下不分页的全量合计,随分页列表一起返回
* totalPieceCount/totalGrossWeightTon/totalVolume/totalOrderCount</p>
*
* @author rcx
* @date 2026-08-31
*/
@Data
@ApiModel(value = "出库排名统计明细合计对象", description = "出库排名统计明细合计响应对象")
public class ExecutionOutboundDetailRankTotalPO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("件数合计")
private BigDecimal totalPieceCount;
@ApiModelProperty("毛重(吨)合计")
private BigDecimal totalGrossWeightTon;
@ApiModelProperty("体积(CBM)合计")
private BigDecimal totalVolume;
@ApiModelProperty("仓单数合计(去重出库单数)")
private Long totalOrderCount;
}
@@ -1,45 +0,0 @@
package com.mhd.oms.domain.outboundRank.repository.po;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 线路出库排名PO
*
* <p>按日期区间对出库单聚合:销售量=SUM(出库数量),交易数=COUNT(DISTINCT 出库单号),金额=SUM(明细总价);
* 仅统计带线路的出库单(line_code 为 2026-08-20 新增冗余字段,历史单为空)</p>
*
* @author rcx
* @date 2026-08-31
*/
@Data
@ApiModel(value = "线路出库排名对象", description = "线路出库排名响应对象")
public class ExecutionOutboundLineRankPO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("线路编码")
@Excel(name = "线路编码")
private String lineCode;
@ApiModelProperty("线路名称")
@Excel(name = "线路名称")
private String lineName;
@ApiModelProperty("销售量(出库数量合计)")
@Excel(name = "销售量")
private BigDecimal salesQuantity;
@ApiModelProperty("交易数(出库单据数)")
@Excel(name = "交易数")
private Long tradeCount;
@ApiModelProperty("金额")
@Excel(name = "金额")
private BigDecimal amount;
}
@@ -1,52 +0,0 @@
package com.mhd.oms.domain.outboundRank.repository.po;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 商品出库排名PO
*
* <p>按日期区间对出库明细聚合:销售量=SUM(出库数量),交易数=COUNT(DISTINCT 出库单号),金额=SUM(明细总价)</p>
*
* @author rcx
* @date 2026-08-31
*/
@Data
@ApiModel(value = "商品出库排名对象", description = "商品出库排名响应对象")
public class ExecutionOutboundMaterialRankPO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("商品货号")
@Excel(name = "商品货号")
private String materialCode;
@ApiModelProperty("商品名称")
@Excel(name = "商品名称")
private String materialName;
@ApiModelProperty("规格")
@Excel(name = "规格")
private String specificationModel;
@ApiModelProperty("单位")
@Excel(name = "单位")
private String unitName;
@ApiModelProperty("销售量(出库数量合计)")
@Excel(name = "销售量")
private BigDecimal salesQuantity;
@ApiModelProperty("交易数(出库单据数)")
@Excel(name = "交易数")
private Long tradeCount;
@ApiModelProperty("金额")
@Excel(name = "金额")
private BigDecimal amount;
}
@@ -1,32 +0,0 @@
package com.mhd.oms.domain.outboundRank.repository.po;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 出库排名合计PO
*
* <p>当前筛选条件下不分页的全量合计,随分页列表一起返回(totalSalesQuantity/totalTradeCount/totalAmount</p>
*
* @author rcx
* @date 2026-08-31
*/
@Data
@ApiModel(value = "出库排名合计对象", description = "出库排名合计响应对象")
public class ExecutionOutboundRankTotalPO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("销售量合计")
private BigDecimal totalSalesQuantity;
@ApiModelProperty("交易数合计(去重出库单数)")
private Long totalTradeCount;
@ApiModelProperty("金额合计")
private BigDecimal totalAmount;
}
@@ -6,7 +6,7 @@ import lombok.Data;
import java.io.Serializable;
/**
* 出库排名统计查询DO
* 出库排名统计(明细)查询DO
*
* <p>topOrganizationId 由服务端按登录用户注入,前端不传</p>
*
@@ -24,10 +24,16 @@ public class ExecutionOutboundRankDO implements Serializable {
@ApiModelProperty("出库日期-结束 yyyy-MM-dd(必填)")
private String createTimeEnd;
@ApiModelProperty("仓单编号/出库单号(模糊)")
private String outOrderNumber;
@ApiModelProperty("入库单号(模糊)")
private String inOrderNumber;
@ApiModelProperty("商品货号(模糊)")
private String materialCode;
@ApiModelProperty("商品名称(模糊)")
@ApiModelProperty("货名/商品名称(模糊)")
private String materialName;
@ApiModelProperty("线路编码(模糊)")
@@ -6,27 +6,35 @@ import lombok.Data;
import java.io.Serializable;
/**
* 出库排名统计入参DTO
* 出库排名统计(明细)入参DTO
*
* <p>按日期区间统计商品/线路出库量排名。OMS 库出库单状态不流转(无"已出库"数据),
* 数据源跨库取 WMS 库出库表NGWL_TEST_WMS.stock_out_order / out_material_detail,与 WMS 端 /outboundRankApi 同口径</p>
* <p>按日期区间筛选出库明细列表,一行 = 仓单×货品(件数/毛重/体积按行汇总,件数降序)。
* OMS 库出库单状态不流转(无"已出库"数据),数据源跨库取 WMS 库出库表,与 WMS 端 /outboundRankApi 同口径</p>
*
* @author rcx
* @date 2026-08-31
*/
@Data
public class ExecutionOutboundRankDTO {
public class ExecutionOutboundRankDTO implements Serializable {
@ApiModelProperty("出库日期-开始 yyyy-MM-dd(必填,按出库单创建时间统计)")
private static final long serialVersionUID = 1L;
@ApiModelProperty("出库日期-开始 yyyy-MM-dd(必填,按出库单创建时间筛选)")
private String createTimeStart;
@ApiModelProperty("出库日期-结束 yyyy-MM-dd(必填,按出库单创建时间统计")
@ApiModelProperty("出库日期-结束 yyyy-MM-dd(必填,按出库单创建时间筛选")
private String createTimeEnd;
@ApiModelProperty("仓单编号/出库单号(模糊)")
private String outOrderNumber;
@ApiModelProperty("入库单号(模糊)")
private String inOrderNumber;
@ApiModelProperty("商品货号(模糊)")
private String materialCode;
@ApiModelProperty("商品名称(模糊)")
@ApiModelProperty("货名/商品名称(模糊)")
private String materialName;
@ApiModelProperty("线路编码(模糊)")
@@ -4,9 +4,8 @@ import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundLineRankPO;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundMaterialRankPO;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundRankTotalPO;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundDetailRankPO;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundDetailRankTotalPO;
import com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -15,9 +14,9 @@ import org.springframework.stereotype.Service;
import java.util.List;
/**
* 出库排名统计应用服务
* 出库排名统计(明细)应用服务
*
* <p>负责登录用户组织隔离注入、日期区间校验,统计逻辑在 ExecutionOutboundRankDomainService → ExecutionOutboundRankMapper.xml(跨库取 WMS 出库数据)</p>
* <p>负责登录用户组织隔离注入、日期区间校验,查询逻辑在 ExecutionOutboundRankDomainService → ExecutionOutboundRankMapper.xml(跨库取 WMS 出库数据)</p>
*
* @author rcx
* @date 2026-08-31
@@ -30,49 +29,26 @@ public class ExecutionOutboundRankApplicationService {
private ExecutionOutboundRankDomainService executionOutboundRankDomainService;
/**
* 分页查询商品出库排名列表
* 分页查询出库明细列表
*/
public List<ExecutionOutboundMaterialRankPO> queryMaterialRankList(ExecutionOutboundRankDO executionOutboundRankDO) {
public List<ExecutionOutboundDetailRankPO> queryDetailList(ExecutionOutboundRankDO executionOutboundRankDO) {
fillLoginContext(executionOutboundRankDO);
return executionOutboundRankDomainService.queryMaterialRankList(executionOutboundRankDO);
return executionOutboundRankDomainService.queryDetailList(executionOutboundRankDO);
}
/**
* 分页查询线路出库排名列表
* 出库明细合计(当前筛选条件全量,不分页)
*/
public List<ExecutionOutboundLineRankPO> queryLineRankList(ExecutionOutboundRankDO executionOutboundRankDO) {
public ExecutionOutboundDetailRankTotalPO queryDetailTotal(ExecutionOutboundRankDO executionOutboundRankDO) {
return executionOutboundRankDomainService.queryDetailTotal(executionOutboundRankDO);
}
/**
* 导出出库明细(不分页全量)
*/
public List<ExecutionOutboundDetailRankPO> exportDetailList(ExecutionOutboundRankDO executionOutboundRankDO) {
fillLoginContext(executionOutboundRankDO);
return executionOutboundRankDomainService.queryLineRankList(executionOutboundRankDO);
}
/**
* 商品出库排名合计(当前筛选条件全量,不分页)
*/
public ExecutionOutboundRankTotalPO queryMaterialRankTotal(ExecutionOutboundRankDO executionOutboundRankDO) {
return executionOutboundRankDomainService.queryMaterialRankTotal(executionOutboundRankDO);
}
/**
* 线路出库排名合计(当前筛选条件全量,不分页)
*/
public ExecutionOutboundRankTotalPO queryLineRankTotal(ExecutionOutboundRankDO executionOutboundRankDO) {
return executionOutboundRankDomainService.queryLineRankTotal(executionOutboundRankDO);
}
/**
* 导出商品出库排名(不分页全量)
*/
public List<ExecutionOutboundMaterialRankPO> exportMaterialRankList(ExecutionOutboundRankDO executionOutboundRankDO) {
fillLoginContext(executionOutboundRankDO);
return executionOutboundRankDomainService.queryMaterialRankList(executionOutboundRankDO);
}
/**
* 导出线路出库排名(不分页全量)
*/
public List<ExecutionOutboundLineRankPO> exportLineRankList(ExecutionOutboundRankDO executionOutboundRankDO) {
fillLoginContext(executionOutboundRankDO);
return executionOutboundRankDomainService.queryLineRankList(executionOutboundRankDO);
return executionOutboundRankDomainService.queryDetailList(executionOutboundRankDO);
}
/**
@@ -1,9 +1,8 @@
package com.mhd.oms.domain.outboundRank.service;
import com.mhd.oms.domain.outboundRank.repository.facade.IExecutionOutboundRankService;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundLineRankPO;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundMaterialRankPO;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundRankTotalPO;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundDetailRankPO;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundDetailRankTotalPO;
import com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -12,7 +11,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
/**
* 出库排名统计领域服务
* 出库排名统计(明细)领域服务
*
* @author rcx
* @date 2026-08-31
@@ -25,30 +24,16 @@ public class ExecutionOutboundRankDomainService {
private IExecutionOutboundRankService executionOutboundRankService;
/**
* 商品出库排名列表
* 出库明细列表
*/
public List<ExecutionOutboundMaterialRankPO> queryMaterialRankList(ExecutionOutboundRankDO executionOutboundRankDO) {
return executionOutboundRankService.queryMaterialRankList(executionOutboundRankDO);
public List<ExecutionOutboundDetailRankPO> queryDetailList(ExecutionOutboundRankDO executionOutboundRankDO) {
return executionOutboundRankService.queryDetailList(executionOutboundRankDO);
}
/**
* 线路出库排名列表
* 出库明细合计(不分页)
*/
public List<ExecutionOutboundLineRankPO> queryLineRankList(ExecutionOutboundRankDO executionOutboundRankDO) {
return executionOutboundRankService.queryLineRankList(executionOutboundRankDO);
}
/**
* 商品出库排名合计(不分页)
*/
public ExecutionOutboundRankTotalPO queryMaterialRankTotal(ExecutionOutboundRankDO executionOutboundRankDO) {
return executionOutboundRankService.queryMaterialRankTotal(executionOutboundRankDO);
}
/**
* 线路出库排名合计(不分页)
*/
public ExecutionOutboundRankTotalPO queryLineRankTotal(ExecutionOutboundRankDO executionOutboundRankDO) {
return executionOutboundRankService.queryLineRankTotal(executionOutboundRankDO);
public ExecutionOutboundDetailRankTotalPO queryDetailTotal(ExecutionOutboundRankDO executionOutboundRankDO) {
return executionOutboundRankService.queryDetailTotal(executionOutboundRankDO);
}
}
@@ -4,9 +4,8 @@ import com.github.pagehelper.PageInfo;
import com.mhd.common.core.constant.HttpStatus;
import com.mhd.common.core.utils.PageUtils;
import com.mhd.common.core.utils.poi.ExcelUtil;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundLineRankPO;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundMaterialRankPO;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundRankTotalPO;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundDetailRankPO;
import com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundDetailRankTotalPO;
import com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO;
import com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDTO;
import com.mhd.oms.domain.outboundRank.service.ExecutionOutboundRankApplicationService;
@@ -27,11 +26,11 @@ import java.util.List;
/**
* 出库排名统计Api
*
* <p>按日期区间筛选,统计商品/线路出库量排名。OMS 库出库单状态不流转(无"已出库"数据),
* 数据源跨库取 WMS 库出库表(NGWL_TEST_WMS.stock_out_order / out_material_detail),
* 口径与 WMS 端 /outboundRankApi 完全一致,两边数字一致;
* 统计条件:出库单创建时间 + 已出库及之后状态(9,12,13),明细仅取 level=1 主行;
* 销售量=SUM(出库数量)、交易数=COUNT(DISTINCT 出库单号)、金额=SUM(明细总价)</p>
* <p>按日期区间筛选出库明细列表(一行 = 仓单×货品,件数/毛重/体积按行汇总,按出库数量(销售量)降序,件数/出仓日期/单号次之)。
* OMS 库出库单状态不流转(无"已出库"数据),数据源跨库取 WMS 库出库表(NGWL_TEST_WMS.stock_out_order / out_material_detail),
* 口径与 WMS 端 /outboundRankApi 完全一致,两边数字一致;统计条件:出库单创建时间 + 已出库及之后状态(9,12,13),明细仅取 level=1 主行。
* 商品/线路两个 tab 各自独立接口,内部为同一份明细查询:商品接口忽略线路筛选参数,线路接口忽略商品筛选参数。
* 字段:种类/仓单编号/入库单号/客户编号/收货人/货名/线路/件数/毛重(吨)/体积(CBM)/退保总额(占位null)/出仓日期</p>
*
* @author rcx
* @date 2026-08-31
@@ -48,84 +47,97 @@ public class ExecutionOutboundRankApi {
private ExecutionOutboundRankApplicationService executionOutboundRankApplicationService;
/**
* 分页查询商品出库排名列表(含合计行)
* 分页查询商品出库排名列表(含合计行,商品tab;忽略线路筛选参数
*/
@ApiOperation("分页查询商品出库排名列表")
@GetMapping("/queryMaterialRankList")
public HashMap<String, Object> queryMaterialRankList(ExecutionOutboundRankDTO executionOutboundRankDTO) {
//转换实体
ExecutionOutboundRankDO executionOutboundRankDO = executionOutboundRankAssembler.toDO(executionOutboundRankDTO);
//商品tab:忽略线路筛选参数
executionOutboundRankDO.setLineCode(null);
executionOutboundRankDO.setLineName(null);
startPage();
List<ExecutionOutboundMaterialRankPO> list = executionOutboundRankApplicationService.queryMaterialRankList(executionOutboundRankDO);
ExecutionOutboundRankTotalPO total = executionOutboundRankApplicationService.queryMaterialRankTotal(executionOutboundRankDO);
List<ExecutionOutboundDetailRankPO> list = executionOutboundRankApplicationService.queryDetailList(executionOutboundRankDO);
ExecutionOutboundDetailRankTotalPO total = executionOutboundRankApplicationService.queryDetailTotal(executionOutboundRankDO);
return getDataTableWithTotal(list, total);
}
/**
* 分页查询线路出库排名列表(含合计行)
* 分页查询线路出库排名列表(含合计行,线路tab;忽略商品筛选参数
*/
@ApiOperation("分页查询线路出库排名列表")
@GetMapping("/queryLineRankList")
public HashMap<String, Object> queryLineRankList(ExecutionOutboundRankDTO executionOutboundRankDTO) {
//转换实体
ExecutionOutboundRankDO executionOutboundRankDO = executionOutboundRankAssembler.toDO(executionOutboundRankDTO);
//线路tab:忽略商品筛选参数
executionOutboundRankDO.setMaterialCode(null);
executionOutboundRankDO.setMaterialName(null);
startPage();
List<ExecutionOutboundLineRankPO> list = executionOutboundRankApplicationService.queryLineRankList(executionOutboundRankDO);
ExecutionOutboundRankTotalPO total = executionOutboundRankApplicationService.queryLineRankTotal(executionOutboundRankDO);
List<ExecutionOutboundDetailRankPO> list = executionOutboundRankApplicationService.queryDetailList(executionOutboundRankDO);
ExecutionOutboundDetailRankTotalPO total = executionOutboundRankApplicationService.queryDetailTotal(executionOutboundRankDO);
return getDataTableWithTotal(list, total);
}
/**
* 导出商品出库排名Excel
* 导出商品出库排名Excel(商品tab;忽略线路筛选参数)
*/
@ApiOperation("导出商品出库排名Excel")
@GetMapping("/exportMaterialRank")
public void exportMaterialRank(HttpServletResponse response, ExecutionOutboundRankDTO executionOutboundRankDTO) throws Exception {
//转换实体(不分页,导出全量)
ExecutionOutboundRankDO executionOutboundRankDO = executionOutboundRankAssembler.toDO(executionOutboundRankDTO);
List<ExecutionOutboundMaterialRankPO> list = executionOutboundRankApplicationService.exportMaterialRankList(executionOutboundRankDO);
//商品tab:忽略线路筛选参数
executionOutboundRankDO.setLineCode(null);
executionOutboundRankDO.setLineName(null);
List<ExecutionOutboundDetailRankPO> list = executionOutboundRankApplicationService.exportDetailList(executionOutboundRankDO);
String fileName = URLEncoder.encode("商品出库排名", "UTF-8").replaceAll("\\+", "%20");
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
ExcelUtil<ExecutionOutboundMaterialRankPO> util = new ExcelUtil<>(ExecutionOutboundMaterialRankPO.class);
ExcelUtil<ExecutionOutboundDetailRankPO> util = new ExcelUtil<>(ExecutionOutboundDetailRankPO.class);
util.exportExcel(response, list, "商品出库排名");
}
/**
* 导出线路出库排名Excel
* 导出线路出库排名Excel(线路tab;忽略商品筛选参数)
*/
@ApiOperation("导出线路出库排名Excel")
@GetMapping("/exportLineRank")
public void exportLineRank(HttpServletResponse response, ExecutionOutboundRankDTO executionOutboundRankDTO) throws Exception {
//转换实体(不分页,导出全量)
ExecutionOutboundRankDO executionOutboundRankDO = executionOutboundRankAssembler.toDO(executionOutboundRankDTO);
List<ExecutionOutboundLineRankPO> list = executionOutboundRankApplicationService.exportLineRankList(executionOutboundRankDO);
//线路tab:忽略商品筛选参数
executionOutboundRankDO.setMaterialCode(null);
executionOutboundRankDO.setMaterialName(null);
List<ExecutionOutboundDetailRankPO> list = executionOutboundRankApplicationService.exportDetailList(executionOutboundRankDO);
String fileName = URLEncoder.encode("线路出库排名", "UTF-8").replaceAll("\\+", "%20");
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
ExcelUtil<ExecutionOutboundLineRankPO> util = new ExcelUtil<>(ExecutionOutboundLineRankPO.class);
ExcelUtil<ExecutionOutboundDetailRankPO> util = new ExcelUtil<>(ExecutionOutboundDetailRankPO.class);
util.exportExcel(response, list, "线路出库排名");
}
/**
* 分页结果 + 合计行:data/total/code/msg 之外追加 totalSalesQuantity/totalTradeCount/totalAmount
* 分页结果 + 合计行:data/total/code/msg 之外追加 totalPieceCount/totalGrossWeightTon/totalVolume/totalOrderCount
*/
private HashMap<String, Object> getDataTableWithTotal(List<?> list, ExecutionOutboundRankTotalPO total) {
private HashMap<String, Object> getDataTableWithTotal(List<?> list, ExecutionOutboundDetailRankTotalPO total) {
HashMap<String, Object> result = new HashMap<>();
result.put("data", list);
result.put("total", new PageInfo<>(list).getTotal());
result.put("code", HttpStatus.SUCCESS);
result.put("msg", "查询成功");
if (total != null) {
result.put("totalSalesQuantity", total.getTotalSalesQuantity());
result.put("totalTradeCount", total.getTotalTradeCount());
result.put("totalAmount", total.getTotalAmount());
result.put("totalPieceCount", total.getTotalPieceCount());
result.put("totalGrossWeightTon", total.getTotalGrossWeightTon());
result.put("totalVolume", total.getTotalVolume());
result.put("totalOrderCount", total.getTotalOrderCount());
}
return result;
}
@@ -5,14 +5,14 @@
<mapper namespace="com.mhd.oms.domain.outboundRank.repository.mapper.ExecutionOutboundRankMapper">
<!--
出库排名统计公共查询条件(OMS 端,跨库取 WMS 出库数据)
出库排名统计(明细)公共查询条件(OMS 端,跨库取 WMS 出库数据)
数据源:WMS 库出库明细 NGWL_TEST_WMS.out_material_detail(a,仅 level=1 主行防重复)
join WMS 库出库单 NGWL_TEST_WMS.stock_out_order(b)
说明:OMS 库出库单状态不流转(无"已出库"数据),"已出库"状态的真实数据在 WMS 库,
故跨库取数(与 OMS 库存查询跨库 join NGWL_TEST_WMS.material_base_info 同一模式),
口径与 WMS 端 /outboundRankApi 完全一致,两边数字一致;
条件:b.status in (9已出库,12已复核,13已交接),排除已取消(10)/已关闭(11);
日期按出库单创建时间 b.create_time
日期按出库单创建时间 b.create_time;一行 = 某仓单内某货品的合计,按出库数量(销售量)降序,件数/出仓日期/单号次之
-->
<sql id="outboundRankConditions">
a.del_flag = 1
@@ -36,6 +36,12 @@
<if test="lineName != null and lineName != ''">
and b.line_name like concat('%', #{lineName}, '%')
</if>
<if test="outOrderNumber != null and outOrderNumber != ''">
and b.out_order_number like concat('%', #{outOrderNumber}, '%')
</if>
<if test="inOrderNumber != null and inOrderNumber != ''">
and a.in_order_number like concat('%', #{inOrderNumber}, '%')
</if>
<if test="materialCode != null and materialCode != ''">
and a.material_code like concat('%', #{materialCode}, '%')
</if>
@@ -55,67 +61,50 @@
join NGWL_TEST_WMS.stock_out_order b on a.out_order_number = b.out_order_number and b.del_flag = 1
</sql>
<!-- 商品出库排名列表 -->
<select id="queryMaterialRankList" parameterType="com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO"
resultType="com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundMaterialRankPO">
<!-- 出库明细列表(仓单+货品汇总,按出库数量(销售量)降序;退保总额暂无后端字段不提供) -->
<select id="queryDetailList" parameterType="com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO"
resultType="com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundDetailRankPO">
select
a.material_code AS materialCode,
MAX(a.material_name) AS materialName,
MAX(a.SPECIFICATION_MODEL) AS specificationModel,
MAX(a.unit_name) AS unitName,
IFNULL(SUM(a.outbound_quantity), 0) AS salesQuantity,
COUNT(DISTINCT a.out_order_number) AS tradeCount,
IFNULL(SUM(IFNULL(a.TOTAL_AMOUNT, 0)), 0) AS amount
MAX(b.ORDER_TYPE_NAME) AS orderTypeName,
b.out_order_number AS outOrderNumber,
MAX(a.in_order_number) AS inOrderNumber,
MAX(b.customer_code) AS customerCode,
MAX(IFNULL(b."TO", b.contact_person)) AS receiver,
a.material_code AS materialCode,
MAX(a.material_name) AS materialName,
MAX(b.line_code) AS lineCode,
MAX(b.line_name) AS lineName,
IFNULL(SUM(a.PIECE_COUNT), 0) AS pieceCount,
ROUND(IFNULL(SUM(a.TOTAL_GROSS_WEIGHT), 0) / 1000, 3) AS grossWeightTon,
IFNULL(SUM(a.TOTAL_VOLUME), 0) AS totalVolume,
MAX(IFNULL(b.OUTBOUND_DATE, IFNULL(b.COMPLETE_TIME, b.create_time))) AS outboundDate
<include refid="outboundRankFrom"/>
<where>
<include refid="outboundRankConditions"/>
</where>
GROUP BY a.material_code
order by salesQuantity desc
GROUP BY b.out_order_number, a.material_code
order by IFNULL(SUM(a.outbound_quantity), 0) desc, pieceCount desc, outboundDate desc, outOrderNumber desc
</select>
<!-- 线路出库排名列表(线路为空的历史单不参与线路排名 -->
<select id="queryLineRankList" parameterType="com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO"
resultType="com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundLineRankPO">
<!-- 出库明细合计(当前筛选条件全量;外层对分组结果再汇总,与入库排名同模板 -->
<select id="queryDetailTotal" parameterType="com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO"
resultType="com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundDetailRankTotalPO">
select
b.line_code AS lineCode,
MAX(b.line_name) AS lineName,
IFNULL(SUM(a.outbound_quantity), 0) AS salesQuantity,
COUNT(DISTINCT b.out_order_number) AS tradeCount,
IFNULL(SUM(IFNULL(a.TOTAL_AMOUNT, 0)), 0) AS amount
<include refid="outboundRankFrom"/>
<where>
<include refid="outboundRankConditions"/>
and b.line_code is not null and b.line_code != ''
</where>
GROUP BY b.line_code
order by salesQuantity desc
</select>
<!-- 商品出库排名合计(当前筛选条件全量) -->
<select id="queryMaterialRankTotal" parameterType="com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO"
resultType="com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundRankTotalPO">
select
IFNULL(SUM(a.outbound_quantity), 0) AS totalSalesQuantity,
COUNT(DISTINCT a.out_order_number) AS totalTradeCount,
IFNULL(SUM(IFNULL(a.TOTAL_AMOUNT, 0)), 0) AS totalAmount
<include refid="outboundRankFrom"/>
<where>
<include refid="outboundRankConditions"/>
</where>
</select>
<!-- 线路出库排名合计(当前筛选条件全量) -->
<select id="queryLineRankTotal" parameterType="com.mhd.oms.domain.outboundRank.repository.todo.ExecutionOutboundRankDO"
resultType="com.mhd.oms.domain.outboundRank.repository.po.ExecutionOutboundRankTotalPO">
select
IFNULL(SUM(a.outbound_quantity), 0) AS totalSalesQuantity,
COUNT(DISTINCT b.out_order_number) AS totalTradeCount,
IFNULL(SUM(IFNULL(a.TOTAL_AMOUNT, 0)), 0) AS totalAmount
<include refid="outboundRankFrom"/>
<where>
<include refid="outboundRankConditions"/>
and b.line_code is not null and b.line_code != ''
</where>
IFNULL(SUM(t.pieceCount), 0) AS totalPieceCount,
ROUND(IFNULL(SUM(t.grossWeightKG), 0) / 1000, 3) AS totalGrossWeightTon,
IFNULL(SUM(t.totalVolume), 0) AS totalVolume,
COUNT(DISTINCT t.outOrderNumber) AS totalOrderCount
from (
select
b.out_order_number AS outOrderNumber,
IFNULL(SUM(a.PIECE_COUNT), 0) AS pieceCount,
IFNULL(SUM(a.TOTAL_GROSS_WEIGHT), 0) AS grossWeightKG,
IFNULL(SUM(a.TOTAL_VOLUME), 0) AS totalVolume
<include refid="outboundRankFrom"/>
<where>
<include refid="outboundRankConditions"/>
</where>
GROUP BY b.out_order_number, a.material_code
) t
</select>
</mapper>
@@ -6,9 +6,8 @@ import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.domain.cache.AssociationWarehouseCacheDO;
import com.mhd.system.api.domain.cache.SystemServiceCacheUtil;
import com.mhd.system.api.model.LoginUser;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundLineRankPO;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundMaterialRankPO;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundRankTotalPO;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundDetailRankPO;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundDetailRankTotalPO;
import com.mhd.wms.domain.outboundRank.repository.todo.OutboundRankDO;
import com.mhd.wms.domain.outboundRank.service.OutboundRankDomainService;
import lombok.extern.slf4j.Slf4j;
@@ -18,9 +17,9 @@ import org.springframework.stereotype.Service;
import java.util.List;
/**
* 出库排名统计应用服务
* 出库排名统计(明细)应用服务
*
* <p>负责登录用户组织隔离注入、日期区间校验,统计逻辑在 OutboundRankDomainService → OutboundRankMapper.xml</p>
* <p>负责登录用户组织隔离注入、日期区间校验,查询逻辑在 OutboundRankDomainService → OutboundRankMapper.xml</p>
*
* @author rcx
* @date 2026-08-31
@@ -33,49 +32,26 @@ public class OutboundRankApplicationService {
private OutboundRankDomainService outboundRankDomainService;
/**
* 分页查询商品出库排名列表
* 分页查询出库明细列表
*/
public List<OutboundMaterialRankPO> queryMaterialRankList(OutboundRankDO outboundRankDO) {
public List<OutboundDetailRankPO> queryDetailList(OutboundRankDO outboundRankDO) {
fillLoginContext(outboundRankDO);
return outboundRankDomainService.queryMaterialRankList(outboundRankDO);
return outboundRankDomainService.queryDetailList(outboundRankDO);
}
/**
* 分页查询线路出库排名列表
* 出库明细合计(当前筛选条件全量,不分页)
*/
public List<OutboundLineRankPO> queryLineRankList(OutboundRankDO outboundRankDO) {
public OutboundDetailRankTotalPO queryDetailTotal(OutboundRankDO outboundRankDO) {
return outboundRankDomainService.queryDetailTotal(outboundRankDO);
}
/**
* 导出出库明细(不分页全量)
*/
public List<OutboundDetailRankPO> exportDetailList(OutboundRankDO outboundRankDO) {
fillLoginContext(outboundRankDO);
return outboundRankDomainService.queryLineRankList(outboundRankDO);
}
/**
* 商品出库排名合计(当前筛选条件全量,不分页)
*/
public OutboundRankTotalPO queryMaterialRankTotal(OutboundRankDO outboundRankDO) {
return outboundRankDomainService.queryMaterialRankTotal(outboundRankDO);
}
/**
* 线路出库排名合计(当前筛选条件全量,不分页)
*/
public OutboundRankTotalPO queryLineRankTotal(OutboundRankDO outboundRankDO) {
return outboundRankDomainService.queryLineRankTotal(outboundRankDO);
}
/**
* 导出商品出库排名(不分页全量)
*/
public List<OutboundMaterialRankPO> exportMaterialRankList(OutboundRankDO outboundRankDO) {
fillLoginContext(outboundRankDO);
return outboundRankDomainService.queryMaterialRankList(outboundRankDO);
}
/**
* 导出线路出库排名(不分页全量)
*/
public List<OutboundLineRankPO> exportLineRankList(OutboundRankDO outboundRankDO) {
fillLoginContext(outboundRankDO);
return outboundRankDomainService.queryLineRankList(outboundRankDO);
return outboundRankDomainService.queryDetailList(outboundRankDO);
}
/**
@@ -1,14 +1,13 @@
package com.mhd.wms.domain.outboundRank.repository.facade;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundLineRankPO;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundMaterialRankPO;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundRankTotalPO;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundDetailRankPO;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundDetailRankTotalPO;
import com.mhd.wms.domain.outboundRank.repository.todo.OutboundRankDO;
import java.util.List;
/**
* 出库排名统计Service接口
* 出库排名统计(明细)Service接口
*
* @author rcx
* @date 2026-08-31
@@ -16,22 +15,12 @@ import java.util.List;
public interface IOutboundRankService {
/**
* 商品出库排名列表
* 出库明细列表
*/
List<OutboundMaterialRankPO> queryMaterialRankList(OutboundRankDO outboundRankDO);
List<OutboundDetailRankPO> queryDetailList(OutboundRankDO outboundRankDO);
/**
* 线路出库排名列表
* 出库明细合计(不分页)
*/
List<OutboundLineRankPO> queryLineRankList(OutboundRankDO outboundRankDO);
/**
* 商品出库排名合计(不分页)
*/
OutboundRankTotalPO queryMaterialRankTotal(OutboundRankDO outboundRankDO);
/**
* 线路出库排名合计(不分页)
*/
OutboundRankTotalPO queryLineRankTotal(OutboundRankDO outboundRankDO);
OutboundDetailRankTotalPO queryDetailTotal(OutboundRankDO outboundRankDO);
}
@@ -1,14 +1,13 @@
package com.mhd.wms.domain.outboundRank.repository.mapper;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundLineRankPO;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundMaterialRankPO;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundRankTotalPO;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundDetailRankPO;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundDetailRankTotalPO;
import com.mhd.wms.domain.outboundRank.repository.todo.OutboundRankDO;
import java.util.List;
/**
* 出库排名统计Mapper接口
* 出库排名统计(明细)Mapper接口
*
* @author rcx
* @date 2026-08-31
@@ -16,22 +15,12 @@ import java.util.List;
public interface OutboundRankMapper {
/**
* 商品出库排名列表(按销售量倒序)
* 出库明细列表(一行=仓单×货品,按件数倒序)
*/
List<OutboundMaterialRankPO> queryMaterialRankList(OutboundRankDO outboundRankDO);
List<OutboundDetailRankPO> queryDetailList(OutboundRankDO outboundRankDO);
/**
* 线路出库排名列表(按销售量倒序
* 出库明细合计(不分页,当前筛选条件全量合计
*/
List<OutboundLineRankPO> queryLineRankList(OutboundRankDO outboundRankDO);
/**
* 商品出库排名合计(不分页,当前筛选条件全量合计)
*/
OutboundRankTotalPO queryMaterialRankTotal(OutboundRankDO outboundRankDO);
/**
* 线路出库排名合计(不分页,当前筛选条件全量合计)
*/
OutboundRankTotalPO queryLineRankTotal(OutboundRankDO outboundRankDO);
OutboundDetailRankTotalPO queryDetailTotal(OutboundRankDO outboundRankDO);
}
@@ -2,9 +2,8 @@ package com.mhd.wms.domain.outboundRank.repository.persistence;
import com.mhd.wms.domain.outboundRank.repository.facade.IOutboundRankService;
import com.mhd.wms.domain.outboundRank.repository.mapper.OutboundRankMapper;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundLineRankPO;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundMaterialRankPO;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundRankTotalPO;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundDetailRankPO;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundDetailRankTotalPO;
import com.mhd.wms.domain.outboundRank.repository.todo.OutboundRankDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -12,7 +11,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
/**
* 出库排名统计Service业务层处理
* 出库排名统计明细Service业务层处理
*
* @author rcx
* @date 2026-08-31
@@ -24,22 +23,12 @@ public class OutboundRankImpl implements IOutboundRankService {
private OutboundRankMapper outboundRankMapper;
@Override
public List<OutboundMaterialRankPO> queryMaterialRankList(OutboundRankDO outboundRankDO) {
return outboundRankMapper.queryMaterialRankList(outboundRankDO);
public List<OutboundDetailRankPO> queryDetailList(OutboundRankDO outboundRankDO) {
return outboundRankMapper.queryDetailList(outboundRankDO);
}
@Override
public List<OutboundLineRankPO> queryLineRankList(OutboundRankDO outboundRankDO) {
return outboundRankMapper.queryLineRankList(outboundRankDO);
}
@Override
public OutboundRankTotalPO queryMaterialRankTotal(OutboundRankDO outboundRankDO) {
return outboundRankMapper.queryMaterialRankTotal(outboundRankDO);
}
@Override
public OutboundRankTotalPO queryLineRankTotal(OutboundRankDO outboundRankDO) {
return outboundRankMapper.queryLineRankTotal(outboundRankDO);
public OutboundDetailRankTotalPO queryDetailTotal(OutboundRankDO outboundRankDO) {
return outboundRankMapper.queryDetailTotal(outboundRankDO);
}
}
@@ -0,0 +1,85 @@
package com.mhd.wms.domain.outboundRank.repository.po;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* 出库排名统计明细PO一行 = 仓单×货品件数/毛重/体积按行汇总
*
* <p>字段口径种类=出库单据类型仓单编号=出库单号收货人=出库单 TO (为空取联系人)
* 毛重()=明细总毛重KG/1000出仓日期=出仓日期(为空依次兜底完成时间/创建时间)
* 退保总额为占位字段后端暂无对应数据来源恒为 null候选货品档案保额 insure_amount确认后可补</p>
*
* @author rcx
* @date 2026-08-31
*/
@Data
@ApiModel(value = "出库排名统计明细对象", description = "出库排名统计明细响应对象")
public class OutboundDetailRankPO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("种类(出库单据类型)")
@Excel(name = "种类")
private String orderTypeName;
@ApiModelProperty("仓单编号(出库单号)")
@Excel(name = "仓单编号")
private String outOrderNumber;
@ApiModelProperty("入库单号")
@Excel(name = "入库单号")
private String inOrderNumber;
@ApiModelProperty("客户编号")
@Excel(name = "客户编号")
private String customerCode;
@ApiModelProperty("收货人(出库单 TO 栏,为空取联系人)")
@Excel(name = "收货人")
private String receiver;
@ApiModelProperty("商品货号(辅助字段,不导出)")
private String materialCode;
@ApiModelProperty("货名")
@Excel(name = "货名")
private String materialName;
@ApiModelProperty("线路编码(辅助字段,不导出)")
private String lineCode;
@ApiModelProperty("线路")
@Excel(name = "线路")
private String lineName;
@ApiModelProperty("件数")
@Excel(name = "件数")
private BigDecimal pieceCount;
@ApiModelProperty("毛重(吨)")
@Excel(name = "毛重(吨)")
private BigDecimal grossWeightTon;
@ApiModelProperty("体积(CBM)")
@Excel(name = "体积(CBM)")
private BigDecimal totalVolume;
@ApiModelProperty("退保总额(占位字段,后端暂无数据来源,恒为 null)")
@Excel(name = "退保总额")
private BigDecimal depositRefundAmount;
@ApiModelProperty("出仓日期(出仓日期为空时依次兜底完成时间/创建时间)")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@Excel(name = "出仓日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date outboundDate;
}
@@ -0,0 +1,36 @@
package com.mhd.wms.domain.outboundRank.repository.po;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 出库排名统计明细合计PO
*
* <p>当前筛选条件下不分页的全量合计随分页列表一起返回
* totalPieceCount/totalGrossWeightTon/totalVolume/totalOrderCount</p>
*
* @author rcx
* @date 2026-08-31
*/
@Data
@ApiModel(value = "出库排名统计明细合计对象", description = "出库排名统计明细合计响应对象")
public class OutboundDetailRankTotalPO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("件数合计")
private BigDecimal totalPieceCount;
@ApiModelProperty("毛重(吨)合计")
private BigDecimal totalGrossWeightTon;
@ApiModelProperty("体积(CBM)合计")
private BigDecimal totalVolume;
@ApiModelProperty("仓单数合计(去重出库单数)")
private Long totalOrderCount;
}
@@ -1,45 +0,0 @@
package com.mhd.wms.domain.outboundRank.repository.po;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 线路出库排名PO
*
* <p>按日期区间对出库单聚合销售量=SUM(出库数量)交易数=COUNT(DISTINCT 出库单号)金额=SUM(明细总价)
* 仅统计带线路的出库单line_code 2026-08-20 新增冗余字段历史单为空</p>
*
* @author rcx
* @date 2026-08-31
*/
@Data
@ApiModel(value = "线路出库排名对象", description = "线路出库排名响应对象")
public class OutboundLineRankPO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("线路编码")
@Excel(name = "线路编码")
private String lineCode;
@ApiModelProperty("线路名称")
@Excel(name = "线路名称")
private String lineName;
@ApiModelProperty("销售量(出库数量合计)")
@Excel(name = "销售量")
private BigDecimal salesQuantity;
@ApiModelProperty("交易数(出库单据数)")
@Excel(name = "交易数")
private Long tradeCount;
@ApiModelProperty("金额")
@Excel(name = "金额")
private BigDecimal amount;
}
@@ -1,52 +0,0 @@
package com.mhd.wms.domain.outboundRank.repository.po;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 商品出库排名PO
*
* <p>按日期区间对出库明细聚合销售量=SUM(出库数量)交易数=COUNT(DISTINCT 出库单号)金额=SUM(明细总价)</p>
*
* @author rcx
* @date 2026-08-31
*/
@Data
@ApiModel(value = "商品出库排名对象", description = "商品出库排名响应对象")
public class OutboundMaterialRankPO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("商品货号")
@Excel(name = "商品货号")
private String materialCode;
@ApiModelProperty("商品名称")
@Excel(name = "商品名称")
private String materialName;
@ApiModelProperty("规格")
@Excel(name = "规格")
private String specificationModel;
@ApiModelProperty("单位")
@Excel(name = "单位")
private String unitName;
@ApiModelProperty("销售量(出库数量合计)")
@Excel(name = "销售量")
private BigDecimal salesQuantity;
@ApiModelProperty("交易数(出库单据数)")
@Excel(name = "交易数")
private Long tradeCount;
@ApiModelProperty("金额")
@Excel(name = "金额")
private BigDecimal amount;
}
@@ -1,32 +0,0 @@
package com.mhd.wms.domain.outboundRank.repository.po;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 出库排名合计PO
*
* <p>当前筛选条件下不分页的全量合计随分页列表一起返回totalSalesQuantity/totalTradeCount/totalAmount</p>
*
* @author rcx
* @date 2026-08-31
*/
@Data
@ApiModel(value = "出库排名合计对象", description = "出库排名合计响应对象")
public class OutboundRankTotalPO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("销售量合计")
private BigDecimal totalSalesQuantity;
@ApiModelProperty("交易数合计(去重出库单数)")
private Long totalTradeCount;
@ApiModelProperty("金额合计")
private BigDecimal totalAmount;
}
@@ -6,7 +6,7 @@ import lombok.Data;
import java.io.Serializable;
/**
* 出库排名统计查询DO
* 出库排名统计明细查询DO
*
* <p>topOrganizationId / warehouseId 由服务端按登录用户注入前端不传</p>
*
@@ -24,10 +24,16 @@ public class OutboundRankDO implements Serializable {
@ApiModelProperty("出库日期-结束 yyyy-MM-dd(必填)")
private String createTimeEnd;
@ApiModelProperty("仓单编号/出库单号(模糊)")
private String outOrderNumber;
@ApiModelProperty("入库单号(模糊)")
private String inOrderNumber;
@ApiModelProperty("商品货号(模糊)")
private String materialCode;
@ApiModelProperty("商品名称(模糊)")
@ApiModelProperty("货名/商品名称(模糊)")
private String materialName;
@ApiModelProperty("线路编码(模糊)")
@@ -1,9 +1,8 @@
package com.mhd.wms.domain.outboundRank.service;
import com.mhd.wms.domain.outboundRank.repository.facade.IOutboundRankService;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundLineRankPO;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundMaterialRankPO;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundRankTotalPO;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundDetailRankPO;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundDetailRankTotalPO;
import com.mhd.wms.domain.outboundRank.repository.todo.OutboundRankDO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -12,7 +11,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
/**
* 出库排名统计领域服务
* 出库排名统计明细领域服务
*
* @author rcx
* @date 2026-08-31
@@ -25,30 +24,16 @@ public class OutboundRankDomainService {
private IOutboundRankService outboundRankService;
/**
* 商品出库排名列表
* 出库明细列表
*/
public List<OutboundMaterialRankPO> queryMaterialRankList(OutboundRankDO outboundRankDO) {
return outboundRankService.queryMaterialRankList(outboundRankDO);
public List<OutboundDetailRankPO> queryDetailList(OutboundRankDO outboundRankDO) {
return outboundRankService.queryDetailList(outboundRankDO);
}
/**
* 线路出库排名列表
* 出库明细合计不分页
*/
public List<OutboundLineRankPO> queryLineRankList(OutboundRankDO outboundRankDO) {
return outboundRankService.queryLineRankList(outboundRankDO);
}
/**
* 商品出库排名合计不分页
*/
public OutboundRankTotalPO queryMaterialRankTotal(OutboundRankDO outboundRankDO) {
return outboundRankService.queryMaterialRankTotal(outboundRankDO);
}
/**
* 线路出库排名合计不分页
*/
public OutboundRankTotalPO queryLineRankTotal(OutboundRankDO outboundRankDO) {
return outboundRankService.queryLineRankTotal(outboundRankDO);
public OutboundDetailRankTotalPO queryDetailTotal(OutboundRankDO outboundRankDO) {
return outboundRankService.queryDetailTotal(outboundRankDO);
}
}
@@ -3,27 +3,38 @@ package com.mhd.wms.interfaces.dto.outboundRank;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 出库排名统计入参DTO
* 出库排名统计明细入参DTO
*
* <p>按日期区间统计商品/线路出库量排名统计口径出库单创建时间 + 已出库及之后状态(9,12,13)</p>
* <p>按日期区间筛选出库明细列表一行 = 仓单×货品件数/毛重/体积按行汇总件数降序
* 统计口径出库单创建时间 + 已出库及之后状态(9,12,13) + 明细仅取 level=1 主行</p>
*
* @author rcx
* @date 2026-08-31
*/
@Data
public class OutboundRankDTO {
public class OutboundRankDTO implements Serializable {
@ApiModelProperty("出库日期-开始 yyyy-MM-dd(必填,按出库单创建时间统计)")
private static final long serialVersionUID = 1L;
@ApiModelProperty("出库日期-开始 yyyy-MM-dd(必填,按出库单创建时间筛选)")
private String createTimeStart;
@ApiModelProperty("出库日期-结束 yyyy-MM-dd(必填,按出库单创建时间统计")
@ApiModelProperty("出库日期-结束 yyyy-MM-dd(必填,按出库单创建时间筛选")
private String createTimeEnd;
@ApiModelProperty("仓单编号/出库单号(模糊)")
private String outOrderNumber;
@ApiModelProperty("入库单号(模糊)")
private String inOrderNumber;
@ApiModelProperty("商品货号(模糊)")
private String materialCode;
@ApiModelProperty("商品名称(模糊)")
@ApiModelProperty("货名/商品名称(模糊)")
private String materialName;
@ApiModelProperty("线路编码(模糊)")
@@ -5,9 +5,8 @@ import com.mhd.common.core.constant.HttpStatus;
import com.mhd.common.core.utils.PageUtils;
import com.mhd.common.core.utils.poi.ExcelUtil;
import com.mhd.wms.application.service.outboundRank.OutboundRankApplicationService;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundLineRankPO;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundMaterialRankPO;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundRankTotalPO;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundDetailRankPO;
import com.mhd.wms.domain.outboundRank.repository.po.OutboundDetailRankTotalPO;
import com.mhd.wms.domain.outboundRank.repository.todo.OutboundRankDO;
import com.mhd.wms.interfaces.assember.outboundRank.OutboundRankAssembler;
import com.mhd.wms.interfaces.dto.outboundRank.OutboundRankDTO;
@@ -26,8 +25,10 @@ import java.util.List;
/**
* 出库排名统计Api
*
* <p>按日期区间筛选统计商品/线路出库量排名统计口径出库单创建时间 + 已出库及之后状态(9,12,13)
* 明细仅取 level=1 主行销售量=SUM(出库数量)交易数=COUNT(DISTINCT 出库单号)金额=SUM(明细总价)</p>
* <p>按日期区间筛选出库明细列表一行 = 仓单×货品件数/毛重/体积按行汇总按出库数量(销售量)降序件数/出仓日期/单号次之
* 统计口径出库单创建时间 + 已出库及之后状态(9,12,13)明细仅取 level=1 主行
* 商品/线路两个 tab 各自独立接口内部为同一份明细查询商品接口忽略线路筛选参数线路接口忽略商品筛选参数
* 字段种类/仓单编号/入库单号/客户编号/收货人/货名/线路/件数/毛重()/体积(CBM)/退保总额(占位null)/出仓日期</p>
*
* @author rcx
* @date 2026-08-31
@@ -43,84 +44,97 @@ public class OutboundRankApi {
private OutboundRankApplicationService outboundRankApplicationService;
/**
* 分页查询商品出库排名列表含合计行
* 分页查询商品出库排名列表含合计行商品tab忽略线路筛选参数
*/
@ApiOperation("分页查询商品出库排名列表")
@GetMapping("/queryMaterialRankList")
public HashMap<String, Object> queryMaterialRankList(OutboundRankDTO outboundRankDTO) {
//转换实体
OutboundRankDO outboundRankDO = outboundRankAssembler.toDO(outboundRankDTO);
//商品tab忽略线路筛选参数
outboundRankDO.setLineCode(null);
outboundRankDO.setLineName(null);
startPage();
List<OutboundMaterialRankPO> list = outboundRankApplicationService.queryMaterialRankList(outboundRankDO);
OutboundRankTotalPO total = outboundRankApplicationService.queryMaterialRankTotal(outboundRankDO);
List<OutboundDetailRankPO> list = outboundRankApplicationService.queryDetailList(outboundRankDO);
OutboundDetailRankTotalPO total = outboundRankApplicationService.queryDetailTotal(outboundRankDO);
return getDataTableWithTotal(list, total);
}
/**
* 分页查询线路出库排名列表含合计行
* 分页查询线路出库排名列表含合计行线路tab忽略商品筛选参数
*/
@ApiOperation("分页查询线路出库排名列表")
@GetMapping("/queryLineRankList")
public HashMap<String, Object> queryLineRankList(OutboundRankDTO outboundRankDTO) {
//转换实体
OutboundRankDO outboundRankDO = outboundRankAssembler.toDO(outboundRankDTO);
//线路tab忽略商品筛选参数
outboundRankDO.setMaterialCode(null);
outboundRankDO.setMaterialName(null);
startPage();
List<OutboundLineRankPO> list = outboundRankApplicationService.queryLineRankList(outboundRankDO);
OutboundRankTotalPO total = outboundRankApplicationService.queryLineRankTotal(outboundRankDO);
List<OutboundDetailRankPO> list = outboundRankApplicationService.queryDetailList(outboundRankDO);
OutboundDetailRankTotalPO total = outboundRankApplicationService.queryDetailTotal(outboundRankDO);
return getDataTableWithTotal(list, total);
}
/**
* 导出商品出库排名Excel
* 导出商品出库排名Excel商品tab忽略线路筛选参数
*/
@ApiOperation("导出商品出库排名Excel")
@GetMapping("/exportMaterialRank")
public void exportMaterialRank(HttpServletResponse response, OutboundRankDTO outboundRankDTO) throws Exception {
//转换实体不分页导出全量
OutboundRankDO outboundRankDO = outboundRankAssembler.toDO(outboundRankDTO);
List<OutboundMaterialRankPO> list = outboundRankApplicationService.exportMaterialRankList(outboundRankDO);
//商品tab忽略线路筛选参数
outboundRankDO.setLineCode(null);
outboundRankDO.setLineName(null);
List<OutboundDetailRankPO> list = outboundRankApplicationService.exportDetailList(outboundRankDO);
String fileName = URLEncoder.encode("商品出库排名", "UTF-8").replaceAll("\\+", "%20");
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
ExcelUtil<OutboundMaterialRankPO> util = new ExcelUtil<>(OutboundMaterialRankPO.class);
ExcelUtil<OutboundDetailRankPO> util = new ExcelUtil<>(OutboundDetailRankPO.class);
util.exportExcel(response, list, "商品出库排名");
}
/**
* 导出线路出库排名Excel
* 导出线路出库排名Excel线路tab忽略商品筛选参数
*/
@ApiOperation("导出线路出库排名Excel")
@GetMapping("/exportLineRank")
public void exportLineRank(HttpServletResponse response, OutboundRankDTO outboundRankDTO) throws Exception {
//转换实体不分页导出全量
OutboundRankDO outboundRankDO = outboundRankAssembler.toDO(outboundRankDTO);
List<OutboundLineRankPO> list = outboundRankApplicationService.exportLineRankList(outboundRankDO);
//线路tab忽略商品筛选参数
outboundRankDO.setMaterialCode(null);
outboundRankDO.setMaterialName(null);
List<OutboundDetailRankPO> list = outboundRankApplicationService.exportDetailList(outboundRankDO);
String fileName = URLEncoder.encode("线路出库排名", "UTF-8").replaceAll("\\+", "%20");
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
ExcelUtil<OutboundLineRankPO> util = new ExcelUtil<>(OutboundLineRankPO.class);
ExcelUtil<OutboundDetailRankPO> util = new ExcelUtil<>(OutboundDetailRankPO.class);
util.exportExcel(response, list, "线路出库排名");
}
/**
* 分页结果 + 合计行data/total/code/msg 之外追加 totalSalesQuantity/totalTradeCount/totalAmount
* 分页结果 + 合计行data/total/code/msg 之外追加 totalPieceCount/totalGrossWeightTon/totalVolume/totalOrderCount
*/
private HashMap<String, Object> getDataTableWithTotal(List<?> list, OutboundRankTotalPO total) {
private HashMap<String, Object> getDataTableWithTotal(List<?> list, OutboundDetailRankTotalPO total) {
HashMap<String, Object> result = new HashMap<>();
result.put("data", list);
result.put("total", new PageInfo<>(list).getTotal());
result.put("code", HttpStatus.SUCCESS);
result.put("msg", "查询成功");
if (total != null) {
result.put("totalSalesQuantity", total.getTotalSalesQuantity());
result.put("totalTradeCount", total.getTotalTradeCount());
result.put("totalAmount", total.getTotalAmount());
result.put("totalPieceCount", total.getTotalPieceCount());
result.put("totalGrossWeightTon", total.getTotalGrossWeightTon());
result.put("totalVolume", total.getTotalVolume());
result.put("totalOrderCount", total.getTotalOrderCount());
}
return result;
}
@@ -5,10 +5,11 @@
<mapper namespace="com.mhd.wms.domain.outboundRank.repository.mapper.OutboundRankMapper">
<!--
出库排名统计公共查询条件
出库排名统计(明细)公共查询条件
数据源:出库明细 out_material_detail(a,仅 level=1 主行防重复) join 出库单 stock_out_order(b)
口径:b.status in (9已出库,12已复核,13已交接),排除已取消(10)/已关闭(11);
日期按出库单创建时间 b.create_time(与出库单列表日期筛选一致)
日期按出库单创建时间 b.create_time(与出库单列表日期筛选一致)
一行 = 某仓单(b.out_order_number)内某货品(a.material_code)的合计,按出库数量(销售量)降序,件数/出仓日期/单号次之
-->
<sql id="outboundRankConditions">
a.del_flag = 1
@@ -35,6 +36,18 @@
<if test="lineName != null and lineName != ''">
and b.line_name like concat('%', #{lineName}, '%')
</if>
<if test="outOrderNumber != null and outOrderNumber != ''">
and b.out_order_number like concat('%', #{outOrderNumber}, '%')
</if>
<if test="inOrderNumber != null and inOrderNumber != ''">
and a.in_order_number like concat('%', #{inOrderNumber}, '%')
</if>
<if test="materialCode != null and materialCode != ''">
and a.material_code like concat('%', #{materialCode}, '%')
</if>
<if test="materialName != null and materialName != ''">
and a.material_name like concat('%', #{materialName}, '%')
</if>
<if test="createTimeStart != null and createTimeStart != ''">
and date_format(b.create_time,'%Y-%m-%d') &gt;= #{createTimeStart}
</if>
@@ -48,79 +61,50 @@
join stock_out_order b on a.out_order_number = b.out_order_number and b.del_flag = 1
</sql>
<!-- 商品出库排名列表 -->
<select id="queryMaterialRankList" parameterType="com.mhd.wms.domain.outboundRank.repository.todo.OutboundRankDO"
resultType="com.mhd.wms.domain.outboundRank.repository.po.OutboundMaterialRankPO">
<!-- 出库明细列表(仓单+货品汇总,按出库数量(销售量)降序;退保总额暂无后端字段不提供) -->
<select id="queryDetailList" parameterType="com.mhd.wms.domain.outboundRank.repository.todo.OutboundRankDO"
resultType="com.mhd.wms.domain.outboundRank.repository.po.OutboundDetailRankPO">
select
a.material_code AS materialCode,
MAX(a.material_name) AS materialName,
MAX(a.SPECIFICATION_MODEL) AS specificationModel,
MAX(a.unit_name) AS unitName,
IFNULL(SUM(a.outbound_quantity), 0) AS salesQuantity,
COUNT(DISTINCT a.out_order_number) AS tradeCount,
IFNULL(SUM(IFNULL(a.TOTAL_AMOUNT, 0)), 0) AS amount
MAX(b.ORDER_TYPE_NAME) AS orderTypeName,
b.out_order_number AS outOrderNumber,
MAX(a.in_order_number) AS inOrderNumber,
MAX(b.customer_code) AS customerCode,
MAX(IFNULL(b."TO", b.contact_person)) AS receiver,
a.material_code AS materialCode,
MAX(a.material_name) AS materialName,
MAX(b.line_code) AS lineCode,
MAX(b.line_name) AS lineName,
IFNULL(SUM(a.PIECE_COUNT), 0) AS pieceCount,
ROUND(IFNULL(SUM(a.TOTAL_GROSS_WEIGHT), 0) / 1000, 3) AS grossWeightTon,
IFNULL(SUM(a.TOTAL_VOLUME), 0) AS totalVolume,
MAX(IFNULL(b.OUTBOUND_DATE, IFNULL(b.COMPLETE_TIME, b.create_time))) AS outboundDate
<include refid="outboundRankFrom"/>
<where>
<include refid="outboundRankConditions"/>
<if test="materialCode != null and materialCode != ''">
and a.material_code like concat('%', #{materialCode}, '%')
</if>
<if test="materialName != null and materialName != ''">
and a.material_name like concat('%', #{materialName}, '%')
</if>
</where>
GROUP BY a.material_code
order by salesQuantity desc
GROUP BY b.out_order_number, a.material_code
order by IFNULL(SUM(a.outbound_quantity), 0) desc, pieceCount desc, outboundDate desc, outOrderNumber desc
</select>
<!-- 线路出库排名列表(线路为空的历史单不参与线路排名 -->
<select id="queryLineRankList" parameterType="com.mhd.wms.domain.outboundRank.repository.todo.OutboundRankDO"
resultType="com.mhd.wms.domain.outboundRank.repository.po.OutboundLineRankPO">
<!-- 出库明细合计(当前筛选条件全量;外层对分组结果再汇总,与入库排名同模板 -->
<select id="queryDetailTotal" parameterType="com.mhd.wms.domain.outboundRank.repository.todo.OutboundRankDO"
resultType="com.mhd.wms.domain.outboundRank.repository.po.OutboundDetailRankTotalPO">
select
b.line_code AS lineCode,
MAX(b.line_name) AS lineName,
IFNULL(SUM(a.outbound_quantity), 0) AS salesQuantity,
COUNT(DISTINCT b.out_order_number) AS tradeCount,
IFNULL(SUM(IFNULL(a.TOTAL_AMOUNT, 0)), 0) AS amount
<include refid="outboundRankFrom"/>
<where>
<include refid="outboundRankConditions"/>
and b.line_code is not null and b.line_code != ''
</where>
GROUP BY b.line_code
order by salesQuantity desc
</select>
<!-- 商品出库排名合计(当前筛选条件全量) -->
<select id="queryMaterialRankTotal" parameterType="com.mhd.wms.domain.outboundRank.repository.todo.OutboundRankDO"
resultType="com.mhd.wms.domain.outboundRank.repository.po.OutboundRankTotalPO">
select
IFNULL(SUM(a.outbound_quantity), 0) AS totalSalesQuantity,
COUNT(DISTINCT a.out_order_number) AS totalTradeCount,
IFNULL(SUM(IFNULL(a.TOTAL_AMOUNT, 0)), 0) AS totalAmount
<include refid="outboundRankFrom"/>
<where>
<include refid="outboundRankConditions"/>
<if test="materialCode != null and materialCode != ''">
and a.material_code like concat('%', #{materialCode}, '%')
</if>
<if test="materialName != null and materialName != ''">
and a.material_name like concat('%', #{materialName}, '%')
</if>
</where>
</select>
<!-- 线路出库排名合计(当前筛选条件全量) -->
<select id="queryLineRankTotal" parameterType="com.mhd.wms.domain.outboundRank.repository.todo.OutboundRankDO"
resultType="com.mhd.wms.domain.outboundRank.repository.po.OutboundRankTotalPO">
select
IFNULL(SUM(a.outbound_quantity), 0) AS totalSalesQuantity,
COUNT(DISTINCT b.out_order_number) AS totalTradeCount,
IFNULL(SUM(IFNULL(a.TOTAL_AMOUNT, 0)), 0) AS totalAmount
<include refid="outboundRankFrom"/>
<where>
<include refid="outboundRankConditions"/>
and b.line_code is not null and b.line_code != ''
</where>
IFNULL(SUM(t.pieceCount), 0) AS totalPieceCount,
ROUND(IFNULL(SUM(t.grossWeightKG), 0) / 1000, 3) AS totalGrossWeightTon,
IFNULL(SUM(t.totalVolume), 0) AS totalVolume,
COUNT(DISTINCT t.outOrderNumber) AS totalOrderCount
from (
select
b.out_order_number AS outOrderNumber,
IFNULL(SUM(a.PIECE_COUNT), 0) AS pieceCount,
IFNULL(SUM(a.TOTAL_GROSS_WEIGHT), 0) AS grossWeightKG,
IFNULL(SUM(a.TOTAL_VOLUME), 0) AS totalVolume
<include refid="outboundRankFrom"/>
<where>
<include refid="outboundRankConditions"/>
</where>
GROUP BY b.out_order_number, a.material_code
) t
</select>
</mapper>