From 878b6958363308a7d07b7b8197dc19662f3e1198 Mon Sep 17 00:00:00 2001
From: sgj <1442489573@qq.com>
Date: 星期五, 27 三月 2026 15:40:22 +0800
Subject: [PATCH] 获取出入库id,逻辑优化调整
---
fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutRecordService.java | 33 +++++++++++++++------------------
1 files changed, 15 insertions(+), 18 deletions(-)
diff --git a/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutRecordService.java b/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutRecordService.java
index d4b0335..b2c65db 100644
--- a/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutRecordService.java
+++ b/fzzy-igdss-core/src/main/java/com/fzzy/igds/service/InoutRecordService.java
@@ -244,7 +244,7 @@
InoutRecord record = new InoutRecord();
BeanUtils.copyProperties(data, record);
//淇濆瓨
- int num = this.addInoutRecord(record);
+ int num = this.addInoutRecord(record,true);
//闄勪欢澶勭悊
fileService.saveInoutFiles(data.getFiles(), record.getId(), null, "INOUT");
@@ -262,13 +262,13 @@
* @param list
* @return
*/
- public String addInoutRecordList(List<InoutRecord> list) {
+ public String addInoutRecordList(List<InoutRecord> list,boolean isCache) {
if (null == list || list.isEmpty()) {
return "鏂板澶辫触";
}
for (InoutRecord inoutRecord : list) {
- addInoutRecord(inoutRecord);
+ addInoutRecord(inoutRecord,isCache);
}
return null;
@@ -280,10 +280,10 @@
* @param data
* @return
*/
- public int addInoutRecord(InoutRecord data) {
+ public int addInoutRecord(InoutRecord data,boolean isCache) {
if (StringUtils.isBlank(data.getId())) {
- String id = this.createId(data.getRegisterTime(), data.getCompanyId());
+ String id = this.createId(data.getRegisterTime(), data.getCompanyId(),isCache);
if (Constant.TYPE_IN.equals(data.getType())) {
data.setId("R_" + id);
} else if (Constant.TYPE_OUT.equals(data.getType())) {
@@ -595,7 +595,7 @@
* @param companyId
* @return
*/
- public String createId(Date registerTime, String companyId) {
+ public String createId(Date registerTime, String companyId,boolean isCache) {
// 鏃堕棿鎴虫爣绛�
String timeKey = DateFormatUtils.format(registerTime, "yyyyMMdd");
@@ -603,7 +603,10 @@
// 浠庣紦瀛樹腑鑾峰彇宸叉湁鐨勭粍缁囩紪鐮�
String cacheKey = RedisConst.buildKey(companyId, Constant.CACHE_RECORD_ID);
- String cacheId = (String) redisCache.getCacheObject(cacheKey);
+ String cacheId = null;
+ if (isCache) {
+ cacheId=(String) redisCache.getCacheObject(cacheKey);
+ }
if (null != cacheId && cacheId.indexOf(timeKey) >= 0) {
String temp = cacheId.substring(cacheId.length() - 4);
@@ -668,7 +671,9 @@
}
// 鏇存柊缂撳瓨
- redisCache.setCacheObject(cacheKey, cacheId);
+ if(isCache){
+ redisCache.setCacheObject(cacheKey, cacheId);
+ }
return cacheId;
}
@@ -683,15 +688,8 @@
public boolean checkIdExists(String companyId, String id) {
QueryWrapper<InoutRecord> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("company_id", companyId);
- queryWrapper.and(wrapper ->
- wrapper.eq("id", id)
- .or()
- .eq("id", "R_" + id)
- .or()
- .eq("id", "C_" + id)
- .or()
- .eq("id", "M_" + id)
- );
+ //浣跨敤likeleft
+ queryWrapper.likeLeft("id", id);
List<InoutRecord> inoutRecords = inoutRecordMapper.selectList(queryWrapper);
if( null != inoutRecords && inoutRecords.size() > 0){
return true;
@@ -716,7 +714,6 @@
queryWrapper.eq("company_id", companyId);
queryWrapper.like("id", timeKey);
queryWrapper.orderByDesc("register_time");
- queryWrapper.orderByDesc("id");
List<InoutRecord> inoutRecords = inoutRecordMapper.selectList(queryWrapper);
if (null == inoutRecords || inoutRecords.isEmpty()) {
return null;
--
Gitblit v1.9.3