fix(material): 修复查询中缺少逻辑删除过滤条件的问题

- 在采购单查询中添加状态过滤,排除已取消的采购单
- 在采购明细查询中添加逻辑删除标志过滤
- 在价格历史记录查询中统一添加逻辑删除标志过滤
- 确保所有数据查询都遵循逻辑删除规范
This commit is contained in:
2026-01-31 15:05:39 +08:00
parent 48e75676c5
commit cf94814ae6
2 changed files with 6 additions and 0 deletions

View File

@@ -200,6 +200,7 @@ public class MatMaterialServiceImpl implements IMatMaterialService {
QueryWrapper<MatPurchase> purchaseQw = new QueryWrapper<>();
purchaseQw.in("material_id", materialIds);
purchaseQw.eq("del_flag", 0);
purchaseQw.ne("status", 3); // 排除已取消的采购单
List<MatPurchase> purchaseListPo = matPurchaseMapper.selectList(purchaseQw);
// 按materialId分组
@@ -220,6 +221,8 @@ public class MatMaterialServiceImpl implements IMatMaterialService {
if (!purchaseIds.isEmpty()) {
LambdaQueryWrapper<MatPurchaseInDetail> detailLqw = Wrappers.lambdaQuery();
detailLqw.in(MatPurchaseInDetail::getPurchaseId, purchaseIds);
// 逻辑删除
detailLqw.eq(MatPurchaseInDetail::getDelFlag, 0);
List<MatPurchaseInDetail> allDetails = matPurchaseInDetailMapper.selectList(detailLqw);
detailsByPurchaseId = allDetails.stream()
.collect(Collectors.groupingBy(MatPurchaseInDetail::getPurchaseId));

View File

@@ -317,6 +317,8 @@ public class MatPurchaseInDetailServiceImpl implements IMatPurchaseInDetailServi
LambdaQueryWrapper<MatPriceHistory> lqw = Wrappers.lambdaQuery();
lqw.eq(MatPriceHistory::getMaterialId, materialId);
lqw.orderByDesc(MatPriceHistory::getCreateTime);
// 逻辑删除
lqw.eq(MatPriceHistory::getDelFlag, 0);
lqw.last("LIMIT 1");
MatPriceHistoryVo lastHistory = matPriceHistoryMapper.selectVoOne(lqw);
@@ -405,6 +407,7 @@ public class MatPurchaseInDetailServiceImpl implements IMatPurchaseInDetailServi
LambdaQueryWrapper<MatPriceHistory> lqw = Wrappers.lambdaQuery();
lqw.eq(MatPriceHistory::getMaterialId, materialId);
lqw.eq(MatPriceHistory::getPurchaseInDetailId, purchaseInDetailId);
lqw.eq(MatPriceHistory::getDelFlag, 0);
// 查询待删除的记录
List<MatPriceHistoryVo> historyList = matPriceHistoryMapper.selectVoList(lqw);