|
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.diagbot.client.UserServiceClient;
|
|
|
import com.diagbot.dto.ConceptCollectionDTO;
|
|
|
+import com.diagbot.dto.ConceptCollectionMatchDTO;
|
|
|
import com.diagbot.dto.DictionaryInfoDTO;
|
|
|
import com.diagbot.dto.RespDTO;
|
|
|
import com.diagbot.entity.KlConcept;
|
|
@@ -27,6 +28,7 @@ import com.diagbot.util.UserUtils;
|
|
|
import com.diagbot.vo.ConceptCollectionBaseVO;
|
|
|
import com.diagbot.vo.ConceptCollectionPageVO;
|
|
|
import com.diagbot.vo.ConceptCollectionSaveVO;
|
|
|
+import com.diagbot.vo.ConceptCollectionVO;
|
|
|
import com.diagbot.vo.IdVO;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -34,7 +36,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -51,7 +55,7 @@ public class KlConceptCollectionFacade {
|
|
|
@Autowired
|
|
|
KlLibraryInfoFacade klLibraryInfoFacade;
|
|
|
@Autowired
|
|
|
- @Qualifier("klRelationServiceImpl")
|
|
|
+ @Qualifier("klRelationServiceImpl")
|
|
|
KlRelationService klRelationService;
|
|
|
@Autowired
|
|
|
KlRelationFacade klRelationFacade;
|
|
@@ -111,6 +115,7 @@ public class KlConceptCollectionFacade {
|
|
|
|
|
|
/**
|
|
|
* 保存(新增和修改)
|
|
|
+ *
|
|
|
* @param conceptCollectionSaveVO
|
|
|
* @return
|
|
|
*/
|
|
@@ -157,12 +162,19 @@ public class KlConceptCollectionFacade {
|
|
|
.collect(Collectors.toList());
|
|
|
List<KlConcept> concepts = klConceptFacade.list(new QueryWrapper<KlConcept>()
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .eq("status", StatusEnum.Enable.getKey())
|
|
|
+ //.eq("status", StatusEnum.Enable.getKey())
|
|
|
.in("id", conceptIds));
|
|
|
|
|
|
if (ListUtil.isEmpty(concepts)) {
|
|
|
- throw new CommonException(CommonErrorCode.NOT_EXISTS, "基础术语不存在或已禁用");
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "保存失败,基础术语不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ for (KlConcept concept : concepts) {
|
|
|
+ if (concept.getStatus().equals(StatusEnum.Disable.getKey())) {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "保存失败,存在已禁用基础术语");
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
List<Long> saveConceptIds = concepts.stream().map(KlConcept::getId).collect(Collectors.toList());
|
|
|
|
|
|
//删除已有记录
|
|
@@ -337,4 +349,56 @@ public class KlConceptCollectionFacade {
|
|
|
klRelationOrderFacade.remove(new QueryWrapper<KlRelationOrder>().in("t_relation_id", relationIds));
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量校验标准术语是否存在
|
|
|
+ *
|
|
|
+ * @param conceptCollectionVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ConceptCollectionMatchDTO collectionMatch(ConceptCollectionVO conceptCollectionVO) {
|
|
|
+ ConceptCollectionMatchDTO retDTO = new ConceptCollectionMatchDTO();
|
|
|
+ List<String> conceptNames = Arrays.stream(conceptCollectionVO.getConceptLibNames().trim().split("\\\n"))
|
|
|
+ .filter(i -> StringUtils.isNotBlank(i))
|
|
|
+ .map(i -> i.trim())
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (ListUtil.isEmpty(conceptNames)) {
|
|
|
+ return retDTO;
|
|
|
+ }
|
|
|
+ List<KlConcept> klConceptList = klConceptFacade.list(new QueryWrapper<KlConcept>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("lib_type", conceptCollectionVO.getConceptLibType())
|
|
|
+ .in("lib_name", conceptNames));
|
|
|
+ Map<String, KlConcept> klConceptMap = new HashMap<>();
|
|
|
+
|
|
|
+ if (ListUtil.isNotEmpty(klConceptList)) {
|
|
|
+ klConceptMap = klConceptList.stream().collect(Collectors.toMap(KlConcept::getLibName, v -> v));
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ConceptCollectionBaseVO> matchList = Lists.newLinkedList();
|
|
|
+ List<ConceptCollectionBaseVO> unMatchList = Lists.newLinkedList();
|
|
|
+ List<ConceptCollectionBaseVO> disableList = Lists.newLinkedList();
|
|
|
+ for (String name : conceptNames) {
|
|
|
+ ConceptCollectionBaseVO baseVO = new ConceptCollectionBaseVO();
|
|
|
+ baseVO.setConceptLibName(name);
|
|
|
+ baseVO.setConceptLibType(conceptCollectionVO.getConceptLibType());
|
|
|
+ if (klConceptMap.containsKey(name)) {
|
|
|
+ KlConcept baseConcept = klConceptMap.get(name);
|
|
|
+ baseVO.setConceptId(baseConcept.getId());
|
|
|
+ if (baseConcept.getStatus().equals(StatusEnum.Enable.getKey())) {
|
|
|
+ matchList.add(baseVO);
|
|
|
+ } else {
|
|
|
+ disableList.add(baseVO);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ unMatchList.add(baseVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ retDTO.setMatchList(matchList);
|
|
|
+ retDTO.setUnMatchList(unMatchList);
|
|
|
+ retDTO.setDisableList(disableList);
|
|
|
+
|
|
|
+ return retDTO;
|
|
|
+ }
|
|
|
}
|