diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java index cbd54f0..c9d29b8 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java @@ -104,9 +104,6 @@ public class TaskServiceImpl extends BaseServiceImpl imp @Autowired private TaskNoUserDataScopeMapper taskNoUserDataScopeMapper; - @Autowired - private RedisTemplate redisTemplate; - /** * 正在调用开始任务的id集合 */ @@ -533,42 +530,12 @@ public class TaskServiceImpl extends BaseServiceImpl imp @Override public BladePage page(TaskDTO taskDTO) { - List inspects = (List) redisTemplate.opsForValue().get("inspect_list" + taskDTO.getCurrent() + taskDTO.getSize()); - Long total = (Long) redisTemplate.opsForValue().get("inspect_list_total"); - if(ObjectUtil.isEmpty(inspects) || ObjectUtil.isEmpty(total)){ - Query query=new Query(); - query.setSize(taskDTO.getSize()); - query.setCurrent(taskDTO.getCurrent()); - IPage pages = Condition.getPage(query); - List list = this.baseMapper.getAllPageList(pages,taskDTO); - List limit = list.stream().peek(taskVo -> { - // 获取机器人信息 - if (taskVo.getAutoVideo().equals(PlanContants.InspectTypeEnum.ROBOT.getVal()) ) { - if (Func.isNotEmpty( ObjectUtil.isNotEmpty(taskVo.getUserId()))) { - taskVo.setRobot(robotService.getDetailByUserId(taskVo.getUserId())); - } - } - }).collect(Collectors.toList()); - pages.setRecords(limit); - redisTemplate.opsForValue().set("inspect_list" + taskDTO.getCurrent() + taskDTO.getSize(),limit); - redisTemplate.expire("inspect_list" + taskDTO.getCurrent() + taskDTO.getSize(),30, TimeUnit.SECONDS); - redisTemplate.opsForValue().set("inspect_list_total",pages.getTotal()); - redisTemplate.expire("inspect_list_total",30, TimeUnit.SECONDS); - return BladePage.of(pages); - } - BladePage page = new BladePage(); - page.setRecords(inspects); - page.setCurrent(taskDTO.getCurrent()); - page.setSize(taskDTO.getSize()); - page.setTotal(total); - return page; - - /* Query query = new Query(); + Query query = new Query(); query.setSize(taskDTO.getSize()); query.setCurrent(taskDTO.getCurrent()); IPage pages = Condition.getPage(query); List list = this.baseMapper.getAllPageList(pages,taskDTO); - list = list.stream().map(taskVo -> { + list = list.stream().peek(taskVo -> { // 获取机器人信息 if (taskVo.getAutoVideo().equals(PlanContants.InspectTypeEnum.ROBOT.getVal()) ) { if (Func.isNotEmpty( ObjectUtil.isNotEmpty(taskVo.getUserId()))) { @@ -580,11 +547,10 @@ public class TaskServiceImpl extends BaseServiceImpl imp long inspectTime = DateUtil.between(taskVo.getStartTime(), taskVo.getEndTime()).toMinutes(); taskVo.setInspectTime(Optional.of(inspectTime).orElse(0L)); } - return taskVo; }).collect(Collectors.toList()); pages.setRecords(list); BladePage bladePage = BladePage.of(pages); - return bladePage;*/ + return bladePage; } private void getQueryWrapper(TaskDTO taskDTO, LambdaQueryWrapper queryWrapper) { 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 ec492c9..dca5b5b 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 @@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; @@ -65,7 +64,6 @@ 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; @@ -87,8 +85,6 @@ public class OperMaintenanceTaskServiceImpl extends BaseServiceImpl> list(OperMaintenanceTaskDTO req) { - List tasks = (List) redisTemplate.opsForValue().get("main_list" + req.getCurrent() + req.getSize()); - Long total = (Long) redisTemplate.opsForValue().get("main_list_total"); - if(ObjectUtil.isEmpty(tasks) || ObjectUtil.isEmpty(total)){ - Query query=new Query(); - query.setSize(req.getSize()); - query.setCurrent(req.getCurrent()); - Wrapper queryWrapper = getQueryWrapper(req); - IPage pages = super.page(Condition.getPage(query), queryWrapper); - List list = OperMaintenanceTaskWrapper.build().listVO(pages.getRecords()); - pages.setRecords(list); - redisTemplate.opsForValue().set("main_list" + req.getCurrent() + req.getSize() , list); - redisTemplate.expire("main_list" + req.getCurrent() + req.getSize(),30, TimeUnit.SECONDS); - redisTemplate.opsForValue().set("main_list_total" , pages.getTotal()); - redisTemplate.expire("main_list_total",30, TimeUnit.SECONDS); - return R.data(pages); - } Query query=new Query(); query.setSize(req.getSize()); query.setCurrent(req.getCurrent()); - IPage pages = Condition.getPage(query); - pages.setTotal(total); - pages.setRecords(tasks); + Wrapper queryWrapper = getQueryWrapper(req); + IPage pages = super.page(Condition.getPage(query), queryWrapper); + pages.setRecords(OperMaintenanceTaskWrapper.build().listVO(pages.getRecords())); return R.data(pages); }