|
@@ -0,0 +1,78 @@
|
|
|
+package com.diagbot.facade;
|
|
|
+
|
|
|
+import com.diagbot.dto.DictionaryInfoDTO;
|
|
|
+import com.diagbot.entity.node.EntityInfo;
|
|
|
+import com.diagbot.repository.EntityInfoRepository;
|
|
|
+import com.diagbot.util.StringUtil;
|
|
|
+import com.diagbot.vo.EntityInfoVO;
|
|
|
+import com.diagbot.vo.EntityPageVO;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.PageRequest;
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description:
|
|
|
+ * @Author:zhaops
|
|
|
+ * @time: 2020/12/14 16:08
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class EntityInfoFacade {
|
|
|
+ @Autowired
|
|
|
+ DictionaryFacade dictionaryFacade;
|
|
|
+ @Autowired
|
|
|
+ EntityInfoRepository entityInfoRepository;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询
|
|
|
+ *
|
|
|
+ * @param entityPageVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Page<EntityInfo> getEntityPage(EntityPageVO entityPageVO) {
|
|
|
+ List<DictionaryInfoDTO> dicTypeLabelType = dictionaryFacade.getListByGroupType(8);
|
|
|
+ List<String> labels = Lists.newArrayList();
|
|
|
+ if (StringUtil.isNotBlank(entityPageVO.getLabelType())) {
|
|
|
+ labels.add(entityPageVO.getLabelType());
|
|
|
+ } else {
|
|
|
+ labels = dicTypeLabelType.stream().map(i -> i.getVal()).distinct().collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ Pageable pageable = PageRequest.of(entityPageVO.getNumber(), entityPageVO.getSize());
|
|
|
+ Page<EntityInfo> page = entityInfoRepository.getEntityPage(labels,
|
|
|
+ entityPageVO.getName(),
|
|
|
+ entityPageVO.getStatus(),
|
|
|
+ entityPageVO.getIs_kl(),
|
|
|
+ pageable);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 唯一键校验
|
|
|
+ *
|
|
|
+ * @param entityInfoVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Boolean isExist(EntityInfoVO entityInfoVO) {
|
|
|
+ Boolean exist = false;
|
|
|
+ Integer count = entityInfoRepository.existNodes(entityInfoVO.getName(), entityInfoVO.getLabelType());
|
|
|
+ if (count > 0) {
|
|
|
+ exist = true;
|
|
|
+ }
|
|
|
+ if (!exist) {
|
|
|
+ if (entityInfoVO.getLabelType().equals("辅助检查名称")) {
|
|
|
+ count = entityInfoRepository.existNodes(entityInfoVO.getName(), "辅助检查子项目名称");
|
|
|
+ } else if (entityInfoVO.getLabelType().equals("辅助检查子项目名称")) {
|
|
|
+ count = entityInfoRepository.existNodes(entityInfoVO.getName(), "辅助检查名称");
|
|
|
+ }
|
|
|
+ if (count > 0) {
|
|
|
+ exist = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return exist;
|
|
|
+ }
|
|
|
+}
|