库存查询按照过期日期来过滤查询

This commit is contained in:
秦鸿展
2026-07-22 10:39:34 +08:00
parent be597775d9
commit 494f49ee1b
5 changed files with 53 additions and 1 deletions
@@ -18,6 +18,7 @@ import com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryQuery
import com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryDO;
import com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryQueryListDO;
import com.mhd.wms.domain.materialInventory.service.MaterialInventoryDomainService;
import com.mhd.wms.interfaces.dto.materialInventory.MaterialInventoryDTO;
import com.mhd.wms.domain.materialBarCode.repository.facade.IMaterialBarCodeService;
import com.mhd.wms.domain.materialBarCode.repository.po.MaterialBarCodePO;
import com.mhd.wms.domain.materialMoreDetail.repository.po.MaterialMoreDetailPO;
@@ -32,6 +32,8 @@ public interface MaterialInventoryMapper extends BaseMapper<MaterialInventory>
public List<MaterialInventoryPO> queryListByKw(MaterialInventoryDO materialInventoryDO);
//查物料库存列表-物料
public List<MaterialInventoryPO> queryListByWl(MaterialInventoryDO materialInventoryDO);
//查物料库存列表-物料+过期日期
public List<MaterialInventoryPO> queryListByWlExpiry(MaterialInventoryDO materialInventoryDO);
//查物料库存列表-货主
public List<MaterialInventoryPO> queryListByHz(MaterialInventoryDO materialInventoryDO);
//查物料库存列表-货主+物料(同一物料在不同货主下各一行)
@@ -85,6 +85,8 @@ public class MaterialInventoryImpl extends ServiceImpl<MaterialInventoryMapper,
return materialInventoryMapper.queryListByKw(materialInventoryDO);
} else if ("wlkw".equals(queryRule)) {
return materialInventoryMapper.queryListByWlKw(materialInventoryDO);
} else if ("wlExpiry".equals(queryRule)) {
return materialInventoryMapper.queryListByWlExpiry(materialInventoryDO);
} else if ("all".equals(queryRule)) {
return materialInventoryMapper.queryList(materialInventoryDO);
} else {
@@ -55,7 +55,9 @@ public class MaterialInventoryApi extends BaseController {
@GetMapping("/list")
public TableDataInfo list(MaterialInventoryDTO materialInventoryDTO,
@RequestParam(value = "customerName", required = false) String customerName,
@RequestParam(value = "excludeZeroInventoryQuantity", required = false) Boolean excludeZeroInventoryQuantity)
@RequestParam(value = "excludeZeroInventoryQuantity", required = false) Boolean excludeZeroInventoryQuantity,
@RequestParam(value = "expiryDateStart", required = false) String expiryDateStart,
@RequestParam(value = "expiryDateEnd", required = false) String expiryDateEnd)
{
if (Boolean.TRUE.equals(excludeZeroInventoryQuantity)) {
materialInventoryDTO.setExcludeZeroInventoryQuantity(true);
@@ -86,6 +88,8 @@ public class MaterialInventoryApi extends BaseController {
MaterialInventoryDO materialInventoryDO = materialInventoryAssembler.toDO(materialInventoryDTO);
materialInventoryDO.setExpiryDateStr(materialInventoryDTO.getExpiryDate());
materialInventoryDO.setProductionDateStr(materialInventoryDTO.getProductionDate());
materialInventoryDO.setExpiryDateStart(expiryDateStart);
materialInventoryDO.setExpiryDateEnd(expiryDateEnd);
Date updateTime = materialInventoryDTO.getUpdateTime();
if (updateTime != null) {
LocalDateTime localDateTime = updateTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
@@ -455,6 +455,45 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
loc.storage_location_id, loc.storage_location_code, loc.storage_location_name order by sort_order, a.update_time desc
</select>
<!-- 按物料+过期日期汇总:相同物料+相同过期日期合并,不同过期日期分开 -->
<select id="queryListByWlExpiry" parameterType="com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryDO" resultMap="MaterialInventoryResult">
select
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,
MAX(a.warehouse_id) AS warehouse_id, MAX(a.warehouse_code) AS warehouse_code, MAX(a.warehouse_name) AS warehouse_name,
MAX(a.storage_section_id) AS storage_section_id, MAX(a.storage_code) AS storage_code, MAX(a.storage_name) AS storage_name,
MAX(a.storage_location_id) AS storage_location_id, MAX(a.storage_location_code) AS storage_location_code, MAX(a.storage_location_name) AS storage_location_name,
MAX(a.batch_number) AS batch_number, MAX(a.material_status_code) AS material_status_code, MAX(a.material_status_name) AS material_status_name,
MAX(a.container_id) AS container_id, MAX(a.container_code) AS container_code, MAX(a.container_type) AS container_type, MAX(a.container_type_name) AS container_type_name,
IFNULL(SUM(a.freeze_quantity), 0) AS freeze_quantity, a.is_able,
IFNULL(SUM(a.inventory_quantity), 0) AS inventory_quantity,
IFNULL(SUM(a.allocation_quantity), 0) AS allocation_quantity,
IFNULL(SUM(a.area), 0) AS area,
IFNULL(SUM(a.NET_WEIGHT), 0) AS NET_WEIGHT,
IFNULL(SUM(a.GROSS_WEIGHT), 0) AS GROSS_WEIGHT,
IFNULL(SUM(a.VOLUME), 0) AS VOLUME,
MAX(a.unit) AS unit,
MAX(a.unit_name) AS unit_name,
MAX(a.production_date) AS production_date,
MAX(a.inventory_date) AS inventory_date,
MAX(a.batch_ref_no) AS batch_ref_no, MAX(a.sheet_ref_no) AS sheet_ref_no, MAX(a.box_pallet_no) AS box_pallet_no,
MAX(a.bar_code) AS inv_bar_code,
MAX(a.in_order_number) AS in_order_number, MAX(a.lot_number) AS lot_number,
b.specification_model,
b.material_code, b.material_name,
CASE WHEN IFNULL(SUM(a.inventory_quantity), 0) = 0 THEN 1 ELSE 0 END AS sort_order
from material_inventory a
left join material_base_info b on a.material_base_info_id = b.material_base_info_id
<where>
<include refid="selectMaterialInventoryPo1"/>
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPoWhere"/>
</where>
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,
b.material_code, b.material_name, b.specification_model
order by sort_order, MAX(a.update_time) desc
</select>
<!-- 按货主+物料汇总:A货主物料1、A货主物料2、B货主物料1、B货主物料2 为 4 行;库位取该货主+该物料下创建时间最新的一条明细 -->
<select id="queryListByHzWl" parameterType="com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryDO" resultMap="MaterialInventoryResult">
select
@@ -580,6 +619,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
group by b.material_base_info_id, a.shipper_id, a.batch_number
order by max(b.material_name), max(a.shipper_name), a.batch_number
</when>
<when test="queryType != null and queryType == 7">
group by b.material_base_info_id, a.shipper_id, a.expiry_date
order by max(b.material_name), max(a.shipper_name), a.expiry_date
</when>
<when test="queryType != null and queryType == 4">
group by a.storage_location_id
order by max(a.storage_location_code)