opt:优化首页单据数量
This commit is contained in:
@@ -64,7 +64,7 @@ public class RestBusinessTemplate {
|
||||
try {
|
||||
callback.execute();
|
||||
result.setCode(ResultCode.SUCCESS.getCode());
|
||||
result.setDesc("推送中,如未审核成功,请查看单据审核结果信息。");
|
||||
result.setDesc("正在推送,如未审核成功,请查看单据审核结果信息。");
|
||||
} catch (BadRequestException e) {
|
||||
log.error("", e);
|
||||
ResultCode code = e.getCode() == null ? ResultCode.FAILED : e.getCode();
|
||||
|
||||
@@ -39,6 +39,15 @@ public interface IeasOutInBillService extends IService<EasOutInBill> {
|
||||
List<HomeBillCounts> getBillsCount();
|
||||
|
||||
|
||||
/**
|
||||
* 查询出入库单据数量
|
||||
*
|
||||
* @return JSONObject
|
||||
*/
|
||||
List<HomeBillCounts> queryBillsCount();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取组织机构信息
|
||||
*
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.base.CommonPage;
|
||||
import org.nl.common.enums.wms.EasBillTypeEnum;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.RedisUtils;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.config.IdUtil;
|
||||
import org.nl.wms.database.eas.dao.*;
|
||||
@@ -30,6 +31,7 @@ import org.nl.wms.ext.srm.WmsToSrmService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -45,6 +47,7 @@ import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -83,10 +86,28 @@ public class EasOutInBillServiceImpl extends ServiceImpl<EasOutInBillMapper, Eas
|
||||
@Qualifier("threadPoolExecutor")
|
||||
private ThreadPoolExecutor pool;
|
||||
|
||||
@Resource
|
||||
private RedisUtils redisUtils;
|
||||
|
||||
|
||||
|
||||
public List<HomeBillCounts> getBillsCount() {
|
||||
String cacheKey = "billCounts";
|
||||
//从Redis中获取缓存数据
|
||||
List<HomeBillCounts> cachedCounts = (List<HomeBillCounts>) redisUtils.get(cacheKey);
|
||||
if (cachedCounts != null) {
|
||||
return cachedCounts;
|
||||
}
|
||||
List<HomeBillCounts> allCounts = queryBillsCount();
|
||||
// 将结果存入Redis,设置过期时间为1小时
|
||||
redisUtils.set(cacheKey, allCounts, 1, TimeUnit.HOURS);
|
||||
return allCounts;
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页显示出入库单据数量
|
||||
*/
|
||||
public List<HomeBillCounts> getBillsCount() {
|
||||
public List<HomeBillCounts> queryBillsCount() {
|
||||
AtomicReference<Long> receiptCount = new AtomicReference<>(0L);
|
||||
AtomicReference<Long> allocationCount = new AtomicReference<>(0L);
|
||||
AtomicReference<List<HomeBillCounts>> inOutBillList = new AtomicReference<>();
|
||||
|
||||
@@ -3,11 +3,13 @@ import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.nl.common.utils.RedisUtils;
|
||||
import org.nl.common.websocket.SendHomeWebSocketServer;
|
||||
import org.nl.config.IdUtil;
|
||||
import org.nl.system.service.user.dao.SysUser;
|
||||
import org.nl.system.service.user.dao.mapper.SysUserMapper;
|
||||
import org.nl.wms.database.eas.dao.EasOutInBillDetail;
|
||||
import org.nl.wms.database.eas.dao.HomeBillCounts;
|
||||
import org.nl.wms.database.eas.dao.mapper.EasOutInBillDetailMapper;
|
||||
import org.nl.wms.database.eas.service.IeasOutInBillService;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
@@ -19,6 +21,7 @@ import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.nl.wms.database.eas.dao.EasOutInBill;
|
||||
@@ -42,6 +45,15 @@ public class EasBillSchedule {
|
||||
@Resource
|
||||
private SysUserMapper sysUserMapper;
|
||||
|
||||
@Resource
|
||||
private IeasOutInBillService ieasOutInBillService;
|
||||
|
||||
|
||||
|
||||
@Resource
|
||||
private RedisUtils redisUtils;
|
||||
|
||||
|
||||
/**
|
||||
* eas单据数据同步
|
||||
*/
|
||||
@@ -130,6 +142,16 @@ public class EasBillSchedule {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 首页单据查询
|
||||
*/
|
||||
@Async("taskExecutor")
|
||||
@Scheduled(cron = "0/30 * * * * *")
|
||||
public void updateRedisCache() {
|
||||
List<HomeBillCounts> billsCount = ieasOutInBillService.queryBillsCount();
|
||||
redisUtils.set("billCounts", billsCount, 1, TimeUnit.HOURS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页信息推送
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user