|
|
|
@ -1,8 +1,10 @@
|
|
|
|
|
package com.supervision.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.supervision.model.AskTemplateQuestionLibrary;
|
|
|
|
@ -24,39 +26,43 @@ import java.util.function.Function;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author flevance
|
|
|
|
|
* @description 针对表【vp_diagnosis_qa_record(诊断问答记录表)】的数据库操作Service实现
|
|
|
|
|
* @createDate 2023-10-20 17:19:21
|
|
|
|
|
*/
|
|
|
|
|
* @author flevance
|
|
|
|
|
* @description 针对表【vp_diagnosis_qa_record(诊断问答记录表)】的数据库操作Service实现
|
|
|
|
|
* @createDate 2023-10-20 17:19:21
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
public class DiagnosisQaRecordServiceImpl extends ServiceImpl<DiagnosisQaRecordMapper, DiagnosisQaRecord>
|
|
|
|
|
implements DiagnosisQaRecordService{
|
|
|
|
|
implements DiagnosisQaRecordService {
|
|
|
|
|
|
|
|
|
|
private final CommonDicService commonDicService;
|
|
|
|
|
|
|
|
|
|
private final AskTemplateQuestionLibraryService askTemplateQuestionLibraryService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<DiagnosisQaRecordHistoryResVO> queryByProcessId(String processId,Integer pageNum,Integer pageSize) {
|
|
|
|
|
public IPage<DiagnosisQaRecordHistoryResVO> queryByProcessId(String processId, Integer pageNum, Integer pageSize) {
|
|
|
|
|
Page<DiagnosisQaRecord> page = this.lambdaQuery().eq(DiagnosisQaRecord::getProcessId, processId).page(new Page<>(pageNum, pageSize));
|
|
|
|
|
List<DiagnosisQaRecordHistoryResVO> resVOS = BeanUtil.copyToList(page.getRecords(), DiagnosisQaRecordHistoryResVO.class);
|
|
|
|
|
// 根据questionLibraryId找到对应的字典
|
|
|
|
|
Set<String> questionIdList = page.getRecords().stream().map(DiagnosisQaRecord::getQuestionLibraryId).filter(StrUtil::isNotBlank).collect(Collectors.toSet());
|
|
|
|
|
List<AskTemplateQuestionLibrary> askTemplateQuestionLibraryList = askTemplateQuestionLibraryService.listByIds(questionIdList);
|
|
|
|
|
Map<String, Long> questionLibraryMap = askTemplateQuestionLibraryList.stream().collect(Collectors.toMap(AskTemplateQuestionLibrary::getId, AskTemplateQuestionLibrary::getDictId));
|
|
|
|
|
List<CommonDic> commonDicList = commonDicService.lambdaQuery().eq(CommonDic::getGroupCode, "AQT").list();
|
|
|
|
|
Map<Long, CommonDic> dicMap = commonDicList.stream().collect(Collectors.toMap(CommonDic::getId, Function.identity()));
|
|
|
|
|
List<DiagnosisQaRecordHistoryResVO> resVOS = BeanUtil.copyToList(page.getRecords(), DiagnosisQaRecordHistoryResVO.class);
|
|
|
|
|
for (DiagnosisQaRecordHistoryResVO resVO : resVOS) {
|
|
|
|
|
Long dictId = questionLibraryMap.get(resVO.getQuestionLibraryId());
|
|
|
|
|
if (ObjectUtil.isNotEmpty(dictId)){
|
|
|
|
|
CommonDic commonDic = dicMap.get(dictId);
|
|
|
|
|
resVO.setCommonDic(commonDic);
|
|
|
|
|
if (CollUtil.isNotEmpty(questionIdList)){
|
|
|
|
|
List<AskTemplateQuestionLibrary> askTemplateQuestionLibraryList = askTemplateQuestionLibraryService.listByIds(questionIdList);
|
|
|
|
|
Map<String, Long> questionLibraryMap = askTemplateQuestionLibraryList.stream().collect(Collectors.toMap(AskTemplateQuestionLibrary::getId, AskTemplateQuestionLibrary::getDictId));
|
|
|
|
|
List<CommonDic> commonDicList = commonDicService.lambdaQuery().eq(CommonDic::getGroupCode, "AQT").list();
|
|
|
|
|
Map<Long, CommonDic> dicMap = commonDicList.stream().collect(Collectors.toMap(CommonDic::getId, Function.identity()));
|
|
|
|
|
|
|
|
|
|
for (DiagnosisQaRecordHistoryResVO resVO : resVOS) {
|
|
|
|
|
Long dictId = questionLibraryMap.get(resVO.getQuestionLibraryId());
|
|
|
|
|
if (ObjectUtil.isNotEmpty(dictId)) {
|
|
|
|
|
CommonDic commonDic = dicMap.get(dictId);
|
|
|
|
|
resVO.setCommonDic(commonDic);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 分页转换
|
|
|
|
|
Page<DiagnosisQaRecordHistoryResVO> resultPage = new Page<>(page.getPages(), page.getSize(), page.getTotal());
|
|
|
|
|
IPage<DiagnosisQaRecordHistoryResVO> resultPage = new Page<>(page.getPages(), page.getSize(), page.getTotal());
|
|
|
|
|
resultPage.setRecords(resVOS);
|
|
|
|
|
return resVOS;
|
|
|
|
|
return resultPage;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|