|
|
|
@ -4,9 +4,12 @@ import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.supervision.police.domain.EvidenceCategory;
|
|
|
|
|
import com.supervision.police.domain.NotePrompt;
|
|
|
|
|
import com.supervision.police.dto.EvidenceCategoryDTO;
|
|
|
|
|
import com.supervision.police.service.EvidenceCategoryService;
|
|
|
|
|
import com.supervision.police.mapper.EvidenceCategoryMapper;
|
|
|
|
|
import com.supervision.police.service.NotePromptService;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
@ -21,15 +24,24 @@ import java.util.List;
|
|
|
|
|
public class EvidenceCategoryServiceImpl extends ServiceImpl<EvidenceCategoryMapper, EvidenceCategory>
|
|
|
|
|
implements EvidenceCategoryService{
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private NotePromptService notePromptService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<EvidenceCategoryDTO> listCategoryTree(String caseType) {
|
|
|
|
|
|
|
|
|
|
List<EvidenceCategoryDTO> list = super.getBaseMapper().listCategoryDTO(caseType);
|
|
|
|
|
|
|
|
|
|
List<NotePrompt> notePrompts = notePromptService.list();
|
|
|
|
|
for (EvidenceCategoryDTO categoryDTO : list) {
|
|
|
|
|
List<EvidenceCategoryDTO> child = list.stream()
|
|
|
|
|
.filter(evidenceCategoryDTO -> StrUtil.equals(categoryDTO.getId(), evidenceCategoryDTO.getParentId())).toList();
|
|
|
|
|
if (CollUtil.isNotEmpty(child)){
|
|
|
|
|
//遍历child,过滤notePrompts中evidence_category_id与child中id相等的数据,如果存在,则设置hasPrompt为true
|
|
|
|
|
child.forEach(evidenceCategoryDTO -> {
|
|
|
|
|
List<NotePrompt> notePromptList = notePrompts.stream()
|
|
|
|
|
.filter(notePrompt -> StrUtil.equals(notePrompt.getEvidenceCategoryId(), evidenceCategoryDTO.getId())).toList();
|
|
|
|
|
evidenceCategoryDTO.setHasPrompt(CollUtil.isNotEmpty(notePromptList));
|
|
|
|
|
});
|
|
|
|
|
categoryDTO.setChild(child);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|