From 87ebafb4f20d329babfc55c25727db8628f32bad Mon Sep 17 00:00:00 2001
From: sgj <1442489573@qq.com>
Date: 星期一, 09 三月 2026 11:33:17 +0800
Subject: [PATCH] 仓库缓存添加24小时保存限制
---
fzzy-igdss-core/src/main/java/com/fzzy/igds/service/DepotService.java | 51 +++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 45 insertions(+), 6 deletions(-)
diff --git a/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/DepotService.java b/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/DepotService.java
index 9a7dfd0..ce51da9 100644
--- a/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/DepotService.java
+++ b/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/DepotService.java
@@ -15,6 +15,7 @@
import javax.annotation.Resource;
import java.util.*;
+import java.util.concurrent.TimeUnit;
/**
* @Description
@@ -217,7 +218,7 @@
String key;
for (Depot depot : list) {
key = RedisConst.buildKey(companyId, RedisConst.KEY_DEPOT, depot.getId());
- redisCache.setCacheObject(key, depot);
+ redisCache.setCacheObject(key, depot, 24, TimeUnit.HOURS);
}
}
@@ -249,6 +250,8 @@
companyId = ContextUtil.getCompanyId();
}
List<Depot> list = new ArrayList<>();
+ List<Depot> resultList = new ArrayList<>();
+
String patten = RedisConst.buildKey(companyId, RedisConst.KEY_DEPOT) + "*";
Collection<String> keys = redisCache.keys(patten);
@@ -265,9 +268,26 @@
}
if (!list.isEmpty()) {
//閲嶆柊鎺掑簭
- Collections.sort(list, (p1, p2) -> p1.getOrderNum() - p2.getOrderNum());
+ //妫�鏌ユ暟鎹槸鍚︿负绌�
+ for (Depot depot : list) {
+ if( null!=depot){
+ resultList.add(depot);
+ }
+ }
+ boolean hasNullOrderNum = true;
+ // 妫�鏌ユ槸鍚︽湁浠撳簱鐨勬帓搴忓彿涓虹┖
+ for (Depot depot : resultList) {
+ if ( null== depot.getOrderNum()) {
+ hasNullOrderNum = true;
+ break;
+ }
+ }
+ // 濡傛灉瀛樺湪鎺掑簭鍙蜂负绌虹殑浠撳簱锛屽垯涓嶈繘琛屾帓搴�
+ if (!hasNullOrderNum) {
+ Collections.sort(resultList, (p1, p2) -> p1.getOrderNum() - p2.getOrderNum());
+ }
}
- return list;
+ return resultList;
}
/**
@@ -282,6 +302,8 @@
return null;
}
List<Depot> list = getCacheDepotList(companyId);
+ List<Depot> resultList = new ArrayList<>();
+
if (null == list || list.isEmpty()) {
return null;
}
@@ -291,11 +313,28 @@
result.add(depot);
}
}
- if (!result.isEmpty()) {
+ if (!list.isEmpty()) {
//閲嶆柊鎺掑簭
- Collections.sort(list, (p1, p2) -> p1.getOrderNum() - p2.getOrderNum());
+ //妫�鏌ユ暟鎹槸鍚︿负绌�
+ for (Depot depot : list) {
+ if( null!=depot){
+ resultList.add(depot);
+ }
+ }
+ boolean hasNullOrderNum = true;
+ // 妫�鏌ユ槸鍚︽湁浠撳簱鐨勬帓搴忓彿涓虹┖
+ for (Depot depot : resultList) {
+ if ( null== depot.getOrderNum()) {
+ hasNullOrderNum = true;
+ break;
+ }
+ }
+ // 濡傛灉瀛樺湪鎺掑簭鍙蜂负绌虹殑浠撳簱锛屽垯涓嶈繘琛屾帓搴�
+ if (!hasNullOrderNum) {
+ Collections.sort(resultList, (p1, p2) -> p1.getOrderNum() - p2.getOrderNum());
+ }
}
- return result;
+ return resultList;
}
/**
--
Gitblit v1.9.3