package com.ycl.service.caseHandler.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ycl.common.constant.StepName; import com.ycl.entity.caseHandler.BaseCase; import com.ycl.entity.caseHandler.DisposeRecord; import com.ycl.entity.caseHandler.WorkflowConfigStep; import com.ycl.exception.ApiException; import com.ycl.mapper.caseHandler.BaseCaseMapper; import com.ycl.mapper.caseHandler.DisposeRecordMapper; import com.ycl.mapper.caseHandler.WorkflowConfigStepMapper; 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.time.LocalDateTime; 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; @Resource WorkflowConfigStepMapper workflowConfigStepMapper; @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()); } @Override public Boolean addRecord(DisposeRecord disposeRecord) { //结束上传处置流程 String stepName = StepName.DISPOSE.getName(); QueryWrapper qureyDispatch = new QueryWrapper<>(); qureyDispatch.eq("name", stepName); WorkflowConfigStep dispatchStep = workflowConfigStepMapper.selectOne(qureyDispatch); UpdateWrapper updateWrapper = new UpdateWrapper<>(); updateWrapper.eq("base_case_id", disposeRecord.getBaseCaseId()).eq("workflow_config_step_id",dispatchStep.getId()); DisposeRecord updateRecord = new DisposeRecord(); updateRecord.setState(1); updateRecord.setEndTime(LocalDateTime.now()); updateRecord.setHandlerId(disposeRecord.getCreateUser()); baseMapper.update(updateRecord, updateWrapper); QueryWrapper stepQurey = new QueryWrapper<>(); stepQurey.eq("name", disposeRecord.getStepName()); WorkflowConfigStep workflowConfigStep = workflowConfigStepMapper.selectOne(stepQurey); if (workflowConfigStep == null) { throw new ApiException("未查询到该流程环节"); } //设置流程环节数据 disposeRecord.setWorkflowConfigStepId(workflowConfigStep.getId()); disposeRecord.setHandlerRoleId(workflowConfigStep.getRoleId()); baseMapper.insert(disposeRecord); return true; } }