feat(oms):库存查询导出新增库存为0是否导出参数 /reservationMaterialInventoryApi/list 新增可选参数 excludeZeroInventoryQuantity,前端"库存为0是否导出"选"是"时传 true,SQL 以 HAVING IFNULL(SUM(inventory_quantity),0)>0 排除汇总库存为0的数据;所有查询维度(all/hz/wl/kw/wlkw/wlExpiry)共6条查询在 GROUP BY 后统一挂载公共片段 excludeZeroInventoryHaving,与 sort_order 对0库存的定义保持一致;不传参数时 SQL 不拼接条件,行为与原来完全一致
This commit is contained in:
+3
@@ -258,4 +258,7 @@ public class ReservationMaterialInventoryDO extends MaterialBaseDO {
|
|||||||
|
|
||||||
@ApiModelProperty("导出按到期日分组排序标识:仅 queryRule=wlExpiry 时生效,true-到期日倒序(日期近的在前、空值最后、0库存靠后);不传-保持原有排序")
|
@ApiModelProperty("导出按到期日分组排序标识:仅 queryRule=wlExpiry 时生效,true-到期日倒序(日期近的在前、空值最后、0库存靠后);不传-保持原有排序")
|
||||||
private Boolean orderByExpiryDate;
|
private Boolean orderByExpiryDate;
|
||||||
|
|
||||||
|
@ApiModelProperty("导出排除库存为0标识:true-排除库存数量汇总为0的数据(所有查询维度 queryRule 均生效);不传-不过滤")
|
||||||
|
private Boolean excludeZeroInventoryQuantity;
|
||||||
}
|
}
|
||||||
+5
-1
@@ -47,12 +47,13 @@ public class ReservationMaterialInventoryApi extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 分页查询物料库存列表
|
* 分页查询物料库存列表
|
||||||
*/
|
*/
|
||||||
@ApiOperation("查询物料库存列表")
|
@ApiOperation(value = "查询物料库存列表", notes = "导出复用本接口,任意查询维度(queryRule)下:前端\"库存为0是否导出\"选\"是\"时传 excludeZeroInventoryQuantity=true 排除库存为0的数据,不传或 false 导出全部(含库存为0);orderByExpiryDate=true 时按到期日分组排序")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(ReservationMaterialInventoryDTO materialInventoryDTO,
|
public TableDataInfo list(ReservationMaterialInventoryDTO materialInventoryDTO,
|
||||||
@RequestParam(value = "customerName", required = false) String customerName,
|
@RequestParam(value = "customerName", required = false) String customerName,
|
||||||
@RequestParam(value = "expiryDateStart", required = false) String expiryDateStart,
|
@RequestParam(value = "expiryDateStart", required = false) String expiryDateStart,
|
||||||
@RequestParam(value = "expiryDateEnd", required = false) String expiryDateEnd,
|
@RequestParam(value = "expiryDateEnd", required = false) String expiryDateEnd,
|
||||||
|
@RequestParam(value = "excludeZeroInventoryQuantity", required = false) Boolean excludeZeroInventoryQuantity,
|
||||||
@RequestParam(value = "orderByExpiryDate", required = false) Boolean orderByExpiryDate)
|
@RequestParam(value = "orderByExpiryDate", required = false) Boolean orderByExpiryDate)
|
||||||
{
|
{
|
||||||
// 出库分配前端传的是客户名称 customerName,这里通过名称查询货主ID,使用精确匹配(不模糊匹配)
|
// 出库分配前端传的是客户名称 customerName,这里通过名称查询货主ID,使用精确匹配(不模糊匹配)
|
||||||
@@ -86,6 +87,9 @@ public class ReservationMaterialInventoryApi extends BaseController {
|
|||||||
// 导出场景:queryRule=wlExpiry + orderByExpiryDate=true 时 SQL 按到期日倒序分组
|
// 导出场景:queryRule=wlExpiry + orderByExpiryDate=true 时 SQL 按到期日倒序分组
|
||||||
// (日期近的在前、空值最后、0库存靠后、同到期日按更新时间倒序)
|
// (日期近的在前、空值最后、0库存靠后、同到期日按更新时间倒序)
|
||||||
materialInventoryDO.setOrderByExpiryDate(orderByExpiryDate);
|
materialInventoryDO.setOrderByExpiryDate(orderByExpiryDate);
|
||||||
|
// 导出场景:前端"库存为0是否导出"选"是"时传 excludeZeroInventoryQuantity=true,
|
||||||
|
// SQL 用 HAVING 排除汇总库存为0的数据(与 WMS 同名参数语义一致)
|
||||||
|
materialInventoryDO.setExcludeZeroInventoryQuantity(excludeZeroInventoryQuantity);
|
||||||
startPage();
|
startPage();
|
||||||
// 使用带批次属性的查询方法,批次属性值从库存表中获取
|
// 使用带批次属性的查询方法,批次属性值从库存表中获取
|
||||||
List<ReservationMaterialInventoryPO> list = materialInventoryApplicationService.queryListWithBatchAttributes(materialInventoryDO);
|
List<ReservationMaterialInventoryPO> list = materialInventoryApplicationService.queryListWithBatchAttributes(materialInventoryDO);
|
||||||
|
|||||||
+15
-1
@@ -282,6 +282,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</if>
|
</if>
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
<!-- 导出排除库存为0:所有维度查询(all/hz/wl/kw/wlkw/wlExpiry)的库存数量均为SUM聚合值,
|
||||||
|
统一在各语句 GROUP BY 之后用 HAVING 过滤(与sort_order对0库存的定义保持一致);
|
||||||
|
仅前端导出传 excludeZeroInventoryQuantity=true 时拼接,正常列表查询不传则完全不受影响 -->
|
||||||
|
<sql id="excludeZeroInventoryHaving">
|
||||||
|
<if test="excludeZeroInventoryQuantity != null and excludeZeroInventoryQuantity == true">
|
||||||
|
HAVING IFNULL(SUM(a.inventory_quantity), 0) > 0
|
||||||
|
</if>
|
||||||
|
</sql>
|
||||||
|
|
||||||
<select id="queryList" parameterType="com.mhd.oms.domain.reservationMaterialInventory.repository.todo.ReservationMaterialInventoryDO" resultMap="MaterialInventoryResult">
|
<select id="queryList" parameterType="com.mhd.oms.domain.reservationMaterialInventory.repository.todo.ReservationMaterialInventoryDO" resultMap="MaterialInventoryResult">
|
||||||
select
|
select
|
||||||
<include refid="selectMaterialInventoryPo"/>
|
<include refid="selectMaterialInventoryPo"/>
|
||||||
@@ -292,7 +301,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<include refid="selectMaterialInventoryPo1"/>
|
<include refid="selectMaterialInventoryPo1"/>
|
||||||
<include refid="JoinMaterialBaseInfoPoWhere"/>
|
<include refid="JoinMaterialBaseInfoPoWhere"/>
|
||||||
</where>
|
</where>
|
||||||
group by a.MATERIAL_INVENTORY_ID order by a.update_time desc
|
group by a.MATERIAL_INVENTORY_ID <include refid="excludeZeroInventoryHaving"/> order by a.update_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryListByWlKw" parameterType="com.mhd.oms.domain.reservationMaterialInventory.repository.todo.ReservationMaterialInventoryDO" resultMap="MaterialInventoryResult">
|
<select id="queryListByWlKw" parameterType="com.mhd.oms.domain.reservationMaterialInventory.repository.todo.ReservationMaterialInventoryDO" resultMap="MaterialInventoryResult">
|
||||||
@@ -306,6 +315,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<include refid="JoinMaterialBaseInfoPoWhere"/>
|
<include refid="JoinMaterialBaseInfoPoWhere"/>
|
||||||
</where>
|
</where>
|
||||||
GROUP BY a.MATERIAL_BASE_INFO_ID,a.WAREHOUSE_ID,a.STORAGE_SECTION_ID,a.STORAGE_LOCATION_ID
|
GROUP BY a.MATERIAL_BASE_INFO_ID,a.WAREHOUSE_ID,a.STORAGE_SECTION_ID,a.STORAGE_LOCATION_ID
|
||||||
|
<include refid="excludeZeroInventoryHaving"/>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryListByKw" parameterType="com.mhd.oms.domain.reservationMaterialInventory.repository.todo.ReservationMaterialInventoryDO" resultMap="MaterialInventoryResult">
|
<select id="queryListByKw" parameterType="com.mhd.oms.domain.reservationMaterialInventory.repository.todo.ReservationMaterialInventoryDO" resultMap="MaterialInventoryResult">
|
||||||
@@ -319,6 +329,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<include refid="JoinMaterialBaseInfoPoWhere"/>
|
<include refid="JoinMaterialBaseInfoPoWhere"/>
|
||||||
</where>
|
</where>
|
||||||
GROUP BY a.WAREHOUSE_ID,a.STORAGE_SECTION_ID,a.STORAGE_LOCATION_ID
|
GROUP BY a.WAREHOUSE_ID,a.STORAGE_SECTION_ID,a.STORAGE_LOCATION_ID
|
||||||
|
<include refid="excludeZeroInventoryHaving"/>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryListByWl" parameterType="com.mhd.oms.domain.reservationMaterialInventory.repository.todo.ReservationMaterialInventoryDO" resultMap="MaterialInventoryResult">
|
<select id="queryListByWl" parameterType="com.mhd.oms.domain.reservationMaterialInventory.repository.todo.ReservationMaterialInventoryDO" resultMap="MaterialInventoryResult">
|
||||||
@@ -332,6 +343,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<include refid="JoinMaterialBaseInfoPoWhere"/>
|
<include refid="JoinMaterialBaseInfoPoWhere"/>
|
||||||
</where>
|
</where>
|
||||||
GROUP BY a.MATERIAL_BASE_INFO_ID
|
GROUP BY a.MATERIAL_BASE_INFO_ID
|
||||||
|
<include refid="excludeZeroInventoryHaving"/>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 按物料+过期日期汇总 -->
|
<!-- 按物料+过期日期汇总 -->
|
||||||
@@ -369,6 +381,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
GROUP BY a.MATERIAL_BASE_INFO_ID, a.EXPIRY_DATE, a.shipper_id, a.shipper_code, a.shipper_name,
|
GROUP BY a.MATERIAL_BASE_INFO_ID, a.EXPIRY_DATE, a.shipper_id, a.shipper_code, a.shipper_name,
|
||||||
a.organization_id, a.organization_name, a.top_organization_id,
|
a.organization_id, a.organization_name, a.top_organization_id,
|
||||||
b.material_code, b.material_name
|
b.material_code, b.material_name
|
||||||
|
<include refid="excludeZeroInventoryHaving"/>
|
||||||
<!-- 导出(queryRule=wlExpiry + orderByExpiryDate=true)按到期日分组归类:到期日倒序(日期近的在前)、
|
<!-- 导出(queryRule=wlExpiry + orderByExpiryDate=true)按到期日分组归类:到期日倒序(日期近的在前)、
|
||||||
空值放最后、0库存靠后、同到期日按更新时间倒序;相同物料+相同到期日合并为一行,数量类字段SUM汇总。
|
空值放最后、0库存靠后、同到期日按更新时间倒序;相同物料+相同到期日合并为一行,数量类字段SUM汇总。
|
||||||
不传 orderByExpiryDate 保持原有排序 -->
|
不传 orderByExpiryDate 保持原有排序 -->
|
||||||
@@ -394,6 +407,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<include refid="JoinMaterialBaseInfoPoWhere"/>
|
<include refid="JoinMaterialBaseInfoPoWhere"/>
|
||||||
</where>
|
</where>
|
||||||
GROUP BY a.SHIPPER_ID
|
GROUP BY a.SHIPPER_ID
|
||||||
|
<include refid="excludeZeroInventoryHaving"/>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<resultMap type="com.mhd.oms.domain.reservationMaterialInventory.repository.po.ReservationMaterialInventoryQueryListPO" id="MaterialQueryListResult">
|
<resultMap type="com.mhd.oms.domain.reservationMaterialInventory.repository.po.ReservationMaterialInventoryQueryListPO" id="MaterialQueryListResult">
|
||||||
|
|||||||
Reference in New Issue
Block a user