Explorar o código

标准术语维护

zhaops %!s(int64=4) %!d(string=hai) anos
pai
achega
6e8d9d7fa9

+ 23 - 0
src/main/java/com/diagbot/entity/node/EntityInfo.java

@@ -0,0 +1,23 @@
+package com.diagbot.entity.node;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.neo4j.ogm.annotation.NodeEntity;
+import org.springframework.data.neo4j.annotation.QueryResult;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2020/12/14 10:28
+ */
+@Getter
+@Setter
+@QueryResult
+public class EntityInfo {
+    private Long id;
+    private String name;
+    private String pycode;
+    private Integer status;
+    private Integer is_kl;
+    private String labelType;
+}

+ 78 - 0
src/main/java/com/diagbot/facade/EntityInfoFacade.java

@@ -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;
+    }
+}

+ 67 - 0
src/main/java/com/diagbot/repository/EntityInfoRepository.java

@@ -0,0 +1,67 @@
+package com.diagbot.repository;
+
+import com.diagbot.entity.node.EntityInfo;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.neo4j.annotation.Query;
+import org.springframework.data.neo4j.repository.Neo4jRepository;
+import org.springframework.data.repository.query.Param;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2020/12/14 13:26
+ */
+public interface EntityInfoRepository extends Neo4jRepository<EntityInfo,Long> {
+    @Query(value = "with {labels} as nlabels\n" +
+            "match(n)\n" +
+            "where any(label in labels(n) where label in nlabels)\n" +
+            "and (case when {name} is not null and {name} <> '' " +
+            "then " +
+            "((toLower(n.`name`) CONTAINS toLower($name) OR toLower(n.`拼音编码`) CONTAINS toLower($name))) " +
+            "else 1 = 1 " +
+            "end ) \n" +
+            "and (case when {status} is not null " +
+            "then " +
+            "n.状态 = {status} " +
+            "else 1 = 1 " +
+            "end ) \n" +
+            "and (case when {is_kl} is not null " +
+            "then " +
+            "n.静态知识标识 = {is_kl} " +
+            "else 1 = 1 " +
+            "end ) \n" +
+            "return id(n) as id,n.name,n.拼音编码  as pycode,labels(n)[0] as labelType,n.状态 as status,n.静态知识标识 as is_kl\n" +
+            "order by n.状态 desc, id(n) desc",
+            countQuery = "with {labels} as nlabels\n" +
+                    "match(n)\n" +
+                    "where any(label in labels(n) where label in nlabels)\n" +
+                    "and (case when {name} is not null and {name} <> '' " +
+                    "then " +
+                    "((toLower(n.`name`) CONTAINS toLower($name) OR toLower(n.`拼音编码`) CONTAINS toLower($name))) " +
+                    "else 1 = 1 " +
+                    "end ) \n" +
+                    "and (case when {status} is not null " +
+                    "then " +
+                    "n.状态 = {status} " +
+                    "else 1 = 1 " +
+                    "end ) \n" +
+                    "and (case when {is_kl} is not null " +
+                    "then " +
+                    "n.静态知识标识 = {is_kl} " +
+                    "else 1 = 1 " +
+                    "end ) \n" +
+                    "return count(*)")
+    Page<EntityInfo> getEntityPage(@Param("labels") List<String> labels,
+                                   @Param("name") String name,
+                                   @Param("status") Integer status,
+                                   @Param("is_kl") Integer is_kl,
+                                   Pageable pageable);
+
+    @Query(value = "match(n) where n.name={name} and {label} in labels(n) \n " +
+            "return count(*)")
+    Integer existNodes(@Param("name") String name,
+                                @Param("label") String label);
+}

+ 18 - 0
src/main/java/com/diagbot/vo/EntityInfoVO.java

@@ -0,0 +1,18 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2020/12/14 17:01
+ */
+@Getter
+@Setter
+public class EntityInfoVO {
+    private String name;
+    private String labelType;
+    private Integer status;
+    private Integer is_kl;
+}

+ 16 - 0
src/main/java/com/diagbot/vo/EntityPageVO.java

@@ -0,0 +1,16 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2020/12/14 13:30
+ */
+@Getter
+@Setter
+public class EntityPageVO extends EntityInfoVO{
+    private int number = 0;
+    private int size = 10;
+}

+ 51 - 0
src/main/java/com/diagbot/web/EntityInfoController.java

@@ -0,0 +1,51 @@
+package com.diagbot.web;
+
+import com.diagbot.dto.RespDTO;
+import com.diagbot.entity.node.EntityInfo;
+import com.diagbot.facade.EntityInfoFacade;
+import com.diagbot.vo.EntityInfoVO;
+import com.diagbot.vo.EntityPageVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2020/12/14 16:15
+ */
+@RestController
+@RequestMapping("/entityman")
+@Api(value = "知识图谱标准术语维护相关API", tags = { "知识图谱标准术语维护相关API" })
+@SuppressWarnings("unchecked")
+public class EntityInfoController {
+    @Autowired
+    EntityInfoFacade entityInfoFacade;
+
+    @ApiOperation(value = "分页查询",
+            notes = "number:页码<br>" +
+                    "size:每页条目数<br>" +
+                    "name:术语名称(模糊匹配)<br>" +
+                    "labelType:术语类型-知识图谱标签类型(String)<br>" +
+                    "is_kl:静态知识标志(0-无,1-有)<br>" +
+                    "status:启用禁用标志(0-禁用,1-启用)<br>")
+    @PostMapping("/getEntityPage")
+    public RespDTO<EntityInfo> getEntityPage(@RequestBody EntityPageVO entityPageVO) {
+        Page<EntityInfo> data = entityInfoFacade.getEntityPage(entityPageVO);
+        return RespDTO.onSuc(data);
+    }
+
+    @ApiOperation(value = "唯一键校验",
+            notes = "name:术语名称(模糊匹配)<br>" +
+                    "labelType:术语类型-知识图谱标签类型(String)<br>")
+    @PostMapping("/isExist")
+    public RespDTO<Boolean> isExist(@RequestBody EntityInfoVO entityInfoVO) {
+        Boolean data = entityInfoFacade.isExist(entityInfoVO);
+        return RespDTO.onSuc(data);
+    }
+}

+ 1 - 1
src/main/resources/logback-spring.xml

@@ -204,7 +204,7 @@
     <!-- FrameworkServlet日志-->
     <logger name="org.springframework" level="WARN"/>
 
-    <!--<logger name="org.neo4j.ogm" level="DEBUG" />-->
+    <logger name="org.neo4j.ogm" level="DEBUG" />
 
     <!-- mybatis日志打印-->
     <logger name="org.apache.ibatis" level="DEBUG"/>