Browse Source

静态信息维护

zhoutg 6 năm trước cách đây
mục cha
commit
91a90e9e8a
29 tập tin đã thay đổi với 892 bổ sung377 xóa
  1. 7 0
      config-server/src/main/resources/shared/knowledgeman-service-dev.yml
  2. 7 0
      config-server/src/main/resources/shared/knowledgeman-service-local.yml
  3. 7 0
      config-server/src/main/resources/shared/knowledgeman-service-pro.yml
  4. 7 0
      config-server/src/main/resources/shared/knowledgeman-service-test.yml
  5. 6 1
      knowledgeman-service/pom.xml
  6. 116 0
      knowledgeman-service/src/main/java/com/diagbot/client/fastdfs/FastDFSClient.java
  7. 70 0
      knowledgeman-service/src/main/java/com/diagbot/client/fastdfs/FastDFSFile.java
  8. 49 0
      knowledgeman-service/src/main/java/com/diagbot/config/FastDFSConfigurer.java
  9. 27 0
      knowledgeman-service/src/main/java/com/diagbot/dto/FileDTO.java
  10. 9 60
      knowledgeman-service/src/main/java/com/diagbot/dto/GetLibraryDetailListDTO.java
  11. 71 0
      knowledgeman-service/src/main/java/com/diagbot/dto/LibraryDetailDTO.java
  12. 25 0
      knowledgeman-service/src/main/java/com/diagbot/dto/LibraryIndexDTO.java
  13. 10 127
      knowledgeman-service/src/main/java/com/diagbot/entity/LibraryDetail.java
  14. 54 0
      knowledgeman-service/src/main/java/com/diagbot/enums/PositionTypeEnum.java
  15. 99 89
      knowledgeman-service/src/main/java/com/diagbot/facade/LibraryDetailFacade.java
  16. 13 0
      knowledgeman-service/src/main/java/com/diagbot/facade/UploadFacade.java
  17. 14 0
      knowledgeman-service/src/main/java/com/diagbot/mapper/LibraryDetailMapper.java
  18. 22 2
      knowledgeman-service/src/main/java/com/diagbot/service/LibraryDetailService.java
  19. 13 0
      knowledgeman-service/src/main/java/com/diagbot/service/UploadService.java
  20. 16 2
      knowledgeman-service/src/main/java/com/diagbot/service/impl/LibraryDetailServiceImpl.java
  21. 98 0
      knowledgeman-service/src/main/java/com/diagbot/service/impl/UploadServiceImpl.java
  22. 4 20
      knowledgeman-service/src/main/java/com/diagbot/vo/AddLibraryDetailVO.java
  23. 3 12
      knowledgeman-service/src/main/java/com/diagbot/vo/GetLibraryDetailListVO.java
  24. 5 5
      knowledgeman-service/src/main/java/com/diagbot/vo/GetLibraryDetailVO.java
  25. 21 0
      knowledgeman-service/src/main/java/com/diagbot/vo/LibraryIndexVO.java
  26. 9 6
      knowledgeman-service/src/main/java/com/diagbot/vo/RemoveLibraryDetailVO.java
  27. 32 26
      knowledgeman-service/src/main/java/com/diagbot/web/LibraryDetailController.java
  28. 51 0
      knowledgeman-service/src/main/java/com/diagbot/web/UploadController.java
  29. 27 27
      knowledgeman-service/src/main/resources/mapper/LibraryDetailMapper.xml

+ 7 - 0
config-server/src/main/resources/shared/knowledgeman-service-dev.yml

@@ -101,3 +101,10 @@ mybatis-plus:
     map-underscore-to-camel-case: true
     cache-enabled: false
 
+fastdfs:
+  connect_timeout_in_seconds: 60
+  network_timeout_in_seconds: 60
+  charset: UTF-8
+  http_tracker_http_port: 8080
+  http_anti_steal_token: no
+  tracker_servers: 192.168.2.236:22122

+ 7 - 0
config-server/src/main/resources/shared/knowledgeman-service-local.yml

@@ -101,3 +101,10 @@ mybatis-plus:
     map-underscore-to-camel-case: true
     cache-enabled: false
 
+fastdfs:
+  connect_timeout_in_seconds: 60
+  network_timeout_in_seconds: 60
+  charset: UTF-8
+  http_tracker_http_port: 8080
+  http_anti_steal_token: no
+  tracker_servers: 192.168.2.236:22122

+ 7 - 0
config-server/src/main/resources/shared/knowledgeman-service-pro.yml

@@ -101,3 +101,10 @@ mybatis-plus:
     map-underscore-to-camel-case: true
     cache-enabled: false
 
+fastdfs:
+  connect_timeout_in_seconds: 60
+  network_timeout_in_seconds: 60
+  charset: UTF-8
+  http_tracker_http_port: 8080
+  http_anti_steal_token: no
+  tracker_servers: 192.168.2.236:22122

+ 7 - 0
config-server/src/main/resources/shared/knowledgeman-service-test.yml

@@ -101,3 +101,10 @@ mybatis-plus:
     map-underscore-to-camel-case: true
     cache-enabled: false
 
+fastdfs:
+  connect_timeout_in_seconds: 60
+  network_timeout_in_seconds: 60
+  charset: UTF-8
+  http_tracker_http_port: 8080
+  http_anti_steal_token: no
+  tracker_servers: 192.168.2.241:22122

+ 6 - 1
knowledgeman-service/pom.xml

@@ -163,7 +163,12 @@
             <artifactId>jxl</artifactId>
             <version>2.6.10</version>
         </dependency>
-        
+
+        <dependency>
+            <groupId>net.oschina.zcx7878</groupId>
+            <artifactId>fastdfs-client-java</artifactId>
+            <version>1.27.0.0</version>
+        </dependency>
         <!-- 文件上传相关架包 -->
 		<dependency>
 			<groupId>commons-fileupload</groupId>

+ 116 - 0
knowledgeman-service/src/main/java/com/diagbot/client/fastdfs/FastDFSClient.java

@@ -0,0 +1,116 @@
+package com.diagbot.client.fastdfs;
+
+import org.csource.common.NameValuePair;
+import org.csource.fastdfs.ClientGlobal;
+import org.csource.fastdfs.FileInfo;
+import org.csource.fastdfs.ServerInfo;
+import org.csource.fastdfs.StorageClient;
+import org.csource.fastdfs.StorageServer;
+import org.csource.fastdfs.TrackerClient;
+import org.csource.fastdfs.TrackerServer;
+import org.slf4j.LoggerFactory;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * @Description: FastDFS 客户端
+ * @author: gaodm
+ * @time: 2018/11/13 13:55
+ */
+public class FastDFSClient {
+    private static org.slf4j.Logger logger = LoggerFactory.getLogger(FastDFSClient.class);
+
+    public static String[] upload(FastDFSFile file) {
+        logger.info("File Name: " + file.getName() + "File Length:" + file.getContent().length);
+
+        NameValuePair[] meta_list = new NameValuePair[1];
+        meta_list[0] = new NameValuePair("author", file.getAuthor());
+
+        long startTime = System.currentTimeMillis();
+        String[] uploadResults = null;
+        StorageClient storageClient = null;
+        try {
+            storageClient = getTrackerClient();
+            uploadResults = storageClient.upload_file(file.getContent(), file.getExt(), meta_list);
+        } catch (IOException e) {
+            logger.error("IO Exception when uploadind the file:" + file.getName(), e);
+        } catch (Exception e) {
+            logger.error("Non IO Exception when uploadind the file:" + file.getName(), e);
+        }
+        logger.info("upload_file time used:" + (System.currentTimeMillis() - startTime) + " ms");
+
+        if (uploadResults == null && storageClient != null) {
+            logger.error("upload file fail, error code:" + storageClient.getErrorCode());
+        }
+        String groupName = uploadResults[0];
+        String remoteFileName = uploadResults[1];
+
+        logger.info("upload file successfully!!!" + "group_name:" + groupName + ", remoteFileName:" + " " + remoteFileName);
+        return uploadResults;
+    }
+
+    public static FileInfo getFile(String groupName, String remoteFileName) {
+        try {
+            StorageClient storageClient = getTrackerClient();
+            return storageClient.get_file_info(groupName, remoteFileName);
+        } catch (IOException e) {
+            logger.error("IO Exception: Get File from Fast DFS failed", e);
+        } catch (Exception e) {
+            logger.error("Non IO Exception: Get File from Fast DFS failed", e);
+        }
+        return null;
+    }
+
+    public static InputStream downFile(String groupName, String remoteFileName) {
+        try {
+            StorageClient storageClient = getTrackerClient();
+            byte[] fileByte = storageClient.download_file(groupName, remoteFileName);
+            InputStream ins = new ByteArrayInputStream(fileByte);
+            return ins;
+        } catch (IOException e) {
+            logger.error("IO Exception: Get File from Fast DFS failed", e);
+        } catch (Exception e) {
+            logger.error("Non IO Exception: Get File from Fast DFS failed", e);
+        }
+        return null;
+    }
+
+    public static void deleteFile(String groupName, String remoteFileName)
+            throws Exception {
+        StorageClient storageClient = getTrackerClient();
+        int i = storageClient.delete_file(groupName, remoteFileName);
+        logger.info("delete file successfully!!!" + i);
+    }
+
+    public static StorageServer[] getStoreStorages(String groupName)
+            throws IOException {
+        TrackerClient trackerClient = new TrackerClient();
+        TrackerServer trackerServer = trackerClient.getConnection();
+        return trackerClient.getStoreStorages(trackerServer, groupName);
+    }
+
+    public static ServerInfo[] getFetchStorages(String groupName,
+                                                String remoteFileName) throws IOException {
+        TrackerClient trackerClient = new TrackerClient();
+        TrackerServer trackerServer = trackerClient.getConnection();
+        return trackerClient.getFetchStorages(trackerServer, groupName, remoteFileName);
+    }
+
+    public static String getTrackerUrl() throws IOException {
+        return "http://" + getTrackerServer().getInetSocketAddress().getHostString() + ":" + ClientGlobal.getG_tracker_http_port() + "/";
+    }
+
+    private static StorageClient getTrackerClient() throws IOException {
+        TrackerServer trackerServer = getTrackerServer();
+        StorageClient storageClient = new StorageClient(trackerServer, null);
+        return storageClient;
+    }
+
+    private static TrackerServer getTrackerServer() throws IOException {
+        TrackerClient trackerClient = new TrackerClient();
+        TrackerServer trackerServer = trackerClient.getConnection();
+        return trackerServer;
+    }
+}

+ 70 - 0
knowledgeman-service/src/main/java/com/diagbot/client/fastdfs/FastDFSFile.java

@@ -0,0 +1,70 @@
+package com.diagbot.client.fastdfs;
+
+public class FastDFSFile {
+    private String name;
+
+    private byte[] content;
+
+    private String ext;
+
+    private String md5;
+
+    private String author;
+
+    public FastDFSFile(String name, byte[] content, String ext, String height,
+                       String width, String author) {
+        super();
+        this.name = name;
+        this.content = content;
+        this.ext = ext;
+        this.author = author;
+    }
+
+    public FastDFSFile(String name, byte[] content, String ext) {
+        super();
+        this.name = name;
+        this.content = content;
+        this.ext = ext;
+
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public byte[] getContent() {
+        return content;
+    }
+
+    public void setContent(byte[] content) {
+        this.content = content;
+    }
+
+    public String getExt() {
+        return ext;
+    }
+
+    public void setExt(String ext) {
+        this.ext = ext;
+    }
+
+    public String getMd5() {
+        return md5;
+    }
+
+    public void setMd5(String md5) {
+        this.md5 = md5;
+    }
+
+    public String getAuthor() {
+        return author;
+    }
+
+    public void setAuthor(String author) {
+        this.author = author;
+    }
+}

+ 49 - 0
knowledgeman-service/src/main/java/com/diagbot/config/FastDFSConfigurer.java

@@ -0,0 +1,49 @@
+package com.diagbot.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.csource.fastdfs.ClientGlobal;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.Properties;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2019/3/1 14:15
+ */
+@Configuration
+@Slf4j
+public class FastDFSConfigurer {
+    @Value("${fastdfs.connect_timeout_in_seconds}")
+    private String connectTimeout;
+    @Value("${fastdfs.network_timeout_in_seconds}")
+    private String networkTimeout;
+    @Value("${fastdfs.charset}")
+    private String charset;
+    @Value("${fastdfs.http_tracker_http_port}")
+    private String httpTrackerHttpPort;
+    @Value("${fastdfs.http_anti_steal_token}")
+    private String httpAntiStealToken;
+    @Value("${fastdfs.tracker_servers}")
+    private String trackerServers;
+
+    @Bean
+    public Integer fastDFSInit(){
+        try {
+            Properties props = new Properties();
+            props.put(ClientGlobal.PROP_KEY_CONNECT_TIMEOUT_IN_SECONDS, connectTimeout);
+            props.put(ClientGlobal.PROP_KEY_NETWORK_TIMEOUT_IN_SECONDS, networkTimeout);
+            props.put(ClientGlobal.PROP_KEY_CHARSET, charset);
+            props.put(ClientGlobal.PROP_KEY_HTTP_TRACKER_HTTP_PORT, httpTrackerHttpPort);
+            props.put(ClientGlobal.PROP_KEY_HTTP_ANTI_STEAL_TOKEN, httpAntiStealToken);
+            props.put(ClientGlobal.PROP_KEY_TRACKER_SERVERS, trackerServers);
+            ClientGlobal.initByProperties(props);
+
+        } catch (Exception e) {
+            log.error("FastDFS Client Init Fail!", e);
+        }
+        return 1;
+    }
+}

+ 27 - 0
knowledgeman-service/src/main/java/com/diagbot/dto/FileDTO.java

@@ -0,0 +1,27 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2018/12/18 17:08
+ */
+@Getter
+@Setter
+public class FileDTO {
+    private String state;
+    private String original;
+    private String title;
+    private String url;
+    private String info;
+
+    public FileDTO(String state, String info) {
+        this.state = state;
+        this.info = info;
+    }
+    public FileDTO(){
+
+    }
+}

+ 9 - 60
knowledgeman-service/src/main/java/com/diagbot/dto/GetLibraryDetailListDTO.java

@@ -1,13 +1,12 @@
 package com.diagbot.dto;
 
-import java.util.Date;
-
 import com.fasterxml.jackson.annotation.JsonFormat;
-
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.util.Date;
+
 /**
  * @Description
  * @author rgb
@@ -16,12 +15,6 @@ import lombok.Setter;
 @Getter
 @Setter
 public class GetLibraryDetailListDTO {
-	
-	/**
-     * id
-     */
-	@ApiModelProperty(value="id")
-    private Long id;
 
     /**
      * 操作时间
@@ -41,66 +34,22 @@ public class GetLibraryDetailListDTO {
      */
     @ApiModelProperty(value="概念id")
     private Long conceptId;
-    
-    /**
-     * 概念名称
-     */
-    @ApiModelProperty(value="概念名称")
-    private String conceptName;
-    
-    /**
-     * 概念类型
-     */
-    @ApiModelProperty(value="概念类型")
-    private String conceptType;
-    
-    /**
-     * 概念名称(概念类型)
-     */
-    @ApiModelProperty(value="概念名称(概念类型)")
-    private String conceptNameAndType;
 
     /**
-     * 静态知识来源
+     * 标题
      */
-    @ApiModelProperty(value="静态知识来源")
-    private String source;
-
-    /**
-     * 提示明细标题
-     */
-    @ApiModelProperty(value="提示明细标题")
+    @ApiModelProperty(value="标题")
     private String title;
 
     /**
-     * 提示明细内容
-     */
-    @ApiModelProperty(value="提示明细内容")
-    private String content;
-
-    /**
-     * 纯文本
-     */
-    @ApiModelProperty(value="纯文本")
-    private String text;
-
-    /**
-     * 提示明细序号
+     * 概念名称
      */
-    @ApiModelProperty(value="提示明细序号")
-    private Integer orderNo;
+    @ApiModelProperty(value="概念名称")
+    private String libName;
 
-    /**
-     * 显示位置(多选):1-推送展示,2-更多展示,3-一般治疗展示,4-手术治疗展示,5-药品说明书
-     */
-    @ApiModelProperty(value="显示位置(多选):1-推送展示,2-更多展示,3-一般治疗展示,4-手术治疗展示,5-药品说明书")
-    private String position;
 
     /**
-     * 是否诊断依据(1-是,0-否)
+     * 是否删除,N:未删除,Y:删除
      */
-    @ApiModelProperty(value="是否诊断依据(1-是,0-否)")
-    private Integer isReason;
-
-    
+    private String isDeleted;
 }

+ 71 - 0
knowledgeman-service/src/main/java/com/diagbot/dto/LibraryDetailDTO.java

@@ -0,0 +1,71 @@
+package com.diagbot.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description
+ * @author rgb
+ * @time 2018年12月5日下午5:00:34
+ */
+@Getter
+@Setter
+public class LibraryDetailDTO {
+	
+	/**
+     * id
+     */
+	@ApiModelProperty(value="id")
+    private Long id;
+
+    /**
+     * 概念id
+     */
+    @ApiModelProperty(value="概念id")
+    private Long conceptId;
+
+    /**
+     * 提示明细标题
+     */
+    @ApiModelProperty(value="提示明细标题")
+    private String title;
+
+    /**
+     * 提示明细内容
+     */
+    @ApiModelProperty(value="提示明细内容")
+    private String content;
+
+    /**
+     * 纯文本
+     */
+    @ApiModelProperty(value="纯文本")
+    private String text;
+
+    /**
+     * 概念名称
+     */
+    @ApiModelProperty(value="概念名称")
+    private String libName;
+
+    /**
+     * 提示明细序号
+     */
+    @ApiModelProperty(value="提示明细序号")
+    private Integer orderNo;
+
+    /**
+     * 显示位置(多选):1-推送展示,2-更多展示,3-一般治疗展示,4-手术治疗展示,5-药品说明书
+     */
+    @ApiModelProperty(value="显示位置(多选):1-推送展示,2-更多展示,3-一般治疗展示,4-手术治疗展示,5-药品说明书")
+    private String position;
+
+    /**
+     * 是否诊断依据(1-是,0-否)
+     */
+    @ApiModelProperty(value="是否诊断依据(1-是,0-否)")
+    private Integer isReason;
+
+    
+}

+ 25 - 0
knowledgeman-service/src/main/java/com/diagbot/dto/LibraryIndexDTO.java

@@ -0,0 +1,25 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @author: zhoutg
+ * @time: 2019/5/6 15:59
+ */
+@Getter
+@Setter
+public class LibraryIndexDTO {
+
+    /**
+     * 名称
+     */
+    private String name;
+
+    /**
+     * 量表概念id
+     */
+    private Long conceptId;
+
+}

+ 10 - 127
knowledgeman-service/src/main/java/com/diagbot/entity/LibraryDetail.java

@@ -1,10 +1,13 @@
 package com.diagbot.entity;
 
-import java.io.Serializable;
-import java.util.Date;
-
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serializable;
+import java.util.Date;
 
 /**
  * <p>
@@ -14,6 +17,9 @@ import com.baomidou.mybatisplus.annotation.TableId;
  * @author gaodm
  * @since 2019-03-26
  */
+@Getter
+@Setter
+@TableName("kl_concept_detail")
 public class LibraryDetail implements Serializable {
 
     private static final long serialVersionUID = 1L;
@@ -32,7 +38,7 @@ public class LibraryDetail implements Serializable {
     /**
      * 记录创建时间
      */
-    private Date gmtCreated;
+    private Date gmtCreate;
 
     /**
      * 记录修改时间,如果时间是1970年则表示纪录未修改
@@ -54,11 +60,6 @@ public class LibraryDetail implements Serializable {
      */
     private Long conceptId;
 
-    /**
-     * 静态知识来源
-     */
-    private String source;
-
     /**
      * 提示明细标题
      */
@@ -89,122 +90,4 @@ public class LibraryDetail implements Serializable {
      */
     private Integer isReason;
 
-    public Long getId() {
-        return id;
-    }
-
-    public void setId(Long id) {
-        this.id = id;
-    }
-    public String getIsDeleted() {
-        return isDeleted;
-    }
-
-    public void setIsDeleted(String isDeleted) {
-        this.isDeleted = isDeleted;
-    }
-    public Date getGmtCreated() {
-        return gmtCreated;
-    }
-
-    public void setGmtCreated(Date gmtCreated) {
-        this.gmtCreated = gmtCreated;
-    }
-    public Date getGmtModified() {
-        return gmtModified;
-    }
-
-    public void setGmtModified(Date gmtModified) {
-        this.gmtModified = gmtModified;
-    }
-    public String getCreator() {
-        return creator;
-    }
-
-    public void setCreator(String creator) {
-        this.creator = creator;
-    }
-    public String getModifier() {
-        return modifier;
-    }
-
-    public void setModifier(String modifier) {
-        this.modifier = modifier;
-    }
-    public Long getConceptId() {
-        return conceptId;
-    }
-
-    public void setConceptId(Long conceptId) {
-        this.conceptId = conceptId;
-    }
-    public String getSource() {
-        return source;
-    }
-
-    public void setSource(String source) {
-        this.source = source;
-    }
-    public String getTitle() {
-        return title;
-    }
-
-    public void setTitle(String title) {
-        this.title = title;
-    }
-    public String getContent() {
-        return content;
-    }
-
-    public void setContent(String content) {
-        this.content = content;
-    }
-    public String getText() {
-        return text;
-    }
-
-    public void setText(String text) {
-        this.text = text;
-    }
-    public Integer getOrderNo() {
-        return orderNo;
-    }
-
-    public void setOrderNo(Integer orderNo) {
-        this.orderNo = orderNo;
-    }
-    public String getPosition() {
-        return position;
-    }
-
-    public void setPosition(String position) {
-        this.position = position;
-    }
-    public Integer getIsReason() {
-        return isReason;
-    }
-
-    public void setIsReason(Integer isReason) {
-        this.isReason = isReason;
-    }
-
-    @Override
-    public String toString() {
-        return "LibraryDetail{" +
-        "id=" + id +
-        ", isDeleted=" + isDeleted +
-        ", gmtCreated=" + gmtCreated +
-        ", gmtModified=" + gmtModified +
-        ", creator=" + creator +
-        ", modifier=" + modifier +
-        ", conceptId=" + conceptId +
-        ", source=" + source +
-        ", title=" + title +
-        ", content=" + content +
-        ", text=" + text +
-        ", orderNo=" + orderNo +
-        ", position=" + position +
-        ", isReason=" + isReason +
-        "}";
-    }
 }

+ 54 - 0
knowledgeman-service/src/main/java/com/diagbot/enums/PositionTypeEnum.java

@@ -0,0 +1,54 @@
+package com.diagbot.enums;
+
+import com.diagbot.core.KeyedNamed;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2019/5/7 14:06
+ */
+public enum PositionTypeEnum implements KeyedNamed {
+    T1(1, "推送展示"),
+    T2(2, "更多展示"),
+    T3(3, "一般治疗展示"),
+    T4(4, "手术治疗展示"),
+    T5(5, "药品说明书"),
+    T6(6, "不良反应"),
+    T7(7, "描述信息");
+
+    @Setter
+    private Integer key;
+
+    @Setter
+    private String name;
+
+    PositionTypeEnum(Integer key, String name) {
+        this.key = key;
+        this.name = name;
+    }
+
+    public static PositionTypeEnum getEnum(Integer key) {
+        for (PositionTypeEnum item : PositionTypeEnum.values()) {
+            if (item.key == key) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public static String getName(Integer key) {
+        PositionTypeEnum item = getEnum(key);
+        return item != null ? item.name : null;
+    }
+
+    @Override
+    public int getKey() {
+        return key;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+}

+ 99 - 89
knowledgeman-service/src/main/java/com/diagbot/facade/LibraryDetailFacade.java

@@ -1,32 +1,36 @@
 package com.diagbot.facade;
 
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.client.UserServiceClient;
-import com.diagbot.dto.GetLibraryDetailDTO;
 import com.diagbot.dto.GetLibraryDetailListDTO;
+import com.diagbot.dto.LibraryDetailDTO;
+import com.diagbot.dto.LibraryIndexDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.entity.LibraryDetail;
-import com.diagbot.entity.LibraryInfo;
-import com.diagbot.enums.LexiconTypeEnum;
+import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
+import com.diagbot.service.LibraryDetailService;
 import com.diagbot.service.impl.LibraryDetailServiceImpl;
-import com.diagbot.util.BeanUtil;
 import com.diagbot.util.DateUtil;
+import com.diagbot.util.ListUtil;
 import com.diagbot.util.UserUtils;
 import com.diagbot.vo.AddLibraryDetailVO;
 import com.diagbot.vo.GetLibraryDetailListVO;
 import com.diagbot.vo.GetLibraryDetailVO;
+import com.diagbot.vo.LibraryIndexVO;
 import com.diagbot.vo.RemoveLibraryDetailVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @Description: 术语基本信息查询业务层
@@ -36,112 +40,118 @@ import com.diagbot.vo.RemoveLibraryDetailVO;
 @Component
 public class LibraryDetailFacade extends LibraryDetailServiceImpl {
 
-    @Autowired
-    private LibraryInfoFacade libraryInfoFacade;
     @Autowired
     private UserServiceClient userServiceClient;
-    
+    @Autowired
+    @Qualifier("libraryDetailServiceImpl")
+    private LibraryDetailService libraryDetailService;
+
     /**
      * 获取医学术语命名列表
-     * @param getMedicalInfoListVO
+     *
+     * @param getLibraryDetailListVO
      * @return
      */
     public IPage<GetLibraryDetailListDTO> getLibraryDetailList(GetLibraryDetailListVO getLibraryDetailListVO) {
-    	IPage<GetLibraryDetailListDTO> ipage = this.baseMapper.getLibraryDetailList(getLibraryDetailListVO);
-    	List<String> ids = ipage.getRecords().stream().map(i->i.getModifier()).distinct().collect(Collectors.toList());
-    	if(ids.size()>0){
-    		RespDTO<Map<String, String>> respDTO = userServiceClient.getUserInfoByIds(ids);
-        	if (respDTO == null || !CommonErrorCode.OK.getCode().equals(respDTO.code)) {
+        IPage<GetLibraryDetailListDTO> ipage = this.baseMapper.getLibraryDetailList(getLibraryDetailListVO);
+        List<String> ids = ipage.getRecords().stream().map(i -> i.getModifier()).distinct().collect(Collectors.toList());
+        if (ids.size() > 0) {
+            RespDTO<Map<String, String>> respDTO = userServiceClient.getUserInfoByIds(ids);
+            if (respDTO == null || !CommonErrorCode.OK.getCode().equals(respDTO.code)) {
                 throw new CommonException(CommonErrorCode.RPC_ERROR,
                         "获取用户信息失败");
             }
-        	ipage.getRecords().forEach(i->{
-        		i.setModifier(respDTO.data.get(i.getModifier()));
-        	});	
-    	}
+            ipage.getRecords().forEach(i -> {
+                i.setModifier(respDTO.data.get(i.getModifier()));
+            });
+        }
         return ipage;
     }
-    
+
     /**
      * 医学术语静态知识删除
+     *
      * @param removeLibraryDetailVO
      * @return
      */
     public Boolean removeLibraryDetail(RemoveLibraryDetailVO removeLibraryDetailVO) {
-    	LibraryDetail libraryDetail = this.getById(removeLibraryDetailVO.getId());
-    	if(libraryDetail==null||libraryDetail.getIsDeleted().equals("Y")){
-    		throw new CommonException(CommonErrorCode.NOT_EXISTS);
-    	}
-    	
-    	libraryDetail.setIsDeleted("Y");
-    	libraryDetail.setModifier(UserUtils.getCurrentPrincipleID());
-    	libraryDetail.setGmtModified(DateUtil.now());
-        return updateById(libraryDetail);
+        if (!(IsDeleteEnum.N.getKey().equals(removeLibraryDetailVO.getStatus())
+                || IsDeleteEnum.Y.getKey().equals(removeLibraryDetailVO.getStatus()))) {
+            throw new CommonException(CommonErrorCode.STATUS_IS_ERROR, "状态值错误【Y】或【N】");
+        }
+        String person = UserUtils.getCurrentPrincipleID();
+        List<Long> ids = removeLibraryDetailVO.getConceptId();
+        Date now = DateUtil.now();
+        this.update(new LibraryDetail(), new UpdateWrapper<LibraryDetail>()
+                .in("concept_id", ids)
+                .set("gmt_modified", now)
+                .set("modifier", person)
+                .set("is_deleted", removeLibraryDetailVO.getStatus()));
+        return true;
     }
-    
+
     /**
      * 获取医学术语静态知识详情
+     *
      * @param getLibraryDetailVO
      * @return
      */
-    public GetLibraryDetailDTO getLibraryDetail(GetLibraryDetailVO getLibraryDetailVO){
-    	LibraryDetail libraryDetail = this.getById(getLibraryDetailVO.getId());
-    	if(libraryDetail==null||libraryDetail.getIsDeleted().equals("Y")){
-    		throw new CommonException(CommonErrorCode.NOT_EXISTS);
-    	}
-    	
-    	QueryWrapper<LibraryInfo> libraryInfoQe = new QueryWrapper<>();
-		libraryInfoQe.eq("is_deleted", "N");
-		libraryInfoQe.eq("is_concept", "1");
-		libraryInfoQe.eq("concept_id", libraryDetail.getConceptId());
-		LibraryInfo libraryInfo = libraryInfoFacade.getOne(libraryInfoQe);
-		if(libraryInfo==null){
-			throw new CommonException(CommonErrorCode.RPC_ERROR,"术语医学属性所属概念不存在!");
-		}
-    	
-		GetLibraryDetailDTO getLibraryDetailDTO = new GetLibraryDetailDTO();
-    	BeanUtil.copyProperties(libraryDetail, getLibraryDetailDTO);
-    	getLibraryDetailDTO.setConceptName(libraryInfo.getName());
-    	getLibraryDetailDTO.setConceptType(LexiconTypeEnum.getName(libraryInfo.getTypeId().intValue()));
-    	
-    	return getLibraryDetailDTO;
+    public List<LibraryDetailDTO> getLibraryDetail(GetLibraryDetailVO getLibraryDetailVO) {
+        return this.getByParam(getLibraryDetailVO.getConceptId());
     }
-    
+
     /**
      * 医学术语静态知识添加或者编辑
-     * @param addLibraryDetailVO
+     *
+     * @param libraryDetailVOList
      * @return
      */
-	public Boolean addLibraryDetail(AddLibraryDetailVO addLibraryDetailVO){
-		QueryWrapper<LibraryDetail> libraryDetailQe = new QueryWrapper<>();
-		libraryDetailQe.eq("concept_id", addLibraryDetailVO.getConceptId());
-		libraryDetailQe.eq("source", addLibraryDetailVO.getSource());
-		libraryDetailQe.eq("title", addLibraryDetailVO.getTitle());
-		LibraryDetail libraryDetail = getOne(libraryDetailQe);
-		
-		if(libraryDetail!=null&&libraryDetail.getIsDeleted().equals("N")){
-			if(addLibraryDetailVO.getIsTip()==1){
-				throw new CommonException(CommonErrorCode.RPC_ERROR,"根据(术语、术语来源、标题名称)该静态知识已经建立,确定要覆盖该内容吗?确定,覆盖内容,取消,不覆盖。");
-			}
-		}
-		
+    public Boolean addLibraryDetail(List<AddLibraryDetailVO> libraryDetailVOList) {
+        if (ListUtil.isEmpty(libraryDetailVOList)) {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
+                    "静态知识明细内容不能为空");
+        }
+
+        // 删除原明细信息
+        Long conceptId = libraryDetailVOList.get(0).getConceptId();
+        if (conceptId != null) {
+            this.remove(new QueryWrapper<LibraryDetail>()
+                    .eq("concept_id", conceptId));
+        }
+
+        //  新增明细信息
 		String currentUser = UserUtils.getCurrentPrincipleID();
-		Date now = DateUtil.now();
-		
-		if(libraryDetail==null){
-			libraryDetail = new LibraryDetail();
-			libraryDetail.setGmtCreated(now);
-			libraryDetail.setCreator(currentUser);
-		}else{
-			libraryDetail.setIsDeleted("N");
-		}
-		
-		libraryDetail.setGmtModified(now);
-		libraryDetail.setModifier(currentUser);
-		BeanUtil.copyProperties(addLibraryDetailVO, libraryDetail);
-		
-		return saveOrUpdate(libraryDetail);
+        Date now = DateUtil.now();
+        List<LibraryDetail> list = new ArrayList<>();
+        for (AddLibraryDetailVO detailVO : libraryDetailVOList) {
+            LibraryDetail bean = new LibraryDetail();
+            bean.setConceptId(detailVO.getConceptId());
+            bean.setGmtModified(now);
+            bean.setGmtCreate(now);
+            bean.setIsDeleted(IsDeleteEnum.N.getKey());
+            bean.setModifier(currentUser);
+            bean.setCreator(currentUser);
+            bean.setContent(detailVO.getContent());
+            bean.setIsReason(detailVO.getIsReason());
+            bean.setOrderNo(detailVO.getOrderNo());
+            bean.setPosition(detailVO.getPosition());
+            bean.setText(detailVO.getText());
+            bean.setTitle(detailVO.getTitle());
+            list.add(bean);
+        }
+        libraryDetailService.saveBatch(list);
+        return true;
     }
-    
-    
+
+
+    /**
+     * 检索
+     *
+     * @param libraryIndexVO
+     * @return
+     */
+    public List<LibraryIndexDTO> indexFac(LibraryIndexVO libraryIndexVO) {
+        return this.index(libraryIndexVO);
+    }
+
 }

+ 13 - 0
knowledgeman-service/src/main/java/com/diagbot/facade/UploadFacade.java

@@ -0,0 +1,13 @@
+package com.diagbot.facade;
+
+import com.diagbot.service.impl.UploadServiceImpl;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Description: 文件上传装饰层
+ * @author: gaodm
+ * @time: 2018/11/13 13:19
+ */
+@Component
+public class UploadFacade extends UploadServiceImpl {
+}

+ 14 - 0
knowledgeman-service/src/main/java/com/diagbot/mapper/LibraryDetailMapper.java

@@ -3,8 +3,13 @@ package com.diagbot.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.dto.GetLibraryDetailListDTO;
+import com.diagbot.dto.LibraryDetailDTO;
+import com.diagbot.dto.LibraryIndexDTO;
 import com.diagbot.entity.LibraryDetail;
 import com.diagbot.vo.GetLibraryDetailListVO;
+import com.diagbot.vo.LibraryIndexVO;
+
+import java.util.List;
 
 /**
  * <p>
@@ -18,5 +23,14 @@ public interface LibraryDetailMapper extends BaseMapper<LibraryDetail> {
 
 	IPage<GetLibraryDetailListDTO> getLibraryDetailList(GetLibraryDetailListVO getLibraryDetailListVO);
 
+	public List<LibraryDetailDTO> getByParam(Long conceptId);
+
+	/**
+	 * 检索
+	 *
+	 * @param libraryIndexVO
+	 * @return
+	 */
+	public List<LibraryIndexDTO> index(LibraryIndexVO libraryIndexVO);
    
 }

+ 22 - 2
knowledgeman-service/src/main/java/com/diagbot/service/LibraryDetailService.java

@@ -1,7 +1,12 @@
 package com.diagbot.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.diagbot.dto.LibraryDetailDTO;
+import com.diagbot.dto.LibraryIndexDTO;
 import com.diagbot.entity.LibraryDetail;
+import com.diagbot.vo.LibraryIndexVO;
+
+import java.util.List;
 
 /**
  * <p>
@@ -12,6 +17,21 @@ import com.diagbot.entity.LibraryDetail;
  * @since 2019-01-30
  */
 public interface LibraryDetailService extends IService<LibraryDetail> {
-   
-	
+
+    /**
+     * 返回内容
+     *
+     * @param conceptId
+     * @return
+     */
+    public List<LibraryDetailDTO> getByParam(Long conceptId);
+
+
+    /**
+     * 检索
+     *
+     * @param libraryIndexVO
+     * @return
+     */
+    public List<LibraryIndexDTO> index(LibraryIndexVO libraryIndexVO);
 }

+ 13 - 0
knowledgeman-service/src/main/java/com/diagbot/service/UploadService.java

@@ -0,0 +1,13 @@
+package com.diagbot.service;
+
+import com.diagbot.dto.FileDTO;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * @Description: 文件上传服务接口
+ * @author: gaodm
+ * @time: 2018/11/13 13:50
+ */
+public interface UploadService {
+    FileDTO singleFileUpload(MultipartFile file);
+}

+ 16 - 2
knowledgeman-service/src/main/java/com/diagbot/service/impl/LibraryDetailServiceImpl.java

@@ -1,5 +1,8 @@
 package com.diagbot.service.impl;
 
+import com.diagbot.dto.LibraryDetailDTO;
+import com.diagbot.dto.LibraryIndexDTO;
+import com.diagbot.vo.LibraryIndexVO;
 import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -7,6 +10,8 @@ import com.diagbot.entity.LibraryDetail;
 import com.diagbot.mapper.LibraryDetailMapper;
 import com.diagbot.service.LibraryDetailService;
 
+import java.util.List;
+
 /**
  * <p>
  * 提示信息明细 服务实现类
@@ -17,6 +22,15 @@ import com.diagbot.service.LibraryDetailService;
  */
 @Service
 public class LibraryDetailServiceImpl extends ServiceImpl<LibraryDetailMapper, LibraryDetail> implements LibraryDetailService {
-   
-	
+
+
+    @Override
+    public List<LibraryDetailDTO> getByParam(Long conceptId) {
+        return baseMapper.getByParam(conceptId);
+    }
+
+    @Override
+    public List<LibraryIndexDTO> index(LibraryIndexVO libraryIndexVO) {
+        return baseMapper.index(libraryIndexVO);
+    }
 }

+ 98 - 0
knowledgeman-service/src/main/java/com/diagbot/service/impl/UploadServiceImpl.java

@@ -0,0 +1,98 @@
+package com.diagbot.service.impl;
+
+import com.diagbot.client.fastdfs.FastDFSClient;
+import com.diagbot.client.fastdfs.FastDFSFile;
+import com.diagbot.dto.FileDTO;
+import com.diagbot.service.UploadService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * @Description: 文件上传服务接口实现
+ * @author: gaodm
+ * @time: 2018/11/13 13:50
+ */
+@Slf4j
+@Service
+public class UploadServiceImpl implements UploadService {
+    @Override
+    public FileDTO singleFileUpload(MultipartFile file) {
+        if (file.isEmpty()) {
+            return new FileDTO("FAILURE", "文件不能为空");
+        }
+        //文件大小上限1M
+        if (file.getSize() > 1024 * 1024) {
+            return new FileDTO("FAILURE", "文件上传失败,超出大小限制1MB");
+        }
+        try {
+            FileDTO fileDTO = saveFile(file);
+            return fileDTO;
+        } catch (Exception e) {
+            log.error("文件上传失败", e);
+            return new FileDTO("FAILURE", "文件上传失败,请重新上传");
+        }
+    }
+
+
+    /**
+     * @param multipartFile
+     * @return
+     * @throws IOException
+     */
+    public FileDTO saveFile(MultipartFile multipartFile) throws IOException {
+
+        String[] fileAbsolutePath = {};
+        String fileName = multipartFile.getOriginalFilename();
+        String ext = fileName.substring(fileName.lastIndexOf(".") + 1);
+        byte[] file_buff = null;
+        InputStream inputStream = multipartFile.getInputStream();
+        if (inputStream != null) {
+            int len1 = inputStream.available();
+            file_buff = new byte[len1];
+            inputStream.read(file_buff);
+        }
+        inputStream.close();
+        FastDFSFile file = new FastDFSFile(fileName, file_buff, ext);
+        try {
+            fileAbsolutePath = FastDFSClient.upload(file);  //upload to fastdfs
+        } catch (Exception e) {
+            log.error("文件上传异常", e);
+            return new FileDTO("FAILURE", "文件上传异常");
+        }
+        if (fileAbsolutePath == null) {
+            log.error("文件上传失败,请重新上传");
+            return new FileDTO("FAILURE", "文件上传失败,请重新上传");
+        }
+        String path = "/" + fileAbsolutePath[0] + "/" + fileAbsolutePath[1];
+        FileDTO fileDTO = new FileDTO("SUCCESS", "文件上传成功");
+        fileDTO.setUrl(path);
+        fileDTO.setOriginal(multipartFile.getOriginalFilename());
+        fileDTO.setTitle(multipartFile.getOriginalFilename());
+        return fileDTO;
+    }
+
+    /**
+     * 删除服务端文件
+     *
+     * @param path
+     * @return
+     */
+    public FileDTO deleteRemoteFile(String path) {
+        if (path.startsWith("/")) {
+            path = path.substring(1);
+        }
+        String fileName = path.substring(path.indexOf("/") + 1);
+        String groupName = path.substring(0, path.indexOf("/"));
+        try {
+            FastDFSClient.deleteFile(groupName, fileName);
+        } catch (Exception e) {
+            log.error("", e);
+            return new FileDTO("FAILURE", "文件删除失败");
+        }
+        return new FileDTO("SUCCESS", "文件删除成功");
+    }
+}

+ 4 - 20
knowledgeman-service/src/main/java/com/diagbot/vo/AddLibraryDetailVO.java

@@ -1,13 +1,12 @@
 package com.diagbot.vo;
 
-import javax.validation.constraints.NotBlank;
-import javax.validation.constraints.NotNull;
-
-import org.hibernate.validator.constraints.Range;
-
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
 import lombok.Setter;
+import org.hibernate.validator.constraints.Range;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
 
 /**
  * @Description:
@@ -18,14 +17,6 @@ import lombok.Setter;
 @Setter
 public class AddLibraryDetailVO {
 	
-	/**
-	 * 是否提示
-	 */
-	@NotNull(message="是否提示必填")
-	@ApiModelProperty(value="是否提示,0-否,1-是",required=true)
-	@Range(max=1,min=0,message="是否提示必须是0或者1")
-	private Integer isTip;
-	
 	/**
      * 概念id
      */
@@ -33,13 +24,6 @@ public class AddLibraryDetailVO {
 	@ApiModelProperty(value="概念id",required=true)
     private Long conceptId;
 
-    /**
-     * 静态知识来源
-     */
-	@NotBlank(message="静态知识来源必填")
-	@ApiModelProperty(value="静态知识来源",required=true)
-    private String source;
-
     /**
      * 提示明细标题
      */

+ 3 - 12
knowledgeman-service/src/main/java/com/diagbot/vo/GetLibraryDetailListVO.java

@@ -22,18 +22,9 @@ public class GetLibraryDetailListVO extends Page {
 	@ApiModelProperty(value="术语名称")
     private String conceptName;
 
-    
-	/**
-     * 术语类型
-     */
-	@ApiModelProperty(value="术语类型")
-    private String conceptType;
-	
-	/**
-     * 标题
-     */
-	@ApiModelProperty(value="标题")
-    private String title;
+
+	@ApiModelProperty(value = "状态值,已删除=Y,启用中=N")
+	private String status;
 	
 
 }

+ 5 - 5
knowledgeman-service/src/main/java/com/diagbot/vo/GetLibraryDetailVO.java

@@ -1,11 +1,11 @@
 package com.diagbot.vo;
 
-import javax.validation.constraints.NotNull;
-
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
 import lombok.Setter;
 
+import javax.validation.constraints.NotNull;
+
 /**
  * @Description:
  * @author: Weixuan Huang
@@ -18,8 +18,8 @@ public class GetLibraryDetailVO {
     /**
      * 医学术语静态知识id
      */
-	@ApiModelProperty(value="医学术语静态知识id",required=true)
-	@NotNull(message="医学术语静态知识id必传")
-    private Long id;
+	@ApiModelProperty(value="医学术语静态知识概念id",required=true)
+	@NotNull(message="医学术语静态知识概念id必传")
+    private Long conceptId;
     
 }

+ 21 - 0
knowledgeman-service/src/main/java/com/diagbot/vo/LibraryIndexVO.java

@@ -0,0 +1,21 @@
+package com.diagbot.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+ * @description:
+ * @author: ztg
+ * @date: 2019/5/9 11:27
+ */
+@Getter
+@Setter
+public class LibraryIndexVO {
+    @ApiModelProperty(value = "检索名称")
+    @NotBlank(message="名称不能为空")
+    private String name;
+
+}

+ 9 - 6
knowledgeman-service/src/main/java/com/diagbot/vo/RemoveLibraryDetailVO.java

@@ -1,11 +1,13 @@
 package com.diagbot.vo;
 
-import javax.validation.constraints.NotNull;
-
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
 import lombok.Setter;
 
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
 /**
  * @Description:
  * @author: Weixuan Huang
@@ -18,8 +20,9 @@ public class RemoveLibraryDetailVO {
     /**
      * 医学术语静态知识id
      */
-	@ApiModelProperty(value="医学术语静态知识id",required=true)
-	@NotNull(message="医学术语静态知识id必传")
-    private Long id;
-    
+	@ApiModelProperty(value="医学术语静态知识概念id",required=true)
+	@NotNull(message="医学术语静态知识概念id必传")
+    private List<Long> conceptId;
+    @NotBlank(message="状态值不能为空")
+    private String status;
 }

+ 32 - 26
knowledgeman-service/src/main/java/com/diagbot/web/LibraryDetailController.java

@@ -1,27 +1,26 @@
 package com.diagbot.web;
 
-import javax.validation.Valid;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-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;
-
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.annotation.SysLogger;
-import com.diagbot.dto.GetLibraryDetailDTO;
 import com.diagbot.dto.GetLibraryDetailListDTO;
+import com.diagbot.dto.LibraryIndexDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.facade.LibraryDetailFacade;
 import com.diagbot.vo.AddLibraryDetailVO;
 import com.diagbot.vo.GetLibraryDetailListVO;
-import com.diagbot.vo.GetLibraryDetailVO;
+import com.diagbot.vo.LibraryIndexVO;
 import com.diagbot.vo.RemoveLibraryDetailVO;
-
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+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;
+
+import javax.validation.Valid;
+import java.util.List;
 
 /**
  * <p>
@@ -34,20 +33,20 @@ import io.swagger.annotations.ApiOperation;
 @RestController
 @RequestMapping("/libraryDetail")
 @SuppressWarnings("unchecked")
-@Api(value = "医学术语静态知识维护相关API", tags = { "医学术语静态知识维护相关API" })
+@Api(value = "知识库标准化-医学术语静态知识维护相关API", tags = { "知识库标准化-医学术语静态知识维护相关API" })
 public class LibraryDetailController {
 	
     @Autowired
     private LibraryDetailFacade libraryDetailFacade;
     
-    @ApiOperation(value = "获取医学术语静态知识列表[by:rengb]")
+    @ApiOperation(value = "知识库标准化-获取医学术语静态知识列表[by:rengb]")
     @PostMapping("/getLibraryDetailList")
     @SysLogger("getLibraryDetailList")
     public RespDTO<IPage<GetLibraryDetailListDTO>> getLibraryDetailList(@RequestBody GetLibraryDetailListVO getLibraryDetailListVO) {
         return RespDTO.onSuc(libraryDetailFacade.getLibraryDetailList(getLibraryDetailListVO));
     }
     
-    @ApiOperation(value = "医学术语静态知识删除[by:rengb]")
+    @ApiOperation(value = "知识库标准化-医学术语静态知识删除|恢复[by:rengb]")
     @PostMapping("/removeLibraryDetail")
     @SysLogger("removeLibraryDetail")
     @Transactional
@@ -55,20 +54,27 @@ public class LibraryDetailController {
         return RespDTO.onSuc(libraryDetailFacade.removeLibraryDetail(removeLibraryDetailVO));
     }
     
-    @ApiOperation(value = "获取医学术语静态知识详情[by:rengb]")
-    @PostMapping("/getLibraryDetail")
-    @SysLogger("getLibraryDetail")
-    public RespDTO<GetLibraryDetailDTO> getLibraryDetail(@Valid @RequestBody GetLibraryDetailVO getLibraryDetailVO) {
-        return RespDTO.onSuc(libraryDetailFacade.getLibraryDetail(getLibraryDetailVO));
-    }
+//    @ApiOperation(value = "知识库标准化-获取医学术语静态知识详情[by:rengb]")
+//    @PostMapping("/getLibraryDetail")
+//    @SysLogger("getLibraryDetail")
+//    public RespDTO<LibraryDetailDTO> getLibraryDetail(@Valid @RequestBody GetLibraryDetailVO getLibraryDetailVO) {
+//        return RespDTO.onSuc(libraryDetailFacade.getLibraryDetail(getLibraryDetailVO));
+//    }
     
-    @ApiOperation(value = "医学术语静态知识添加或者编辑[by:rengb]")
+    @ApiOperation(value = "知识库标准化-医学术语静态知识添加或者编辑[by:rengb]")
     @PostMapping("/addLibraryDetail")
     @SysLogger("addLibraryDetail")
     @Transactional
-    public RespDTO<Boolean> addLibraryDetail(@Valid @RequestBody AddLibraryDetailVO addLibraryDetailVO) {
-        return RespDTO.onSuc(libraryDetailFacade.addLibraryDetail(addLibraryDetailVO));
+    public RespDTO<Boolean> addLibraryDetail(@Valid @RequestBody List<AddLibraryDetailVO> libraryDetailVOList) {
+        return RespDTO.onSuc(libraryDetailFacade.addLibraryDetail(libraryDetailVOList));
+    }
+
+
+    @ApiOperation(value = "知识库标准化-内容检索[by:zhoutg]", notes = "")
+    @PostMapping("/index")
+    @SysLogger("index")
+    public RespDTO<List<LibraryIndexDTO>> index(@Valid @RequestBody LibraryIndexVO libraryIndexVO) {
+        List<LibraryIndexDTO> data = libraryDetailFacade.indexFac(libraryIndexVO);
+        return RespDTO.onSuc(data);
     }
-    
-    
 }

+ 51 - 0
knowledgeman-service/src/main/java/com/diagbot/web/UploadController.java

@@ -0,0 +1,51 @@
+package com.diagbot.web;
+
+import com.diagbot.dto.FileDTO;
+import com.diagbot.facade.UploadFacade;
+import com.diagbot.util.FastJsonUtils;
+import com.diagbot.util.StringUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@RestController
+@Api(value = "文件上传API", tags = { "知识库标准化-文件上传API" })
+@RequestMapping(value = "/file")
+@SuppressWarnings("unchecked")
+public class UploadController {
+    @Autowired
+    private UploadFacade uploadFacade;
+
+    @ApiOperation(value = "知识库标准化-文件上传")
+    @CrossOrigin(allowCredentials = "true", allowedHeaders = "*", methods = { RequestMethod.POST }, origins = "*")
+    @PostMapping(value = "/uploadImage", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
+    public String singleFileUpload(@RequestParam("upfile") MultipartFile file, HttpServletRequest request, HttpServletResponse response) {
+        FileDTO fileDTO = uploadFacade.singleFileUpload(file);
+        String data = FastJsonUtils.getBeanToJson(fileDTO);
+        response.setContentType("text/plain;charset=UTF-8");
+
+        String callback = request.getParameter("callback");//客户端请求参数
+        if (callback != null && StringUtil.isNotBlank(callback)) {
+            data = callback + "(" + data + ")";
+        }
+        return data;
+    }
+
+    @PostMapping("/deleteRemoteFile")
+    @ApiOperation(value = "知识库标准化-文件删除")
+    public String deleteRemoteFile(@RequestParam("path") String path) {
+        String data = FastJsonUtils.getBeanToJson(uploadFacade.deleteRemoteFile(path));
+        return data;
+    }
+}

+ 27 - 27
knowledgeman-service/src/main/resources/mapper/LibraryDetailMapper.xml

@@ -6,12 +6,11 @@
     <resultMap id="BaseResultMap" type="com.diagbot.entity.LibraryDetail">
         <id column="id" property="id" />
         <result column="is_deleted" property="isDeleted" />
-        <result column="gmt_created" property="gmtCreated" />
+        <result column="gmt_create" property="gmtCreate" />
         <result column="gmt_modified" property="gmtModified" />
         <result column="creator" property="creator" />
         <result column="modifier" property="modifier" />
         <result column="concept_id" property="conceptId" />
-        <result column="source" property="source" />
         <result column="title" property="title" />
         <result column="content" property="content" />
         <result column="text" property="text" />
@@ -21,34 +20,35 @@
     </resultMap>
 
    	<select id="getLibraryDetailList" resultType="com.diagbot.dto.GetLibraryDetailListDTO">
-   		SELECT
-		a.id,
-		a.gmt_modified as gmtModified,
-		a.modifier as modifier,
-		b.id as conceptId,
-		c.`name` as conceptName,
-		c.type as conceptType,
-		CONCAT(c.`name`,'(',c.type,')') as conceptNameAndType,
-		a.source,
-		a.title,
-		a.content,
-		a.text,
-		a.order_no as orderNo,
-		a.position,
-		a.is_reason as isReason
-		FROM library_detail a JOIN concept b ON a.concept_id=b.id
-		JOIN library_info c ON b.lib_id=c.id
-		WHERE a.is_deleted='N' AND b.is_deleted='N' AND c.is_deleted='N' AND c.is_concept=1
+   		SELECT b.id concept_id, b.lib_name, group_concat(title) title, a.is_deleted, a.modifier, a.gmt_modified
+		FROM kl_concept_detail a ,kl_concept b
+		WHERE   b.is_deleted='N' and a.concept_id=b.id
 		<if test="conceptName!=null and conceptName!=''">
-			and c.`name` like concat('%',#{conceptName},'%')
+			and b.`lib_name` like concat('%',#{conceptName},'%')
 		</if>
-		<if test="conceptType!=null and conceptType!=''">
-			and c.type=#{conceptType}
+		<if test="status!=null and status!=''">
+			and a.is_deleted = #{status}
 		</if>
-		<if test="title!=null and title!=''">
-			and a.title like concat('%',#{title},'%')
-		</if>
-		order by a.gmt_modified desc
+		group by b.id, b.lib_name
+		ORDER BY a.is_deleted ASC, a.gmt_modified DESC
    	</select>
 
+
+	<select id="getByParam" resultType="com.diagbot.dto.LibraryDetailDTO">
+        SELECT a.*,b.lib_name FROM `kl_concept_detail` a, `kl_concept` b
+        where  a.is_deleted = 'N' and b.is_deleted = 'N' and b.id = a.concept_id
+        and a.concept_id = #{conceptId}
+        ORDER BY a.order_no
+    </select>
+
+
+    <select id="index" resultType="com.diagbot.dto.LibraryIndexDTO">
+        SELECT a.lib_name name, a.id concept_id FROM `kl_concept` a
+        where a.is_deleted = 'N'
+        <if test="name != null and name != ''">
+            and a.lib_name like concat('%',#{name} ,'%' )
+        </if>
+        and not EXISTS(select 1 from kl_concept_detail where a.id = concept_id)
+        order by a.gmt_modified desc
+    </select>
 </mapper>