From 6a423c07636b40df3eda98a9ad7c0c9a2d4dcba9 Mon Sep 17 00:00:00 2001 From: liwen Date: Tue, 2 Apr 2024 21:06:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=97=A5=E5=B8=B8=E7=BB=B4=E6=8A=A4?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2=E6=B7=BB=E5=8A=A0=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/OperMaintenanceTaskServiceImpl.java | 36 ++++++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java index dca5b5b..b00f071 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java @@ -64,6 +64,7 @@ import java.text.DecimalFormat; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; @@ -85,6 +86,8 @@ public class OperMaintenanceTaskServiceImpl extends BaseServiceImpl> list(OperMaintenanceTaskDTO req) { - Query query=new Query(); - query.setSize(req.getSize()); - query.setCurrent(req.getCurrent()); - Wrapper queryWrapper = getQueryWrapper(req); - IPage pages = super.page(Condition.getPage(query), queryWrapper); - pages.setRecords(OperMaintenanceTaskWrapper.build().listVO(pages.getRecords())); + List inspects = (List) redisTemplate.opsForValue() + .get("maintenance_task_list" + req.getCurrent() + req.getSize()); + Long total = (Long) redisTemplate.opsForValue().get("maintenance_task_list_total"); + IPage pages = new Page<>(req.getCurrent(), req.getSize()); + if (ObjectUtil.isEmpty(inspects) || ObjectUtil.isEmpty(total)) { + Query query = new Query(); + query.setSize(req.getSize()); + query.setCurrent(req.getCurrent()); + Wrapper queryWrapper = getQueryWrapper(req); + List list = super.list(queryWrapper); + List voList = new ArrayList<>(); + list.forEach(x -> { + OperMaintenanceTaskVO operMaintenanceTaskVO = new OperMaintenanceTaskVO(); + BeanUtils.copyProperties(x, operMaintenanceTaskVO); + voList.add(operMaintenanceTaskVO); + }); + pages.setRecords(voList); + redisTemplate.opsForValue().set("maintenance_task_list" + req.getCurrent() + req.getSize(), voList); + redisTemplate.expire("maintenance_task_list" + req.getCurrent() + req.getSize(),60, TimeUnit.SECONDS); + redisTemplate.opsForValue().set("maintenance_task_list_total",pages.getTotal()); + redisTemplate.expire("maintenance_task_list_total",60, TimeUnit.SECONDS); + return R.data(pages); + } + pages.setRecords(inspects); + pages.setCurrent(req.getCurrent()); + pages.setSize(req.getSize()); + pages.setTotal(total); return R.data(pages); }