7 changed files with 59 additions and 48 deletions
@ -0,0 +1,23 @@
|
||||
package com.biutag.supervision.pojo.param; |
||||
|
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author wxc |
||||
* @date 2024/10/16 |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
public class ModelClueTaskQueryParam extends BasePage { |
||||
private List<Integer> modelIds; |
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
private List<Date> distributionTime = new ArrayList<>(); |
||||
private String taskName; |
||||
} |
||||
@ -1,48 +1,35 @@
|
||||
package com.biutag.supervision.service; |
||||
|
||||
import cn.hutool.core.bean.BeanUtil; |
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.biutag.supervision.mapper.ModelClueTaskMapper; |
||||
import com.biutag.supervision.mapper.ModelMapper; |
||||
import com.biutag.supervision.pojo.entity.Model; |
||||
import com.biutag.supervision.pojo.entity.ModelClueTask; |
||||
import com.biutag.supervision.pojo.model.ModelClueTaskModel; |
||||
import com.biutag.supervision.pojo.param.ModelClueQueryParam; |
||||
import com.biutag.supervision.pojo.param.ModelClueTaskQueryParam; |
||||
import lombok.RequiredArgsConstructor; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Objects; |
||||
import java.util.Set; |
||||
import java.util.stream.Collectors; |
||||
|
||||
@RequiredArgsConstructor |
||||
@Service |
||||
public class ModelClueTaskService extends ServiceImpl<ModelClueTaskMapper, ModelClueTask> { |
||||
|
||||
private final ModelMapper modelMapper; |
||||
|
||||
public Page<ModelClueTaskModel> page(ModelClueQueryParam param) { |
||||
LambdaQueryWrapper<ModelClueTask> queryWrapper = new LambdaQueryWrapper<ModelClueTask>() |
||||
.orderByDesc(ModelClueTask::getDistributionTime); |
||||
|
||||
Page<ModelClueTask> page = page(Page.of(param.getCurrent(), param.getSize()), queryWrapper); |
||||
if (page.getRecords().isEmpty()) { |
||||
return new Page<ModelClueTaskModel>().setRecords(new ArrayList<>()).setTotal(0); |
||||
public Page<ModelClueTaskModel> page(ModelClueTaskQueryParam param) { |
||||
if (Objects.nonNull(param.getModelIds()) && param.getModelIds().isEmpty()) { |
||||
return new Page<ModelClueTaskModel>().setTotal(0).setRecords(new ArrayList<>()); |
||||
} |
||||
QueryWrapper<ModelClueTask> queryWrapper = new QueryWrapper<>(); |
||||
queryWrapper.in(Objects.nonNull(param.getModelIds()), "mt.model_id", param.getModelIds()); |
||||
queryWrapper.like(StrUtil.isNotBlank(param.getTaskName()), "mt.task_name", param.getTaskName()); |
||||
if (Objects.nonNull(param.getDistributionTime()) && !param.getDistributionTime().isEmpty()) { |
||||
queryWrapper.between("mt.distribution_time", param.getDistributionTime().get(0), param.getDistributionTime().get(1)); |
||||
} |
||||
Set<Integer> modelIds = page.getRecords().stream().map(ModelClueTask::getModelId).collect(Collectors.toSet()); |
||||
List<Model> models = modelMapper.selectBatchIds(modelIds); |
||||
List<ModelClueTaskModel> list = page.getRecords().stream().map(item -> { |
||||
ModelClueTaskModel taskModel = new ModelClueTaskModel(); |
||||
BeanUtil.copyProperties(item, taskModel); |
||||
String modelName = models.stream().filter(model -> model.getId().equals(item.getModelId())).findFirst().map(Model::getModelName).orElse(""); |
||||
taskModel.setModelName(modelName); |
||||
return taskModel; |
||||
}).toList(); |
||||
return new Page<ModelClueTaskModel>().setRecords(list).setTotal(page.getTotal()); |
||||
Page<ModelClueTaskModel> page = baseMapper.queryPage(Page.of(param.getCurrent(), param.getSize()), queryWrapper); |
||||
return page; |
||||
} |
||||
|
||||
} |
||||
|
||||
Loading…
Reference in new issue