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); }