package com.ycl.service.caseHandler.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ycl.entity.caseHandler.BaseCase;
import com.ycl.entity.caseHandler.DisposeRecord;
import com.ycl.mapper.caseHandler.BaseCaseMapper;
import com.ycl.mapper.caseHandler.DisposeRecordMapper;
import com.ycl.service.caseHandler.IDisposeRecordService;
import com.ycl.vo.MyBacklogVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
/**
*
* 处置流程记录 服务实现类
*
*
* @author wl
* @since 2022-09-24
*/
@Service
public class DisposeRecordServiceImpl extends ServiceImpl implements IDisposeRecordService {
@Resource
BaseCaseMapper baseCaseMapper;
@Resource
DisposeRecordMapper disposeRecordMapper;
@Override
public List listMyTask(String num, Long userId) {
return disposeRecordMapper.selectList(
new LambdaQueryWrapper()
.eq(DisposeRecord::getHandlerId, userId.intValue())
.isNull(DisposeRecord::getEndTime))
.stream()
.filter(item -> {
if (StringUtils.isBlank(num)){
return true;
}else {
BaseCase baseCase = baseCaseMapper.selectById(item.getBaseCaseId());
if (baseCase.getCode().contains(num)) {
return true;
} else {
return false;
}
}
})
.map(item -> {
MyBacklogVO myBacklogVO = new MyBacklogVO();
BeanUtils.copyProperties(item, myBacklogVO);
BaseCase baseCase = baseCaseMapper.selectById(item.getBaseCaseId());
myBacklogVO.setCategory(baseCase.getCategory());
myBacklogVO.setEventSource(baseCase.getEventSource());
myBacklogVO.setCode(baseCase.getCode());
return myBacklogVO;
}).collect(Collectors.toList());
}
}