From deb8a2c32ba0cb7a88819b54d720418cdc2f7ebb Mon Sep 17 00:00:00 2001
From: sgj <1442489573@qq.com>
Date: 星期二, 24 三月 2026 16:58:53 +0800
Subject: [PATCH] 粮情报表,数量监测报表,库区回显错误纠正
---
fzzy-igdss-core/src/main/java/com/fzzy/igds/service/DepotService.java | 85 +++++++++++++++++++++++++++++++-----------
1 files changed, 63 insertions(+), 22 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 60d0afc..8501085 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
@@ -2,11 +2,14 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.fzzy.igds.constant.Constant;
import com.fzzy.igds.constant.RedisConst;
import com.fzzy.igds.domain.Depot;
import com.fzzy.igds.domain.DepotStore;
+import com.fzzy.igds.domain.Dept;
import com.fzzy.igds.mapper.DepotMapper;
import com.fzzy.igds.utils.ContextUtil;
+import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
@@ -15,6 +18,7 @@
import javax.annotation.Resource;
import java.util.*;
+import java.util.concurrent.TimeUnit;
/**
* @Description
@@ -31,6 +35,9 @@
private RedisCache redisCache;
@Resource
private DepotStoreService depotStoreService;
+
+ @Resource
+ private CoreDeptService coreDeptService;
/**
* 鏌ヨ搴撳尯涓嬩粨搴撳垪琛�
@@ -60,6 +67,51 @@
}
return depotMapper.selectList(queryWrapper);
+ }
+
+ /**
+ * 鏍规嵁鐢ㄦ埛绫诲瀷鏌ヨ鎵�鏈変粨搴擄紝浣滀负dorado鐨刴ap鍥炴樉浣跨敤
+ *
+ * @param deptId
+ * @author sgj
+ * @since 2026/03/24
+ */
+ public List<Depot> getDepotByUserType(String deptId) {
+ List<Depot> result = new ArrayList<>();
+
+ if (StringUtils.isNotBlank(deptId)) {
+ //鏌ュ叕鍙镐笅鎵�鏈夊簱鍖�
+ result = this.getData(null, deptId, false);
+ return result;
+ }
+ //鑾峰彇褰撳墠鐧诲綍浜�
+ SysUser user = ContextUtil.getLoginUser();
+
+ if (Constant.USER_TYPE_10.equals(user.getUserType())) {
+ //鐩戠鐢ㄦ埛锛岀洿鎺ユ煡璇㈢粍缁囦笅鎵�鏈夊簱鍖�
+ result = this.getData(user.getCompanyId(), null, false);
+ return result;
+ }
+ if (Constant.USER_TYPE_20.equals(user.getUserType())) {
+ //閾惰鐢ㄦ埛锛屾牴鎹悎鍚屾煡璇㈤摱琛屼笅鎵�鏈夊簱鍖�
+ List<Dept> deptByBank = coreDeptService.getDeptByBank(user.getUserData());
+ for (Dept dept : deptByBank) {
+ result.addAll(this.getData(null, dept.getId(), false));
+ }
+ return result;
+ }
+ if (Constant.USER_TYPE_30.equals(user.getUserType())) {
+ //搴撳尯鐢ㄦ埛
+ if (ContextUtil.isDepotUser(user.getDeptId() + "")) {
+ //鏌ヨ鐢ㄦ埛鎵�灞炲簱鍖�
+ result = this.getData(null, user.getDeptId() + "", false);
+ } else {
+ //鏌ヨ鐢ㄦ埛鎵�灞炲叕鍙镐笅鎵�鏈夊簱鍖�
+ result = this.getData(user.getCompanyId(), null, false);
+ }
+ return result;
+ }
+ return result;
}
/**
@@ -129,7 +181,6 @@
lastData.setUpdateTime(new Date());
lastData.setUpdateBy("绯荤粺瀹氭椂缁熻");
-
lastData.setDepotStatus(depot.getDepotStatus());
lastData.setFoodVariety(depot.getFoodVariety());
lastData.setFoodLevel(depot.getFoodLevel());
@@ -137,7 +188,6 @@
lastData.setFoodLocationId(depot.getFoodLocationId());
lastData.setFoodType(depot.getFoodType());
lastData.setFoodYear(depot.getFoodYear());
-
lastData.setStorageReal(depot.getStorageReal());
lastData.setCreateTime(new Date()); //璁剧疆涓烘渶鏂版椂闂达紝鍏朵粬绯荤粺鍙互閫氳繃姝ゆ椂闂存煡璇㈡暟鎹槸鍚︽湁鏇存柊淇敼锛屽悓姝ュ埌鐪佸钩鍙版帴鍙c��
@@ -217,7 +267,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,13 +299,15 @@
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);
if (null != keys) {
for (String key : keys) {
+ if (null == redisCache.getCacheObject(key)) {
+ list = new ArrayList<>();
+ break;
+ }
list.add((Depot) redisCache.getCacheObject(key));
}
}
@@ -266,27 +318,16 @@
setCacheDepotList(list, companyId);
}
if (!list.isEmpty()) {
- //閲嶆柊鎺掑簭
- //妫�鏌ユ暟鎹槸鍚︿负绌�
- for (Depot depot : list) {
- if( null!=depot){
- resultList.add(depot);
- }
- }
- boolean hasNullOrderNum = true;
// 妫�鏌ユ槸鍚︽湁浠撳簱鐨勬帓搴忓彿涓虹┖
- for (Depot depot : resultList) {
- if ( null== depot.getOrderNum()) {
- hasNullOrderNum = true;
- break;
+ for (Depot depot : list) {
+ if (null == depot.getOrderNum()) {
+ //鎺掑簭鍙蜂负绌猴紝鍒欓粯璁ょ粰1
+ depot.setOrderNum(1);
}
}
- // 濡傛灉瀛樺湪鎺掑簭鍙蜂负绌虹殑浠撳簱锛屽垯涓嶈繘琛屾帓搴�
- if (!hasNullOrderNum) {
- Collections.sort(resultList, (p1, p2) -> p1.getOrderNum() - p2.getOrderNum());
- }
+ Collections.sort(list, (p1, p2) -> p1.getOrderNum() - p2.getOrderNum());
}
- return resultList;
+ return list;
}
/**
--
Gitblit v1.9.3