库存查询根据查询维度分组插叙;

This commit is contained in:
王奎兴
2026-02-07 15:40:56 +08:00
parent ea4b53b041
commit de7c40e6ce
5 changed files with 87 additions and 8 deletions
@@ -23,10 +23,16 @@ import java.util.List;
*/ */
public interface MaterialInventoryMapper extends BaseMapper<MaterialInventory> public interface MaterialInventoryMapper extends BaseMapper<MaterialInventory>
{ {
/** //查全部
* 查询物料库存列表
*/
public List<MaterialInventoryPO> queryList(MaterialInventoryDO materialInventoryDO); public List<MaterialInventoryPO> queryList(MaterialInventoryDO materialInventoryDO);
//查物料库存列表-物料/库位
public List<MaterialInventoryPO> queryListByWlKw(MaterialInventoryDO materialInventoryDO);
//查物料库存列表-库位
public List<MaterialInventoryPO> queryListByKw(MaterialInventoryDO materialInventoryDO);
//查物料库存列表-物料
public List<MaterialInventoryPO> queryListByWl(MaterialInventoryDO materialInventoryDO);
//查物料库存列表-货主
public List<MaterialInventoryPO> queryListByHz(MaterialInventoryDO materialInventoryDO);
/** /**
* @description 批量增加库存 * @description 批量增加库存
@@ -48,7 +48,20 @@ public class MaterialInventoryImpl extends ServiceImpl<MaterialInventoryMapper,
@Override @Override
public List<MaterialInventoryPO> queryList(MaterialInventoryDO materialInventoryDO) public List<MaterialInventoryPO> queryList(MaterialInventoryDO materialInventoryDO)
{ {
return materialInventoryMapper.queryList(materialInventoryDO); String queryRule = materialInventoryDO.getQueryRule();
if ("hz".equals(queryRule)) {
return materialInventoryMapper.queryListByHz(materialInventoryDO);
} else if ("wl".equals(queryRule)) {
return materialInventoryMapper.queryListByWl(materialInventoryDO);
} else if ("kw".equals(queryRule)) {
return materialInventoryMapper.queryListByKw(materialInventoryDO);
} else if ("wlkw".equals(queryRule)) {
return materialInventoryMapper.queryListByWlKw(materialInventoryDO);
} else if ("all".equals(queryRule)) {
return materialInventoryMapper.queryList(materialInventoryDO);
} else {
throw new ServiceException("查询规则不存在");
}
} }
/** /**
@@ -365,4 +378,4 @@ public class MaterialInventoryImpl extends ServiceImpl<MaterialInventoryMapper,
public MaterialInventoryPO selectOneByWhere(MaterialInventoryDO materialInventoryDO) { public MaterialInventoryPO selectOneByWhere(MaterialInventoryDO materialInventoryDO) {
return materialInventoryMapper.selectOneByWhere(materialInventoryDO); return materialInventoryMapper.selectOneByWhere(materialInventoryDO);
} }
} }
@@ -226,4 +226,7 @@ public class MaterialInventoryDO extends MaterialBaseDO {
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "ExtAttr4", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") @Excel(name = "ExtAttr4", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date extAttr4; private Date extAttr4;
//查询规则 hz:货主,wl:物料,kw:库位,wlkw:物料库位,all:全部
private String queryRule;
} }
@@ -159,4 +159,6 @@ public class MaterialInventoryDTO extends MaterialBaseDTO {
@ApiModelProperty("箱号/卡板号") @ApiModelProperty("箱号/卡板号")
@Excel(name = "箱号/卡板号") @Excel(name = "箱号/卡板号")
private String boxPalletNo; private String boxPalletNo;
} //查询规则 hz:货主,wl:物料,kw:库位,wlkw:物料库位,all:全部
private String queryRule;
}
@@ -69,8 +69,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.shipper_id, a.shipper_code, a.shipper_name, a.shipper_id, a.shipper_code, a.shipper_name,
a.warehouse_id, a.warehouse_code, a.warehouse_name, a.warehouse_id, a.warehouse_code, a.warehouse_name,
a.storage_section_id, a.storage_code, a.storage_name, a.storage_location_id, a.storage_location_code, a.storage_location_name, a.material_base_info_id,a.material_detail_id, a.storage_section_id, a.storage_code, a.storage_name, a.storage_location_id, a.storage_location_code, a.storage_location_name, a.material_base_info_id,a.material_detail_id,
a.batch_number,a.material_status_code,a.material_status_name,a.container_id,a.container_code,a.container_type,a.container_type_name,IFNULL(a.freeze_quantity,0) freeze_quantity,a.is_able, a.batch_number,a.material_status_code,a.material_status_name,a.container_id,a.container_code,a.container_type,a.container_type_name
IFNULL(a.inventory_quantity,0) inventory_quantity, IFNULL(a.allocation_quantity,0) allocation_quantity, a.remark, a.create_time, a.create_by, a.create_by_name, a.update_time, a.update_by, a.update_by_name, ,IFNULL (sum(a.freeze_quantity), 0) freeze_quantity,a.is_able,
IFNULL (sum(a.inventory_quantity), 0) inventory_quantity,
IFNULL (sum(a.allocation_quantity), 0) allocation_quantity,
a.remark, a.create_time, a.create_by, a.create_by_name, a.update_time, a.update_by, a.update_by_name,
a.del_flag,a.unit,a.area,a.NET_WEIGHT,a.GROSS_WEIGHT,a.VOLUME, a.del_flag,a.unit,a.area,a.NET_WEIGHT,a.GROSS_WEIGHT,a.VOLUME,
a.BATCH_REF_NO, a.SHEET_REF_NO, a.BOX_PALLET_NO,nvl(a.unit_name,b.unit_name) as unit_name a.BATCH_REF_NO, a.SHEET_REF_NO, a.BOX_PALLET_NO,nvl(a.unit_name,b.unit_name) as unit_name
</sql> </sql>
@@ -186,6 +189,58 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectMaterialInventoryPo1"/> <include refid="selectMaterialInventoryPo1"/>
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPoWhere"/> <include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPoWhere"/>
</where> </where>
group by a.MATERIAL_INVENTORY_ID
</select>
<select id="queryListByWlKw" parameterType="com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryDO" resultMap="MaterialInventoryResult">
select
<include refid="selectMaterialInventoryPo"/>
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPo"/>
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.WAREHOUSE_ID,a.STORAGE_SECTION_ID,a.STORAGE_LOCATION_ID
</select>
<select id="queryListByKw" parameterType="com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryDO" resultMap="MaterialInventoryResult">
select
<include refid="selectMaterialInventoryPo"/>
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPo"/>
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.WAREHOUSE_ID,a.STORAGE_SECTION_ID,a.STORAGE_LOCATION_ID
</select>
<select id="queryListByWl" parameterType="com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryDO" resultMap="MaterialInventoryResult">
select
<include refid="selectMaterialInventoryPo"/>
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPo"/>
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
</select>
<select id="queryListByHz" parameterType="com.mhd.wms.domain.materialInventory.repository.todo.MaterialInventoryDO" resultMap="MaterialInventoryResult">
select
<include refid="selectMaterialInventoryPo"/>
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPo"/>
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>
</select> </select>
<resultMap type="com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryQueryListPO" id="MaterialQueryListResult"> <resultMap type="com.mhd.wms.domain.materialInventory.repository.po.MaterialInventoryQueryListPO" id="MaterialQueryListResult">