Browse Source

#压测代码回滚

zhongwei
yang_shj 10 months ago
parent
commit
80dc0fd36c
  1. 38
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java
  2. 22
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java

38
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java

@ -104,9 +104,6 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
@Autowired
private TaskNoUserDataScopeMapper taskNoUserDataScopeMapper;
@Autowired
private RedisTemplate redisTemplate;
/**
* 正在调用开始任务的id集合
*/
@ -533,42 +530,12 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
@Override
public BladePage<TaskVo> page(TaskDTO taskDTO) {
List<TaskVo> inspects = (List<TaskVo>) 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<TaskVo> pages = Condition.getPage(query);
List<TaskVo> list = this.baseMapper.getAllPageList(pages,taskDTO);
List<TaskVo> 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.setSize(taskDTO.getSize());
query.setCurrent(taskDTO.getCurrent());
IPage<TaskVo> pages = Condition.getPage(query);
List<TaskVo> 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<TaskMapper, TaskEntity> 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<TaskVo> bladePage = BladePage.of(pages);
return bladePage;*/
return bladePage;
}
private void getQueryWrapper(TaskDTO taskDTO, LambdaQueryWrapper<TaskEntity> queryWrapper) {

22
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<OperMaintena
private final IEmInfoClient emInfoClient;
private final ISysClient sysClient;
private final RedisTemplate redisTemplate;
@Override
public R doSave(OperMaintenanceTaskDTO req) {
req.setTaskCode(this.genTaskCode(RandomUtils.nextInt(0, 999)));
@ -105,28 +101,12 @@ public class OperMaintenanceTaskServiceImpl extends BaseServiceImpl<OperMaintena
@Override
public R<IPage<OperMaintenanceTaskVO>> list(OperMaintenanceTaskDTO req) {
List<OperMaintenanceTaskVO> tasks = (List<OperMaintenanceTaskVO>) 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<OperMaintenanceTaskEntity> queryWrapper = getQueryWrapper(req);
IPage pages = super.page(Condition.getPage(query), queryWrapper);
List<OperMaintenanceTaskVO> 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);
pages.setRecords(OperMaintenanceTaskWrapper.build().listVO(pages.getRecords()));
return R.data(pages);
}

Loading…
Cancel
Save