feat(inventory): 扩展库存筛选功能支持多范围条件

- 将原有的库存是否为零筛选扩展为更灵活的库存范围筛选
- 新增多种库存数量筛选选项:无限制、等于0、大于0、小于等于20、小于等于50
- 使用switch语句重构筛选逻辑提高代码可读性
- 更新注释文档说明新的筛选参数含义
- 修改查询方法支持返回全部记录不分页的功能
This commit is contained in:
2026-03-03 14:16:52 +08:00
parent 45fdca65a7
commit cd3155e63c

View File

@@ -86,7 +86,7 @@ public class ProductDetailAppServiceImpl extends ServiceImpl<InventoryItemMapper
List<String> medCategoryCodes = productDetailSearchParam.getMedCategoryCodes(); List<String> medCategoryCodes = productDetailSearchParam.getMedCategoryCodes();
// 药品类型 // 药品类型
List<String> devCategoryCodes = productDetailSearchParam.getDevCategoryCodes(); List<String> devCategoryCodes = productDetailSearchParam.getDevCategoryCodes();
// 库存是否为零 // 库存范围
Integer zeroFlag = productDetailSearchParam.getZeroFlag(); Integer zeroFlag = productDetailSearchParam.getZeroFlag();
// 过期天数 // 过期天数
Integer remainingDays = productDetailSearchParam.getRemainingDays(); Integer remainingDays = productDetailSearchParam.getRemainingDays();
@@ -108,12 +108,29 @@ public class ProductDetailAppServiceImpl extends ServiceImpl<InventoryItemMapper
if (devCategoryCodes != null && !devCategoryCodes.isEmpty()) { if (devCategoryCodes != null && !devCategoryCodes.isEmpty()) {
queryWrapper.in(CommonConstants.FieldName.DevCategoryCode, devCategoryCodes); queryWrapper.in(CommonConstants.FieldName.DevCategoryCode, devCategoryCodes);
} }
// 库存是否为零 (zeroFlag: 1=库存为零, 0=库存大于零) // 库存范围筛选 (zeroFlag: 1=无限制, 2=数量等于0, 3=数量大于0, 4=数量<=20, 5=数量<=50)
if (zeroFlag != null) { if (zeroFlag != null) {
if (Integer.valueOf(1).equals(zeroFlag)) { switch (zeroFlag) {
case 2:
// 数量等于0
queryWrapper.eq(CommonConstants.FieldName.Quantity, BigDecimal.ZERO); queryWrapper.eq(CommonConstants.FieldName.Quantity, BigDecimal.ZERO);
} else { break;
case 3:
// 数量大于0
queryWrapper.gt(CommonConstants.FieldName.Quantity, BigDecimal.ZERO); queryWrapper.gt(CommonConstants.FieldName.Quantity, BigDecimal.ZERO);
break;
case 4:
// 数量小于等于20
queryWrapper.le(CommonConstants.FieldName.Quantity, new BigDecimal("20"));
break;
case 5:
// 数量小于等于50
queryWrapper.le(CommonConstants.FieldName.Quantity, new BigDecimal("50"));
break;
case 1:
default:
// 无限制,不添加筛选条件
break;
} }
} }
// 所在位置 // 所在位置
@@ -132,7 +149,6 @@ public class ProductDetailAppServiceImpl extends ServiceImpl<InventoryItemMapper
Page<ProductDetailPageDto> productDetailsPage = productDetailsMapper.selectProductDetailsPage( Page<ProductDetailPageDto> productDetailsPage = productDetailsMapper.selectProductDetailsPage(
new Page<>(pageNo, pageSize), queryWrapper, CommonConstants.TableName.MED_MEDICATION_DEFINITION, new Page<>(pageNo, pageSize), queryWrapper, CommonConstants.TableName.MED_MEDICATION_DEFINITION,
CommonConstants.TableName.ADM_DEVICE_DEFINITION, ConditionCode.LOT_NUMBER_COST.getCode()); CommonConstants.TableName.ADM_DEVICE_DEFINITION, ConditionCode.LOT_NUMBER_COST.getCode());
// 库存明细
List<ProductDetailPageDto> productDetailList = productDetailsPage.getRecords(); List<ProductDetailPageDto> productDetailList = productDetailsPage.getRecords();
if (productDetailList != null && !productDetailList.isEmpty()) { if (productDetailList != null && !productDetailList.isEmpty()) {
// 医嘱定价来源 // 医嘱定价来源
@@ -259,12 +275,29 @@ public class ProductDetailAppServiceImpl extends ServiceImpl<InventoryItemMapper
if (devCategoryCodes != null && !devCategoryCodes.isEmpty()) { if (devCategoryCodes != null && !devCategoryCodes.isEmpty()) {
queryWrapper.in(CommonConstants.FieldName.DevCategoryCode, devCategoryCodes); queryWrapper.in(CommonConstants.FieldName.DevCategoryCode, devCategoryCodes);
} }
// 库存是否为零 (zeroFlag: 1=库存为零, 0=库存大于零) // 库存范围筛选 (zeroFlag: 1=无限制, 2=数量等于0, 3=数量大于0, 4=数量<=20, 5=数量<=50)
if (zeroFlag != null) { if (zeroFlag != null) {
if (Integer.valueOf(1).equals(zeroFlag)) { switch (zeroFlag) {
case 2:
// 数量等于0
queryWrapper.eq(CommonConstants.FieldName.Quantity, BigDecimal.ZERO); queryWrapper.eq(CommonConstants.FieldName.Quantity, BigDecimal.ZERO);
} else { break;
case 3:
// 数量大于0
queryWrapper.gt(CommonConstants.FieldName.Quantity, BigDecimal.ZERO); queryWrapper.gt(CommonConstants.FieldName.Quantity, BigDecimal.ZERO);
break;
case 4:
// 数量小于等于20
queryWrapper.le(CommonConstants.FieldName.Quantity, new BigDecimal("20"));
break;
case 5:
// 数量小于等于50
queryWrapper.le(CommonConstants.FieldName.Quantity, new BigDecimal("50"));
break;
case 1:
default:
// 无限制,不添加筛选条件
break;
} }
} }
// 所在位置 // 所在位置
@@ -507,12 +540,29 @@ public class ProductDetailAppServiceImpl extends ServiceImpl<InventoryItemMapper
if (devCategoryCodes != null && !devCategoryCodes.isEmpty()) { if (devCategoryCodes != null && !devCategoryCodes.isEmpty()) {
queryWrapper.in(CommonConstants.FieldName.DevCategoryCode, devCategoryCodes); queryWrapper.in(CommonConstants.FieldName.DevCategoryCode, devCategoryCodes);
} }
// 库存是否为零 (zeroFlag: 1=库存为零, 0=库存大于零) // 库存范围筛选 (zeroFlag: 1=无限制, 2=数量等于0, 3=数量大于0, 4=数量<=20, 5=数量<=50)
if (zeroFlag != null) { if (zeroFlag != null) {
if (Integer.valueOf(1).equals(zeroFlag)) { switch (zeroFlag) {
case 2:
// 数量等于0
queryWrapper.eq(CommonConstants.FieldName.Quantity, BigDecimal.ZERO); queryWrapper.eq(CommonConstants.FieldName.Quantity, BigDecimal.ZERO);
} else { break;
case 3:
// 数量大于0
queryWrapper.gt(CommonConstants.FieldName.Quantity, BigDecimal.ZERO); queryWrapper.gt(CommonConstants.FieldName.Quantity, BigDecimal.ZERO);
break;
case 4:
// 数量小于等于20
queryWrapper.le(CommonConstants.FieldName.Quantity, new BigDecimal("20"));
break;
case 5:
// 数量小于等于50
queryWrapper.le(CommonConstants.FieldName.Quantity, new BigDecimal("50"));
break;
case 1:
default:
// 无限制,不添加筛选条件
break;
} }
} }
// 所在位置 // 所在位置
@@ -527,7 +577,7 @@ public class ProductDetailAppServiceImpl extends ServiceImpl<InventoryItemMapper
if (remainingDays != null) { if (remainingDays != null) {
queryWrapper.le(CommonConstants.FieldName.RemainingDays, remainingDays); queryWrapper.le(CommonConstants.FieldName.RemainingDays, remainingDays);
} }
// 查询库存商品明细分页列表 // 查询库存商品明细分页列表(不分页,查询全部)
List<ProductDetailPageDto> productDetailList = productDetailsMapper.getProductDetailPageAndTranslateField( List<ProductDetailPageDto> productDetailList = productDetailsMapper.getProductDetailPageAndTranslateField(
queryWrapper, CommonConstants.TableName.MED_MEDICATION_DEFINITION, queryWrapper, CommonConstants.TableName.MED_MEDICATION_DEFINITION,
CommonConstants.TableName.ADM_DEVICE_DEFINITION, ConditionCode.LOT_NUMBER_COST.getCode()); CommonConstants.TableName.ADM_DEVICE_DEFINITION, ConditionCode.LOT_NUMBER_COST.getCode());