diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/task/IwsCostPushTask.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/task/IwsCostPushTask.java index 332c18da..940157ea 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/task/IwsCostPushTask.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/task/IwsCostPushTask.java @@ -96,6 +96,9 @@ public class IwsCostPushTask { // --------- 定义结果集合 ------------------ List gqjResultList = new ArrayList<>(list.size()); + // 清空缓存,确保每次定时任务都使用最新的数据,避免缓存污染 + sltAgreementInfoService.clearCache(); + try { // 批量处理,减少单个查询 log.info("开始批量处理 {} 个协议的费用明细", list.size()); @@ -286,6 +289,9 @@ public class IwsCostPushTask { // --------- 定义结果集合 ------------------ List gqjResultList = new ArrayList<>(list.size()); + // 清空缓存,确保每次定时任务都使用最新的数据,避免缓存污染 + sltAgreementInfoService.clearCache(); + try { // 批量处理,减少单个查询 log.info("开始批量处理 {} 个协议的费用明细", list.size()); diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/controller/SltAgreementInfoController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/controller/SltAgreementInfoController.java index 867e2955..b8189948 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/controller/SltAgreementInfoController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/controller/SltAgreementInfoController.java @@ -1577,6 +1577,9 @@ public class SltAgreementInfoController extends BaseController { // --------- 定义返回集合 ------------------ List dataList = new ArrayList<>(list.size()); + // 清空缓存,确保每次请求都使用最新的数据,避免缓存污染 + sltAgreementInfoService.clearCache(); + // 批量处理,减少单个查询 list.forEach(info -> { try { @@ -1650,6 +1653,9 @@ public class SltAgreementInfoController extends BaseController { // --------- 定义返回集合 ------------------ List dataList = new ArrayList<>(list.size()); + // 清空缓存,确保每次请求都使用最新的数据,避免缓存污染 + sltAgreementInfoService.clearCache(); + // 批量处理,减少单个查询 list.forEach(info -> { @@ -1669,6 +1675,10 @@ public class SltAgreementInfoController extends BaseController { } }); + + // 清空缓存,防止内存泄漏 + sltAgreementInfoService.clearCache(); + ExcelUtil util = new ExcelUtil<>(SltInfoVo.class); util.exportExcel(response, dataList, "导出未结算报表列表"); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java index 6825776c..8df6e382 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java @@ -285,12 +285,20 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService { if (repairListCache.get() == null) { System.err.println("批量查询结算信息列表 -- 未结算报表专用:开始执行一次性批量维修费用查询"); // 调用一次性批量维修费用查询 - repairListCache.set(sltAgreementInfoMapper.getRepairDetailsListBatch(info, null)); + // 创建一个新的查询对象,只保留 agreementIds 和 settlementType,清空 agreementCode 避免 SQL 过滤条件污染 + SltAgreementInfo batchQueryInfo = new SltAgreementInfo(); + batchQueryInfo.setAgreementIds(info.getAgreementIds()); + batchQueryInfo.setSettlementType(info.getSettlementType()); + repairListCache.set(sltAgreementInfoMapper.getRepairDetailsListBatch(batchQueryInfo, null)); } if (scrapListCache.get() == null) { System.err.println("批量查询结算信息列表 -- 未结算报表专用:开始执行一次性批量报废费用查询"); // 调用一次性批量报废费用查询 - scrapListCache.set(sltAgreementInfoMapper.getScrapDetailsListBatch(info)); + // 创建一个新的查询对象,只保留 agreementIds 和 settlementType,清空 agreementCode 避免 SQL 过滤条件污染 + SltAgreementInfo batchQueryInfo = new SltAgreementInfo(); + batchQueryInfo.setAgreementIds(info.getAgreementIds()); + batchQueryInfo.setSettlementType(info.getSettlementType()); + scrapListCache.set(sltAgreementInfoMapper.getScrapDetailsListBatch(batchQueryInfo)); } // 查询租赁费用列表 List leaseList = getLeaseBtachList(info);