Compare commits
2 Commits
8123c60db3
...
a547dab6b4
| Author | SHA1 | Date |
|---|---|---|
|
|
a547dab6b4 | 1 year ago |
|
|
b236456169 | 1 year ago |
14 changed files with 3329 additions and 0 deletions
@ -0,0 +1,22 @@ |
|||
import request from '@/utils/request'; |
|||
import {getToken} from "@/utils/auth"; |
|||
|
|||
|
|||
export function addFile(file, config = {}) { |
|||
const formData = new FormData(); |
|||
formData.append('file', file); |
|||
|
|||
// 合并默认配置与传入的配置
|
|||
const defaultConfig = { |
|||
headers: {'Authorization': 'Bearer ' + getToken()}, |
|||
|
|||
}; |
|||
const finalConfig = {...defaultConfig, ...config}; |
|||
|
|||
return request({ |
|||
url: '/file/addFile', |
|||
method: 'post', |
|||
data: formData, |
|||
...finalConfig |
|||
}); |
|||
} |
|||
@ -0,0 +1,142 @@ |
|||
package com.main.woka.Common.util; |
|||
|
|||
import java.util.Date; |
|||
|
|||
public class KcInfo { |
|||
private Long id; |
|||
private Long type; |
|||
private String name; |
|||
private String twUrl; |
|||
private String spUrl; |
|||
private String dwUrl; |
|||
private String jsInfo; |
|||
private Long parentId; |
|||
private Date createTime; |
|||
private Long createBy; |
|||
private Date updateTime; |
|||
private Long updateBy; |
|||
private Long isGraph; |
|||
private Long level; |
|||
private Long groupId; |
|||
|
|||
public Integer getFileId() {return fileId;} |
|||
|
|||
public void setFileId(Integer fileId) {this.fileId = fileId;} |
|||
|
|||
private Integer fileId; |
|||
|
|||
public Long getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(Long id) {this.id = id;} |
|||
|
|||
public Long getType() {return type;} |
|||
|
|||
public void setType(Long type) {this.type = type;} |
|||
|
|||
public String getName() {return name;} |
|||
|
|||
public void setName(String name) {this.name = name;} |
|||
|
|||
public String getTwUrl() {return twUrl;} |
|||
|
|||
public void setTwUrl(String twUrl) {this.twUrl = twUrl;} |
|||
|
|||
public String getSpUrl() {return spUrl;} |
|||
|
|||
public void setSpUrl(String spUrl) {this.spUrl = spUrl;} |
|||
|
|||
public String getDwUrl() {return dwUrl;} |
|||
|
|||
public void setDwUrl(String dwUrl) {this.dwUrl = dwUrl;} |
|||
|
|||
public String getJsInfo() {return jsInfo;} |
|||
|
|||
public void setJsInfo(String jsInfo) {this.jsInfo = jsInfo; |
|||
} |
|||
public Long getParentId() {return parentId;} |
|||
|
|||
public void setParentId(Long parentId) {this.parentId = parentId;} |
|||
|
|||
public Long getIsGraph() {return isGraph; |
|||
} |
|||
public void setIsGraph(Long isGraph) {this.isGraph = isGraph;} |
|||
|
|||
|
|||
// @Override
|
|||
public Long getCreateBy() {return createBy;} |
|||
|
|||
|
|||
public void setCreateBy(Long createBy) {this.createBy = createBy;} |
|||
|
|||
|
|||
public Long getUpdateBy() { |
|||
return updateBy; |
|||
} |
|||
|
|||
|
|||
public void setUpdateBy(Long updateBy) { |
|||
this.updateBy = updateBy; |
|||
} |
|||
|
|||
|
|||
public Date getCreateTime() { |
|||
return createTime; |
|||
} |
|||
|
|||
|
|||
public void setCreateTime(Date createTime) { |
|||
this.createTime = createTime; |
|||
} |
|||
|
|||
|
|||
public Date getUpdateTime() { |
|||
return updateTime; |
|||
} |
|||
|
|||
|
|||
public void setUpdateTime(Date updateTime) { |
|||
this.updateTime = updateTime; |
|||
} |
|||
|
|||
|
|||
|
|||
public Long getLevel() { |
|||
return level; |
|||
} |
|||
|
|||
public void setLevel(Long level) { |
|||
this.level = level; |
|||
} |
|||
|
|||
public Long getGroupId() { |
|||
return groupId; |
|||
} |
|||
|
|||
public void setGroupId(Long groupId) { |
|||
this.groupId = groupId; |
|||
} |
|||
|
|||
@Override |
|||
public String toString() { |
|||
return "KcInfo{" + |
|||
"id=" + id + |
|||
", type=" + type + |
|||
", name='" + name + '\'' + |
|||
", twUrl='" + twUrl + '\'' + |
|||
", spUrl='" + spUrl + '\'' + |
|||
", dwUrl='" + dwUrl + '\'' + |
|||
", jsInfo='" + jsInfo + '\'' + |
|||
", parentId=" + parentId + |
|||
", createTime=" + createTime + |
|||
", createBy=" + createBy + |
|||
", updateTime=" + updateTime + |
|||
", updateBy=" + updateBy + |
|||
", isGraph=" + isGraph + |
|||
", level=" + level + |
|||
", groupId=" + groupId + |
|||
", fileId=" + fileId + |
|||
'}'; |
|||
} |
|||
} |
|||
@ -0,0 +1,81 @@ |
|||
package com.main.woka.Common.util; |
|||
|
|||
import com.main.woka.Common.core.BaseEntity; |
|||
|
|||
|
|||
public class KcInfoRelation extends BaseEntity { |
|||
|
|||
private Long id; |
|||
private Long sourceId; |
|||
private Long targetId; |
|||
private String relation; |
|||
private String sourceName; |
|||
private String targetName; |
|||
private Long isGraph; |
|||
|
|||
public Long getIsGraph() {return isGraph;} |
|||
|
|||
public void setIsGraph(Long isGraph) {this.isGraph = isGraph;} |
|||
|
|||
public Long getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(Long id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public Long getSourceId() { |
|||
return sourceId; |
|||
} |
|||
|
|||
public void setSourceId(Long sourceId) { |
|||
this.sourceId = sourceId; |
|||
} |
|||
|
|||
public Long getTargetId() { |
|||
return targetId; |
|||
} |
|||
|
|||
public void setTargetId(Long targetId) { |
|||
this.targetId = targetId; |
|||
} |
|||
|
|||
public String getRelation() { |
|||
return relation; |
|||
} |
|||
|
|||
public void setRelation(String relation) { |
|||
this.relation = relation; |
|||
} |
|||
|
|||
public String getSourceName() { |
|||
return sourceName; |
|||
} |
|||
|
|||
public void setSourceName(String sourceName) { |
|||
this.sourceName = sourceName; |
|||
} |
|||
|
|||
public String getTargetName() { |
|||
return targetName; |
|||
} |
|||
|
|||
public void setTargetName(String targetName) { |
|||
this.targetName = targetName; |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public String toString() { |
|||
return "KcInfoRelation{" + |
|||
"id=" + id + |
|||
", sourceId=" + sourceId + |
|||
", targetId=" + targetId + |
|||
", relation='" + relation + '\'' + |
|||
", sourceName='" + sourceName + '\'' + |
|||
", targetName='" + targetName + '\'' + |
|||
", isGraph=" + isGraph + |
|||
'}'; |
|||
} |
|||
} |
|||
@ -0,0 +1,65 @@ |
|||
package com.main.woka.Common.util; |
|||
|
|||
import com.main.woka.Common.annotation.Excel; |
|||
import com.main.woka.Common.core.BaseEntity; |
|||
import org.apache.commons.lang3.builder.ToStringBuilder; |
|||
import org.apache.commons.lang3.builder.ToStringStyle; |
|||
|
|||
/** |
|||
* 参数管理对象 zhy_set_info |
|||
* |
|||
* @author ruoyi |
|||
* @date 2024-11-27 |
|||
*/ |
|||
public class KcSetInfo extends BaseEntity |
|||
{ |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** 主键 */ |
|||
private Integer id; |
|||
|
|||
/** 标识 */ |
|||
@Excel(name = "标识") |
|||
private String name; |
|||
|
|||
/** 内容 */ |
|||
@Excel(name = "内容") |
|||
private String content; |
|||
|
|||
public void setId(Integer id) |
|||
{ |
|||
this.id = id; |
|||
} |
|||
|
|||
public Integer getId() |
|||
{ |
|||
return id; |
|||
} |
|||
public void setName(String name) |
|||
{ |
|||
this.name = name; |
|||
} |
|||
|
|||
public String getName() |
|||
{ |
|||
return name; |
|||
} |
|||
public void setContent(String content) |
|||
{ |
|||
this.content = content; |
|||
} |
|||
|
|||
public String getContent() |
|||
{ |
|||
return content; |
|||
} |
|||
|
|||
@Override |
|||
public String toString() { |
|||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) |
|||
.append("id", getId()) |
|||
.append("name", getName()) |
|||
.append("content", getContent()) |
|||
.toString(); |
|||
} |
|||
} |
|||
@ -0,0 +1,72 @@ |
|||
package com.main.woka.Common.util; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
public class KcTlFile implements Serializable { |
|||
private static final long serialVersionUID = 1L; |
|||
private Long id; |
|||
private String fileUrl; |
|||
private Date createTime; |
|||
private Long createBy; |
|||
private Date updateTime; |
|||
private Long updateBy; |
|||
private String fileName; |
|||
|
|||
public String getFileName() {return fileName; |
|||
} |
|||
public void setFileName(String fileName) {this.fileName = fileName;} |
|||
|
|||
private List<KcInfo> childDoc; |
|||
|
|||
public List<KcInfo> getChildDoc() { |
|||
return childDoc; |
|||
} |
|||
|
|||
public void setChildDoc(List<KcInfo> childDoc) { |
|||
this.childDoc = childDoc; |
|||
} |
|||
|
|||
public Long getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(Long id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
|
|||
public String getFileUrl() { |
|||
return fileUrl; |
|||
} |
|||
|
|||
public void setFileUrl(String fileUrl) { |
|||
this.fileUrl = fileUrl; |
|||
} |
|||
|
|||
public Date getCreateTime() { |
|||
return createTime; |
|||
} |
|||
|
|||
public void setCreateTime(Date createTime) { |
|||
this.createTime = createTime; |
|||
} |
|||
|
|||
public Long getCreateBy() { |
|||
return createBy; |
|||
} |
|||
|
|||
public void setCreateBy(Long createBy) { |
|||
this.createBy = createBy; |
|||
} |
|||
|
|||
public Date getUpdateTime() {return updateTime;} |
|||
|
|||
public void setUpdateTime(Date updateTime) {this.updateTime = updateTime;} |
|||
|
|||
public Long getUpdateBy() {return updateBy;} |
|||
|
|||
public void setUpdateBy(Long updateBy) {this.updateBy = updateBy;} |
|||
|
|||
} |
|||
@ -0,0 +1,187 @@ |
|||
package com.main.woka.Common.util; |
|||
|
|||
import edu.stanford.nlp.ling.CoreAnnotations; |
|||
import edu.stanford.nlp.ling.CoreLabel; |
|||
import edu.stanford.nlp.pipeline.Annotation; |
|||
import edu.stanford.nlp.pipeline.StanfordCoreNLP; |
|||
import edu.stanford.nlp.util.StringUtils; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.*; |
|||
|
|||
@Component |
|||
public class RelationUtil { |
|||
//标题分词
|
|||
public String analyzeRelationship(String title1, String title2) { |
|||
//载入properties 文件
|
|||
String[] args = new String[]{"-props", "CoreNLP-chinese.properties"}; |
|||
Properties properties = StringUtils.argsToProperties(args); |
|||
properties.setProperty("annotators", "tokenize, ssplit, pos"); |
|||
properties.setProperty("tokenize.language", "zh"); // 设置为中文
|
|||
|
|||
StanfordCoreNLP pipline = new StanfordCoreNLP(properties); |
|||
|
|||
// 分析第一个短语 "低温"
|
|||
String phrase1 = title1; |
|||
List<Map> ll = analyzePhrase(pipline, phrase1); |
|||
|
|||
|
|||
//循环第一个短语的分词
|
|||
String useTitle = ""; |
|||
|
|||
for(int i=0;i<ll.size();i++){ |
|||
if (ll.get(i).get("pos").equals("NN") || ll.get(i).get("pos").equals("JJ")){ |
|||
useTitle = useTitle+ll.get(i).get("text"); |
|||
}else { |
|||
break; |
|||
} |
|||
|
|||
} |
|||
|
|||
// 分析第二个短语 "低温的影响"
|
|||
String phrase2 = title2; |
|||
String result = analyzePhrase1(pipline, phrase2, useTitle); |
|||
return result; |
|||
} |
|||
|
|||
public List<Map> analyzePhrase(StanfordCoreNLP pipeline, String phrase) { |
|||
List<Map> list = new ArrayList<>(); |
|||
Annotation document = new Annotation(phrase); |
|||
pipeline.annotate(document); |
|||
|
|||
List<CoreLabel> tokens = document.get(CoreAnnotations.TokensAnnotation.class); |
|||
for (CoreLabel token : tokens) { |
|||
String word = token.get(CoreAnnotations.TextAnnotation.class); |
|||
String pos = token.get(CoreAnnotations.PartOfSpeechAnnotation.class); |
|||
System.out.println(word + ": " + pos); |
|||
Map mm = new HashMap(); |
|||
mm.put("text",word); |
|||
mm.put("pos",pos); |
|||
list.add(mm); |
|||
} |
|||
return list; |
|||
|
|||
} |
|||
|
|||
public String analyzePhrase1(StanfordCoreNLP pipeline, String phrase,String useTitle) { |
|||
Annotation document = new Annotation(phrase); |
|||
pipeline.annotate(document); |
|||
String title= ""; |
|||
String result =""; |
|||
Integer index = 0; |
|||
System.out.println(useTitle); |
|||
|
|||
List<CoreLabel> tokens = document.get(CoreAnnotations.TokensAnnotation.class); |
|||
for(int i=0;i<tokens.size();i++){ |
|||
CoreLabel token = tokens.get(i); |
|||
String word = token.get(CoreAnnotations.TextAnnotation.class); |
|||
String pos = token.get(CoreAnnotations.PartOfSpeechAnnotation.class); |
|||
title= title + word; |
|||
if(useTitle.equals(title)){ |
|||
//有相同词汇有关系
|
|||
index = i+1; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
System.out.println(index); |
|||
if (index==0){ |
|||
return "属于"; |
|||
}else { |
|||
for(int j=index;j<tokens.size();j++){ |
|||
CoreLabel token1 = tokens.get(j); |
|||
String word1 = token1.get(CoreAnnotations.TextAnnotation.class); |
|||
String pos1 = token1.get(CoreAnnotations.PartOfSpeechAnnotation.class); |
|||
if(j==index){ |
|||
System.out.println(pos1); |
|||
if(word1.equals("的")){ |
|||
System.out.println("aaaaaaaaaaaaaaaa"); |
|||
}else { |
|||
if(pos1.equals("PU")){ |
|||
result = "属于"; |
|||
break; |
|||
} |
|||
if (!pos1.equals("CC") && !pos1.equals("DEG")){ |
|||
result= result + word1; |
|||
} |
|||
} |
|||
|
|||
|
|||
}else { |
|||
result= result + word1; |
|||
} |
|||
|
|||
} |
|||
if(result.equals("")){ |
|||
result = "属于"; |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
//将一句话分成多个词语
|
|||
public List<String> analyzeRelationshipLong(String title1) { |
|||
List<String> list = new ArrayList<>(); |
|||
String[] args = new String[]{"-props", "CoreNLP-chinese.properties"}; |
|||
Properties properties = StringUtils.argsToProperties(args); |
|||
properties.setProperty("annotators", "tokenize, ssplit, pos"); |
|||
properties.setProperty("tokenize.language", "zh"); // 设置为中文
|
|||
|
|||
StanfordCoreNLP pipline = new StanfordCoreNLP(properties); |
|||
|
|||
// 分析第一个短语 "低温"
|
|||
String phrase1 = title1; |
|||
List<Map> ll = analyzePhrase(pipline, phrase1); |
|||
|
|||
for(int i=0;i<ll.size();i++){ |
|||
if (ll.get(i).get("pos").equals("NN")){ |
|||
list.add(String.valueOf(ll.get(i).get("text"))); |
|||
} |
|||
} |
|||
|
|||
return list; |
|||
} |
|||
|
|||
|
|||
public List<String> analyzeRelationshipLong1(String title1) { |
|||
List<String> list = new ArrayList<>(); |
|||
String[] args = new String[]{"-props", "CoreNLP-chinese.properties"}; |
|||
Properties properties = StringUtils.argsToProperties(args); |
|||
properties.setProperty("annotators", "tokenize, ssplit, pos"); |
|||
properties.setProperty("tokenize.language", "zh"); // 设置为中文
|
|||
|
|||
StanfordCoreNLP pipline = new StanfordCoreNLP(properties); |
|||
|
|||
// 分析第一个短语 "低温"
|
|||
String phrase1 = title1; |
|||
List<Map> ll = analyzePhrase(pipline, phrase1); |
|||
|
|||
for(int i=0;i<ll.size();i++){ |
|||
if (ll.get(i).get("pos").equals("NN")){ |
|||
if(String.valueOf(ll.get(i).get("text")).charAt(0)!='<' && String.valueOf(ll.get(i).get("text")).charAt(0)!='&' && String.valueOf(ll.get(i).get("text")).charAt(String.valueOf(ll.get(i).get("text")).length()-1)!='t'){ |
|||
int hh = 0; |
|||
for(int b=0;b<list.size();b++){ |
|||
if(list.get(b).equals(String.valueOf(ll.get(i).get("text")))){ |
|||
hh = 1; |
|||
break; |
|||
} |
|||
} |
|||
if (hh == 0){ |
|||
list.add(String.valueOf(ll.get(i).get("text"))); |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
} |
|||
|
|||
return list; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,118 @@ |
|||
package com.main.woka.Web.Controller; |
|||
|
|||
import com.main.woka.Common.core.AjaxResult; |
|||
import com.main.woka.Common.util.KcTlFile; |
|||
import com.main.woka.Common.util.Neo4jUtil; |
|||
import com.main.woka.Common.util.WebSocket; |
|||
import com.main.woka.Web.Mapper.KcFileMapper; |
|||
import com.main.woka.Web.Mapper.KcInfoRelationMapper; |
|||
import com.main.woka.Web.Service.impl.KcTlFileServiceImpl; |
|||
import com.main.woka.Web.Service.impl.PdfUtil; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import java.io.File; |
|||
import java.io.FileInputStream; |
|||
import java.io.IOException; |
|||
import java.sql.Timestamp; |
|||
import java.text.SimpleDateFormat; |
|||
import java.util.Date; |
|||
|
|||
@RestController |
|||
@RequestMapping("/file") |
|||
public class KcTlFileController extends BaseController { |
|||
|
|||
@Autowired |
|||
KcTlFileServiceImpl kcFileService; |
|||
|
|||
@Autowired |
|||
KcFileMapper kcFileMapper; |
|||
|
|||
@Autowired |
|||
WebSocket webSocket; |
|||
|
|||
@Autowired |
|||
Neo4jUtil neo4jUtil; |
|||
|
|||
@Autowired |
|||
PdfUtil pdfUtil; |
|||
|
|||
@Autowired |
|||
KcInfoRelationMapper kcInfoRelationMapper; |
|||
|
|||
@PostMapping("/addFile") |
|||
public AjaxResult addFile(MultipartFile file) throws IOException { |
|||
String url = saveFileWithStructure(file); |
|||
FileInputStream fileInputStream = new FileInputStream(url + "\\" + file.getOriginalFilename()); |
|||
|
|||
|
|||
KcTlFile kcTlFile = new KcTlFile(); |
|||
kcTlFile.setCreateTime(new Timestamp(new Date().getTime())); |
|||
kcTlFile.setFileName(file.getOriginalFilename()); |
|||
kcTlFile.setFileUrl(url + "\\" + file.getOriginalFilename()); |
|||
// kcTlFile.setIsShow("0");
|
|||
// kcTlFile.setIsDelete("0");
|
|||
kcTlFile.setCreateBy(getUserId()); |
|||
webSocket.sendOneMessage(String.valueOf(getUserId()), "正在保存原文件"); |
|||
kcFileService.insertFile(kcTlFile); |
|||
webSocket.sendOneMessage(String.valueOf(getUserId()), "正在解析分词"); |
|||
kcFileService.wordSplitter(fileInputStream, url + "\\wordSplitter", Math.toIntExact(kcTlFile.getId())); |
|||
|
|||
webSocket.sendOneMessage(String.valueOf(getUserId()), "正在建立关系"); |
|||
kcFileService.getRelationShip(Math.toIntExact(kcTlFile.getId())); |
|||
webSocket.sendOneMessage(String.valueOf(getUserId()), "正在创建图谱"); |
|||
kcFileService.createGraph(); |
|||
return AjaxResult.success().put("msg", "成功"); |
|||
} |
|||
|
|||
|
|||
public String saveFileWithStructure(MultipartFile file) throws IOException { |
|||
// Get the current date and format it
|
|||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss"); |
|||
String formattedDate = dateFormat.format(new Date()); |
|||
|
|||
// Create base directory if not exists
|
|||
File baseDir = new File("D:\\fileManager"); |
|||
|
|||
if (!baseDir.exists() && !baseDir.mkdirs()) { |
|||
throw new IOException("Failed to create base directory: " + baseDir.getAbsolutePath()); |
|||
} |
|||
|
|||
// Create 'index' directory at the base level
|
|||
File indexDir = new File(baseDir, "index"); |
|||
if (!indexDir.exists() && !indexDir.mkdir()) { |
|||
throw new IOException("Failed to create index directory: " + indexDir.getAbsolutePath()); |
|||
} |
|||
|
|||
// Create subdirectory with filename + date
|
|||
String fileName = file.getOriginalFilename(); |
|||
File subDir = new File(baseDir, fileName + "_" + formattedDate); |
|||
if (!subDir.mkdir()) { |
|||
throw new IOException("Failed to create subdirectory: " + subDir.getAbsolutePath()); |
|||
} |
|||
|
|||
// Create 'wordSplitter' directory within the subdirectory
|
|||
File wordSplitterDir = new File(subDir, "wordSplitter"); |
|||
if (!wordSplitterDir.mkdir()) { |
|||
throw new IOException("Failed to create wordSplitter directory: " + wordSplitterDir.getAbsolutePath()); |
|||
} |
|||
|
|||
// Save the original file to the subdirectory
|
|||
File destinationFile = new File(subDir, fileName); |
|||
try { |
|||
file.transferTo(destinationFile); |
|||
} catch (IOException e) { |
|||
// Clean up the created directories if file transfer fails
|
|||
subDir.delete(); |
|||
wordSplitterDir.delete(); |
|||
throw e; |
|||
} |
|||
return subDir.getPath(); |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,78 @@ |
|||
package com.main.woka.Web.Mapper; |
|||
|
|||
import com.main.woka.Common.util.KcInfo; |
|||
import com.main.woka.Common.util.KcInfoRelation; |
|||
import com.main.woka.Common.util.KcTlFile; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Mapper |
|||
public interface KcFileMapper { |
|||
List<KcInfo> selectAllDoc(); |
|||
List<KcInfo> selectAllDocOver(KcInfo kcInfo); |
|||
List<KcInfo> selectAllDocList(); |
|||
|
|||
//List<KcInfo> selectAllDocListP(Long level);
|
|||
List<KcInfo> selectAllDocByfileId(Integer fileId); |
|||
|
|||
|
|||
int insertDoc(KcInfo kcInfo); |
|||
|
|||
|
|||
int insertDocList(List<KcInfo> list); |
|||
|
|||
|
|||
KcInfo selectDoc(KcInfo kcInfo); |
|||
|
|||
KcInfo selectDocByURL(KcInfo kcInfo); |
|||
|
|||
KcInfo selectDocById(KcInfo kcInfo); |
|||
|
|||
KcInfo selectDocByIdId(Long id); |
|||
|
|||
|
|||
int updateDocById(KcInfo kcInfo); |
|||
int updateparentId(List<KcInfo> list); |
|||
int updateParentId1(@Param("name") String name, @Param("level") Long level, @Param("parentId") Long parentId); |
|||
|
|||
int updateParentId2(@Param("name") String name,@Param("level") Long level, @Param("parentId") Long parentId, @Param("groupId")Long groupId); |
|||
|
|||
List<KcInfo> getOneHeader(Long parentId); |
|||
|
|||
List<KcInfo> getHeaderByLevel(@Param("level") Long level , @Param("fileId") Integer fileId); |
|||
|
|||
List<KcTlFile> getFileList(); |
|||
|
|||
List<KcTlFile> getFileList1(); |
|||
|
|||
|
|||
|
|||
|
|||
KcTlFile getFileById(@Param("id") Integer id); |
|||
List<KcInfo> getDocByFileId(@Param("fileId")Integer fileId); |
|||
List<KcInfo> getDocByFileIdNew(@Param("fileId")Integer fileId,@Param("name")String name); |
|||
|
|||
List<KcInfo> selectAllDocByPLeve(KcInfo kcInfo); |
|||
|
|||
List<KcInfo> selectAllDocByPLeve1(KcInfo kcInfo); |
|||
|
|||
int deleteTxtById(@Param("id")Long id); |
|||
List<KcInfo> selectDocByUrl(List<String> urlList); |
|||
|
|||
|
|||
|
|||
|
|||
int updateGraphStatus(Long id); |
|||
int updateGraphRelation(KcInfoRelation kcInfoRelation); |
|||
|
|||
|
|||
KcInfo selectDocUrl(KcInfo kcInfoApi); |
|||
|
|||
int updateDownLoadUrl(KcInfo kcInfoApi); |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,66 @@ |
|||
package com.main.woka.Web.Mapper; |
|||
|
|||
import com.main.woka.Common.util.KcInfoRelation; |
|||
import com.main.woka.Common.util.KcTlFile; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Mapper |
|||
public interface KcInfoRelationMapper { |
|||
|
|||
|
|||
int insertFile(KcTlFile kcTlFile); |
|||
|
|||
List<KcInfoRelation> getAllRelation(); |
|||
|
|||
/** |
|||
* 查询文章关系 |
|||
* |
|||
* @param id 文章关系主键 |
|||
* @return 文章关系 |
|||
*/ |
|||
public KcInfoRelation selectKcRelationshipById(Long id); |
|||
|
|||
/** |
|||
* 查询文章关系列表 |
|||
* |
|||
* @param kcRelationship 文章关系 |
|||
* @return 文章关系集合 |
|||
*/ |
|||
public List<KcInfoRelation> selectKcRelationshipList(KcInfoRelation kcRelationship); |
|||
|
|||
/** |
|||
* 新增文章关系 |
|||
* |
|||
* @param kcRelationship 文章关系 |
|||
* @return 结果 |
|||
*/ |
|||
public int insertKcRelationship(KcInfoRelation kcRelationship); |
|||
|
|||
/** |
|||
* 修改文章关系 |
|||
* |
|||
* @param kcRelationship 文章关系 |
|||
* @return 结果 |
|||
*/ |
|||
public int updateKcRelationship(KcInfoRelation kcRelationship); |
|||
|
|||
/** |
|||
* 删除文章关系 |
|||
* |
|||
* @param id 文章关系主键 |
|||
* @return 结果 |
|||
*/ |
|||
public int deleteKcRelationshipById(Long id); |
|||
|
|||
/** |
|||
* 批量删除文章关系 |
|||
* |
|||
* @param ids 需要删除的数据主键集合 |
|||
* @return 结果 |
|||
*/ |
|||
public int deleteKcRelationshipByIds(Long[] ids); |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,765 @@ |
|||
package com.main.woka.Web.Service.impl; |
|||
|
|||
import com.main.woka.Common.util.*; |
|||
import com.main.woka.Web.Mapper.KcFileMapper; |
|||
import com.main.woka.Web.Mapper.KcInfoRelationMapper; |
|||
import org.neo4j.driver.v1.StatementResult; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.io.FileInputStream; |
|||
import java.lang.reflect.Field; |
|||
import java.util.*; |
|||
|
|||
@Service |
|||
public class KcTlFileServiceImpl { |
|||
|
|||
@Autowired |
|||
KcFileMapper kcFileMapper; |
|||
|
|||
@Autowired |
|||
KcInfoRelationMapper kcInfoRelationMapper; |
|||
|
|||
@Autowired |
|||
WordSplitter wordSplitter; |
|||
|
|||
@Autowired |
|||
RelationUtil relationUtil; |
|||
|
|||
@Autowired |
|||
Neo4jUtil neo4jUtil; |
|||
|
|||
@Autowired |
|||
KcFileMapper kcFile1Mapper; |
|||
|
|||
public String wordSplitter(FileInputStream file, String url, Integer fileId){ |
|||
try { |
|||
wordSplitter.testWordOne(file,url,fileId); |
|||
return "a"; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return "b"; |
|||
} |
|||
|
|||
public Integer insertFile(KcTlFile kcTlFile){ |
|||
return kcInfoRelationMapper.insertFile(kcTlFile); |
|||
} |
|||
|
|||
public String getRelationShip(Integer fileId){ |
|||
|
|||
|
|||
|
|||
//先获取所有的第一级标题
|
|||
List<KcInfo> list = kcFileMapper.getHeaderByLevel(1l,fileId); |
|||
String nameOld = String.valueOf(kcFile1Mapper.getFileById(fileId)); |
|||
String name = nameOld.substring(0,nameOld.length()-5); |
|||
|
|||
|
|||
for(int a=0;a<list.size();a++){ |
|||
String source = list.get(a).getName(); |
|||
Long OneId = list.get(a).getId(); |
|||
|
|||
|
|||
String name1 = name; |
|||
String name2 = source; |
|||
KcInfoRelation zz1 = new KcInfoRelation(); |
|||
zz1.setRelation("属于"); |
|||
zz1.setSourceId(Long.valueOf(fileId)); |
|||
zz1.setTargetId(OneId); |
|||
zz1.setSourceName(name1); |
|||
zz1.setTargetName(name2); |
|||
zz1.setCreateTime(new Date()); |
|||
kcInfoRelationMapper.insertKcRelationship(zz1); |
|||
|
|||
|
|||
List<KcInfo> list1 = kcFileMapper.getOneHeader(OneId); |
|||
|
|||
for(int i=0;i<list1.size();i++){ |
|||
|
|||
String target = list1.get(i).getName(); |
|||
// String aa = relationUtil.analyzeRelationship(source,target);
|
|||
String aa = "属于"; |
|||
// System.out.println(aa);
|
|||
//获取两个的Id
|
|||
Long TwoId = list1.get(i).getId(); |
|||
KcInfoRelation zz = new KcInfoRelation(); |
|||
zz.setRelation(aa); |
|||
zz.setSourceId(OneId); |
|||
zz.setTargetId(TwoId); |
|||
zz.setSourceName(source); |
|||
zz.setTargetName(target); |
|||
zz.setCreateTime(new Date()); |
|||
kcInfoRelationMapper.insertKcRelationship(zz); |
|||
} |
|||
} |
|||
|
|||
//获取所有的二级标题
|
|||
List<KcInfo> list2 = kcFileMapper.getHeaderByLevel(2l,fileId); |
|||
for(int a1=0;a1<list2.size();a1++){ |
|||
Long OneId = list2.get(a1).getId(); |
|||
List<KcInfo> list1 = kcFileMapper.getOneHeader(OneId); |
|||
for(int i=0;i<list1.size();i++){ |
|||
String source = list2.get(a1).getName(); |
|||
String target = list1.get(i).getName(); |
|||
// String aa = relationUtil.analyzeRelationship(source,target);
|
|||
String aa = "属于"; |
|||
System.out.println(aa); |
|||
//获取两个的Id
|
|||
Long TwoId = list1.get(i).getId(); |
|||
KcInfoRelation zz = new KcInfoRelation(); |
|||
zz.setRelation(aa); |
|||
zz.setSourceId(OneId); |
|||
zz.setTargetId(TwoId); |
|||
zz.setSourceName(source); |
|||
zz.setTargetName(target); |
|||
zz.setCreateTime(new Date()); |
|||
kcInfoRelationMapper.insertKcRelationship(zz); |
|||
|
|||
} |
|||
} |
|||
|
|||
//获取所有的三级标题
|
|||
List<KcInfo> list3 = kcFileMapper.getHeaderByLevel(3l,fileId); |
|||
for(int a2=0;a2<list3.size();a2++){ |
|||
Long OneId = list3.get(a2).getId(); |
|||
List<KcInfo> list1 = kcFileMapper.getOneHeader(OneId); |
|||
for(int i=0;i<list1.size();i++){ |
|||
String source = list3.get(a2).getName(); |
|||
String target = list1.get(i).getName(); |
|||
String aa = "属于"; |
|||
// String aa = relationUtil.analyzeRelationship(source,target);
|
|||
System.out.println(aa); |
|||
//获取两个的Id
|
|||
Long TwoId = list1.get(i).getId(); |
|||
KcInfoRelation zz = new KcInfoRelation(); |
|||
zz.setRelation(aa); |
|||
zz.setSourceId(OneId); |
|||
zz.setTargetId(TwoId); |
|||
zz.setSourceName(source); |
|||
zz.setTargetName(target); |
|||
zz.setCreateTime(new Date()); |
|||
kcInfoRelationMapper.insertKcRelationship(zz); |
|||
|
|||
} |
|||
} |
|||
|
|||
|
|||
//获取所有的四级标题
|
|||
List<KcInfo> list4 = kcFileMapper.getHeaderByLevel(4l,fileId); |
|||
for(int a2=0;a2<list4.size();a2++){ |
|||
Long OneId = list4.get(a2).getId(); |
|||
List<KcInfo> list1 = kcFileMapper.getOneHeader(OneId); |
|||
for(int i=0;i<list1.size();i++){ |
|||
String source = list4.get(a2).getName(); |
|||
String target = list1.get(i).getName(); |
|||
String aa = "属于"; |
|||
// String aa = relationUtil.analyzeRelationship(source,target);
|
|||
System.out.println(aa); |
|||
//获取两个的Id
|
|||
Long TwoId = list1.get(i).getId(); |
|||
KcInfoRelation zz = new KcInfoRelation(); |
|||
zz.setRelation(aa); |
|||
zz.setSourceId(OneId); |
|||
zz.setTargetId(TwoId); |
|||
zz.setSourceName(source); |
|||
zz.setTargetName(target); |
|||
zz.setCreateTime(new Date()); |
|||
kcInfoRelationMapper.insertKcRelationship(zz); |
|||
|
|||
} |
|||
} |
|||
|
|||
//获取所有的五级文件
|
|||
List<KcInfo> list5 = kcFileMapper.getHeaderByLevel(5l,fileId); |
|||
for(int a2=0;a2<list5.size();a2++){ |
|||
Long OneId = list5.get(a2).getId(); |
|||
List<KcInfo> list1 = kcFileMapper.getOneHeader(OneId); |
|||
for(int i=0;i<list1.size();i++){ |
|||
String source = list5.get(a2).getName(); |
|||
String target = list1.get(i).getName(); |
|||
String aa = "属于"; |
|||
// String aa = relationUtil.analyzeRelationship(source,target);
|
|||
System.out.println(aa); |
|||
//获取两个的Id
|
|||
Long TwoId = list1.get(i).getId(); |
|||
KcInfoRelation zz = new KcInfoRelation(); |
|||
zz.setRelation(aa); |
|||
zz.setSourceId(OneId); |
|||
zz.setTargetId(TwoId); |
|||
zz.setSourceName(source); |
|||
zz.setTargetName(target); |
|||
zz.setCreateTime(new Date()); |
|||
kcInfoRelationMapper.insertKcRelationship(zz); |
|||
|
|||
} |
|||
} |
|||
|
|||
return "a"; |
|||
} |
|||
|
|||
// public String getRelationShip1(Integer fileId,String parentId,String relation){
|
|||
//
|
|||
//
|
|||
//
|
|||
// //先获取所有的第一级标题
|
|||
// List<KcInfo> list = kcFileMapper.getHeaderByLevel(1l,fileId);
|
|||
//
|
|||
// //查询选择的上级
|
|||
// KcInfo aan = new KcInfo();
|
|||
// aan.setId(Long.valueOf(parentId));
|
|||
// KcInfo ddo = kcFile1Mapper.selectDocById(aan);
|
|||
// String name = ddo.getName();
|
|||
//
|
|||
// Long leve = 0l;
|
|||
//
|
|||
//
|
|||
//
|
|||
//
|
|||
// if(list.size()!=0){
|
|||
// for(int a=0;a<list.size();a++){
|
|||
// String source = list.get(a).getName();
|
|||
// Long OneId = list.get(a).getId();
|
|||
//
|
|||
//
|
|||
// String name1 = name;
|
|||
// String name2 = source;
|
|||
// KcInfoRelation zz1 = new KcInfoRelation();
|
|||
// zz1.setRelation(relation);
|
|||
// zz1.setSourceId(Long.valueOf(parentId));
|
|||
// zz1.setTargetId(OneId);
|
|||
// zz1.setSourceName(name1);
|
|||
// zz1.setTargetName(name2);
|
|||
// zz1.setCreateTime(new Date());
|
|||
// kcInfoRelationMapper.insertKcRelationship(zz1);
|
|||
//
|
|||
//
|
|||
// List<KcInfo> list1 = kcFileMapper.getOneHeader(OneId);
|
|||
//
|
|||
// for(int i=0;i<list1.size();i++){
|
|||
//
|
|||
// String target = list1.get(i).getName();
|
|||
// String aa = "属于";
|
|||
//// String aa = relationUtil.analyzeRelationship(source,target);
|
|||
// System.out.println(aa);
|
|||
// //获取两个的Id
|
|||
// Long TwoId = list1.get(i).getId();
|
|||
// KcInfoRelation zz = new KcInfoRelation();
|
|||
// zz.setRelation(aa);
|
|||
// zz.setSourceId(OneId);
|
|||
// zz.setTargetId(TwoId);
|
|||
// zz.setSourceName(source);
|
|||
// zz.setTargetName(target);
|
|||
// zz.setCreateTime(new Date());
|
|||
// kcInfoRelationMapper.insertKcRelationship(zz);
|
|||
// }
|
|||
// }
|
|||
// leve =1l;
|
|||
// }
|
|||
//
|
|||
//
|
|||
// //获取所有的二级标题
|
|||
// List<KcInfo> list2 = kcFileMapper.getHeaderByLevel(2l,fileId);
|
|||
// if(list2.size()!=0){
|
|||
//
|
|||
// for(int a1=0;a1<list2.size();a1++){
|
|||
// Long OneId = list2.get(a1).getId();
|
|||
//
|
|||
// if(leve==0){
|
|||
// String source = list2.get(a1).getName();
|
|||
// String name1 = name;
|
|||
// String name2 = source;
|
|||
// KcInfoRelation zz1 = new KcInfoRelation();
|
|||
// zz1.setRelation(relation);
|
|||
// zz1.setSourceId(Long.valueOf(parentId));
|
|||
// zz1.setTargetId(OneId);
|
|||
// zz1.setSourceName(name1);
|
|||
// zz1.setTargetName(name2);
|
|||
// zz1.setCreateTime(new Date());
|
|||
// kcInfoRelationMapper.insertKcRelationship(zz1);
|
|||
// }
|
|||
// List<KcInfo> list1 = kcFileMapper.getOneHeader(OneId);
|
|||
// for(int i=0;i<list1.size();i++){
|
|||
// String source = list2.get(a1).getName();
|
|||
// String target = list1.get(i).getName();
|
|||
// String aa = "属于";
|
|||
//// String aa = relationUtil.analyzeRelationship(source,target);
|
|||
// System.out.println(aa);
|
|||
// //获取两个的Id
|
|||
// Long TwoId = list1.get(i).getId();
|
|||
// KcInfoRelation zz = new KcInfoRelation();
|
|||
// zz.setRelation(aa);
|
|||
// zz.setSourceId(OneId);
|
|||
// zz.setTargetId(TwoId);
|
|||
// zz.setSourceName(source);
|
|||
// zz.setTargetName(target);
|
|||
// zz.setCreateTime(new Date());
|
|||
// kcInfoRelationMapper.insertKcRelationship(zz);
|
|||
//
|
|||
// }
|
|||
// }
|
|||
// leve = 2l;
|
|||
//
|
|||
// }
|
|||
//
|
|||
// //获取所有的三级标题
|
|||
// List<KcInfo> list3 = kcFileMapper.getHeaderByLevel(3l,fileId);
|
|||
// if(list3.size()!=0){
|
|||
// for(int a2=0;a2<list3.size();a2++){
|
|||
// Long OneId = list3.get(a2).getId();
|
|||
// if(leve==0){
|
|||
// String source = list3.get(a2).getName();
|
|||
// String name1 = name;
|
|||
// String name2 = source;
|
|||
// KcInfoRelation zz1 = new KcInfoRelation();
|
|||
// zz1.setRelation(relation);
|
|||
// zz1.setSourceId(Long.valueOf(parentId));
|
|||
// zz1.setTargetId(OneId);
|
|||
// zz1.setSourceName(name1);
|
|||
// zz1.setTargetName(name2);
|
|||
// zz1.setCreateTime(new Date());
|
|||
// kcInfoRelationMapper.insertKcRelationship(zz1);
|
|||
// }
|
|||
// List<KcInfo> list1 = kcFileMapper.getOneHeader(OneId);
|
|||
// for(int i=0;i<list1.size();i++){
|
|||
// String source = list3.get(a2).getName();
|
|||
// String target = list1.get(i).getName();
|
|||
// String aa = "属于";
|
|||
//// String aa = relationUtil.analyzeRelationship(source,target);
|
|||
// System.out.println(aa);
|
|||
// //获取两个的Id
|
|||
// Long TwoId = list1.get(i).getId();
|
|||
// KcInfoRelation zz = new KcInfoRelation();
|
|||
// zz.setRelation(aa);
|
|||
// zz.setSourceId(OneId);
|
|||
// zz.setTargetId(TwoId);
|
|||
// zz.setSourceName(source);
|
|||
// zz.setTargetName(target);
|
|||
// zz.setCreateTime(new Date());
|
|||
// kcInfoRelationMapper.insertKcRelationship(zz);
|
|||
//
|
|||
// }
|
|||
// }
|
|||
// leve = 3l;
|
|||
// }
|
|||
//
|
|||
//
|
|||
//
|
|||
// //获取所有的四级标题
|
|||
// List<KcInfo> list4 = kcFileMapper.getHeaderByLevel(4l,fileId);
|
|||
// if(list4.size()!=0){
|
|||
// for(int a2=0;a2<list4.size();a2++){
|
|||
// Long OneId = list4.get(a2).getId();
|
|||
// if(leve==0){
|
|||
// String source = list4.get(a2).getName();
|
|||
// String name1 = name;
|
|||
// String name2 = source;
|
|||
// KcInfoRelation zz1 = new KcInfoRelation();
|
|||
// zz1.setRelation(relation);
|
|||
// zz1.setSourceId(Long.valueOf(parentId));
|
|||
// zz1.setTargetId(OneId);
|
|||
// zz1.setSourceName(name1);
|
|||
// zz1.setTargetName(name2);
|
|||
// zz1.setCreateTime(new Date());
|
|||
// kcInfoRelationMapper.insertKcRelationship(zz1);
|
|||
// }
|
|||
// List<KcInfo> list1 = kcFileMapper.getOneHeader(OneId);
|
|||
// for(int i=0;i<list1.size();i++){
|
|||
// String source = list4.get(a2).getName();
|
|||
// String target = list1.get(i).getName();
|
|||
// String aa = "属于";
|
|||
//// String aa = relationUtil.analyzeRelationship(source,target);
|
|||
// System.out.println(aa);
|
|||
// //获取两个的Id
|
|||
// Long TwoId = list1.get(i).getId();
|
|||
// KcInfoRelation zz = new KcInfoRelation();
|
|||
// zz.setRelation(aa);
|
|||
// zz.setSourceId(OneId);
|
|||
// zz.setTargetId(TwoId);
|
|||
// zz.setSourceName(source);
|
|||
// zz.setTargetName(target);
|
|||
// zz.setCreateTime(new Date());
|
|||
// kcInfoRelationMapper.insertKcRelationship(zz);
|
|||
//
|
|||
// }
|
|||
// }
|
|||
// leve=4l;
|
|||
// }
|
|||
//
|
|||
//
|
|||
// //获取所有的五级文件
|
|||
// List<KcInfo> list5 = kcFileMapper.getHeaderByLevel(5l,fileId);
|
|||
// if(list5.size()!=0){
|
|||
// for(int a2=0;a2<list5.size();a2++){
|
|||
// Long OneId = list5.get(a2).getId();
|
|||
// if(leve==0){
|
|||
// String source = list5.get(a2).getName();
|
|||
// String name1 = name;
|
|||
// String name2 = source;
|
|||
// KcInfoRelation zz1 = new KcInfoRelation();
|
|||
// zz1.setRelation(relation);
|
|||
// zz1.setSourceId(Long.valueOf(parentId));
|
|||
// zz1.setTargetId(OneId);
|
|||
// zz1.setSourceName(name1);
|
|||
// zz1.setTargetName(name2);
|
|||
// zz1.setCreateTime(new Date());
|
|||
// kcInfoRelationMapper.insertKcRelationship(zz1);
|
|||
// }
|
|||
// List<KcInfo> list1 = kcFileMapper.getOneHeader(OneId);
|
|||
// for(int i=0;i<list1.size();i++){
|
|||
// String source = list5.get(a2).getName();
|
|||
// String target = list1.get(i).getName();
|
|||
// String aa = "属于";
|
|||
//// String aa = relationUtil.analyzeRelationship(source,target);
|
|||
//
|
|||
// System.out.println(aa);
|
|||
// //获取两个的Id
|
|||
// Long TwoId = list1.get(i).getId();
|
|||
// KcInfoRelation zz = new KcInfoRelation();
|
|||
// zz.setRelation(aa);
|
|||
// zz.setSourceId(OneId);
|
|||
// zz.setTargetId(TwoId);
|
|||
// zz.setSourceName(source);
|
|||
// zz.setTargetName(target);
|
|||
// zz.setCreateTime(new Date());
|
|||
// kcInfoRelationMapper.insertKcRelationship(zz);
|
|||
//
|
|||
// }
|
|||
// }
|
|||
// leve = 5l;
|
|||
// }
|
|||
//
|
|||
//
|
|||
// return "a";
|
|||
// }
|
|||
|
|||
//生成图谱
|
|||
public String createGraph(){ |
|||
//先获取所有的文章实体
|
|||
//查询对应的大文章
|
|||
List<List<Map>> list2 = new ArrayList<>(); |
|||
List<KcTlFile> ll = kcFile1Mapper.getFileList(); |
|||
for(int b=0;b<ll.size();b++){ |
|||
List<Map> list1 = new ArrayList<>(); |
|||
String name = ll.get(b).getFileName().substring(0,ll.get(b).getFileName().length()-5); |
|||
//获取这个大文章下的所有文章;
|
|||
name = name.replace("+","&"); |
|||
name = name.replace("-","为"); |
|||
name = name.replace(" ",""); |
|||
name = name.replace(".",""); |
|||
Map<String,String> bb1 = new HashMap<>(); |
|||
bb1.put("key","name"); |
|||
bb1.put("value",name); |
|||
list1.add(bb1); |
|||
Map<String,String> bb2 = new HashMap<>(); |
|||
bb2.put("key","docId"); |
|||
bb2.put("value", String.valueOf(ll.get(b).getId())); |
|||
list1.add(bb2); |
|||
Map<String,String> bb3 = new HashMap<>(); |
|||
bb3.put("key","leve"); |
|||
bb3.put("value","leve0"); |
|||
list1.add(bb3); |
|||
// System.out.println(list1.size());
|
|||
list2.add(list1); |
|||
|
|||
List<KcInfo> list = kcFile1Mapper.selectAllDocByfileId(Math.toIntExact(ll.get(b).getId())); |
|||
|
|||
|
|||
for(int i=0;i<list.size();i++){ |
|||
List<Map> listNew = new ArrayList<>(); |
|||
KcInfo info = list.get(i); |
|||
Class<?> clazz = KcInfo.class; |
|||
Field[] fields = clazz.getDeclaredFields(); |
|||
|
|||
for (Field field : fields) { |
|||
String fieldName = field.getName(); |
|||
System.out.println("字段名称:" + fieldName); |
|||
Map<String,String> bb = new HashMap<>(); |
|||
if(fieldName.equals("id")){ |
|||
bb.put("key","docId"); |
|||
bb.put("value", String.valueOf(info.getId())); |
|||
listNew.add(bb); |
|||
} |
|||
if(fieldName.equals("name")){ |
|||
bb.put("key","name"); |
|||
bb.put("value", info.getName()); |
|||
|
|||
listNew.add(bb); |
|||
} |
|||
if(fieldName.equals("parentId")){ |
|||
bb.put("key","parentId"); |
|||
bb.put("value", String.valueOf(info.getParentId())); |
|||
listNew.add(bb); |
|||
} |
|||
|
|||
if(fieldName.equals("groupId")){ |
|||
bb.put("key","groupId"); |
|||
bb.put("value", String.valueOf(info.getGroupId())); |
|||
|
|||
listNew.add(bb); |
|||
} |
|||
if(fieldName.equals("level")){ |
|||
if(info.getLevel()==1){ |
|||
bb.put("key","leve"); |
|||
bb.put("value","leve1"); |
|||
} |
|||
if(info.getLevel()==2){ |
|||
bb.put("key","leve"); |
|||
bb.put("value","leve2"); |
|||
} |
|||
if(info.getLevel()==3){ |
|||
bb.put("key","leve"); |
|||
bb.put("value","leve3"); |
|||
} |
|||
if(info.getLevel()==4){ |
|||
bb.put("key","leve"); |
|||
bb.put("value","leve4"); |
|||
} |
|||
if(info.getLevel()==5){ |
|||
bb.put("key","leve"); |
|||
bb.put("value","leve5"); |
|||
} |
|||
if(info.getLevel()==6){ |
|||
bb.put("key","leve"); |
|||
bb.put("value","leve6"); |
|||
} |
|||
listNew.add(bb); |
|||
} |
|||
|
|||
} |
|||
list2.add(listNew); |
|||
|
|||
} |
|||
|
|||
for(int bb=0;bb<list2.size();bb++){ |
|||
String docId = ""; |
|||
String cql = "create (doc: Doc{"; |
|||
for(int a=0;a<list2.get(bb).size();a++){ |
|||
if(list2.get(bb).get(a).get("key").equals("docId")){ |
|||
docId = String.valueOf(list2.get(bb).get(a).get("value")); |
|||
} |
|||
|
|||
|
|||
if (list2.get(bb).size()>1){ |
|||
if(a==0){ |
|||
cql = cql + list2.get(bb).get(a).get("key")+":'"+list2.get(bb).get(a).get("value")+"'"; |
|||
}else if(a==(list2.get(bb).size()-1)){ |
|||
cql = cql +","+list2.get(bb).get(a).get("key")+":'"+list2.get(bb).get(a).get("value")+"'})"; |
|||
}else { |
|||
cql = cql +","+ list2.get(bb).get(a).get("key")+":'"+list2.get(bb).get(a).get("value")+"'"; |
|||
} |
|||
}else { |
|||
cql = cql + list2.get(bb).get(a).get("key")+":'"+list2.get(bb).get(a).get("value")+"'}) return doc"; |
|||
} |
|||
|
|||
} |
|||
|
|||
System.out.println(cql); |
|||
StatementResult result = neo4jUtil.excuteCypherSql(cql); |
|||
//创建了之后将创建的实体和关系进行update
|
|||
if(Long.valueOf(docId)>100){ |
|||
int aa = kcFile1Mapper.updateGraphStatus(Long.valueOf(docId)); |
|||
} |
|||
System.out.println(result.keys()); |
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
//获取所有关系
|
|||
List<KcInfoRelation> listR = kcInfoRelationMapper.getAllRelation(); |
|||
System.out.println(listR.size()); |
|||
|
|||
for(int i=0;i<listR.size();i++){ |
|||
List<String> charList = new ArrayList<>(); |
|||
|
|||
for (int j = 0; j < listR.get(i).getRelation().length(); j++) { |
|||
if(!listR.get(i).getRelation().substring(j, j + 1).equals("、")){ |
|||
charList.add(listR.get(i).getRelation().substring(j, j + 1)); |
|||
} |
|||
} |
|||
|
|||
String re = ""; |
|||
for (int k=0;k<charList.size();k++){ |
|||
re = re + charList.get(k); |
|||
} |
|||
listR.get(i).setRelation(re); |
|||
} |
|||
|
|||
|
|||
//创建
|
|||
for(int i=0;i<listR.size();i++){ |
|||
|
|||
String cql = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '"+listR.get(i).getSourceId() +"' AND " + "b.docId = '"+listR.get(i).getTargetId()+"'"; |
|||
cql = cql + " CREATE (a)-[r:"+String.valueOf(listR.get(i).getRelation())+"{ name: '"+String.valueOf(listR.get(i).getRelation())+"'}] -> (b) RETURN r"; |
|||
StatementResult result = neo4jUtil.excuteCypherSql(cql); |
|||
int bb = kcFile1Mapper.updateGraphRelation(listR.get(i)); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
return "aa"; |
|||
} |
|||
|
|||
|
|||
// public String createGraph1(){
|
|||
// //先获取所有的文章实体
|
|||
//
|
|||
//
|
|||
// //查询对应的大文章
|
|||
// List<List<Map>> list2 = new ArrayList<>();
|
|||
// List<KcTlFile> ll = kcFile1Mapper.getFileList();
|
|||
// for(int b=0;b<ll.size();b++){
|
|||
// List<Map> list1 = new ArrayList<>();
|
|||
//
|
|||
// List<KcInfo> list = kcFile1Mapper.selectAllDocByfileId(Math.toIntExact(ll.get(b).getId()));
|
|||
//
|
|||
// for(int i=0;i<list.size();i++){
|
|||
// List<Map> listNew = new ArrayList<>();
|
|||
// KcInfo info = list.get(i);
|
|||
// Class<?> clazz = KcInfo.class;
|
|||
// Field[] fields = clazz.getDeclaredFields();
|
|||
//
|
|||
// for (Field field : fields) {
|
|||
// String fieldName = field.getName();
|
|||
// System.out.println("字段名称:" + fieldName);
|
|||
// Map<String,String> bb = new HashMap<>();
|
|||
// if(fieldName.equals("id")){
|
|||
// bb.put("key","docId");
|
|||
// bb.put("value", String.valueOf(info.getId()));
|
|||
// listNew.add(bb);
|
|||
// }
|
|||
// if(fieldName.equals("name")){
|
|||
// bb.put("key","name");
|
|||
// bb.put("value", info.getName());
|
|||
//
|
|||
// listNew.add(bb);
|
|||
// }
|
|||
//// if(fieldName.equals("level")){
|
|||
//// if(info.getLevel()==1){
|
|||
//// bb.put("key","leve");
|
|||
//// bb.put("value","leve1");
|
|||
//// }
|
|||
//// if(info.getLevel()==2){
|
|||
//// bb.put("key","leve");
|
|||
//// bb.put("value","leve2");
|
|||
//// }
|
|||
//// if(info.getLevel()==3){
|
|||
//// bb.put("key","leve");
|
|||
//// bb.put("value","leve3");
|
|||
//// }
|
|||
//// if(info.getLevel()==4){
|
|||
//// bb.put("key","leve");
|
|||
//// bb.put("value","leve4");
|
|||
//// }
|
|||
//// if(info.getLevel()==5){
|
|||
//// bb.put("key","leve");
|
|||
//// bb.put("value","leve5");
|
|||
//// }
|
|||
//// if(info.getLevel()==6){
|
|||
//// bb.put("key","leve");
|
|||
//// bb.put("value","leve6");
|
|||
//// }
|
|||
//// listNew.add(bb);
|
|||
//// }
|
|||
//
|
|||
// }
|
|||
// list2.add(listNew);
|
|||
//
|
|||
// }
|
|||
//
|
|||
// for(int bb=0;bb<list2.size();bb++){
|
|||
// String docId = "";
|
|||
// String cql = "create (doc: Doc{";
|
|||
// for(int a=0;a<list2.get(bb).size();a++){
|
|||
// System.out.println(list2.get(bb).size());
|
|||
//// if(bb==0){
|
|||
//// System.out.println(list2.get(bb).get(0));
|
|||
//// System.out.println(list2.get(bb).get(1));
|
|||
//// System.out.println(list2.get(bb).get(2));
|
|||
//// }
|
|||
// if(list2.get(bb).get(a).get("key").equals("docId")){
|
|||
// docId = String.valueOf(list2.get(bb).get(a).get("value"));
|
|||
// }
|
|||
//
|
|||
//
|
|||
// if (list2.get(bb).size()>1){
|
|||
// if(a==0){
|
|||
// cql = cql + list2.get(bb).get(a).get("key")+":'"+list2.get(bb).get(a).get("value")+"'";
|
|||
// }else if(a==(list2.get(bb).size()-1)){
|
|||
// cql = cql +","+list2.get(bb).get(a).get("key")+":'"+list2.get(bb).get(a).get("value")+"'})";
|
|||
// }else {
|
|||
// cql = cql +","+ list2.get(bb).get(a).get("key")+":'"+list2.get(bb).get(a).get("value")+"'";
|
|||
// }
|
|||
// }else {
|
|||
// cql = cql + list2.get(bb).get(a).get("key")+":'"+list2.get(bb).get(a).get("value")+"'}) return doc";
|
|||
// }
|
|||
//
|
|||
// }
|
|||
//
|
|||
// System.out.println(cql);
|
|||
// StatementResult result = neo4jUtil.excuteCypherSql(cql);
|
|||
// //创建了之后将创建的实体和关系进行update
|
|||
// if(Long.valueOf(docId)>100){
|
|||
// int aa = kcFile1Mapper.updateGraphStatus(Long.valueOf(docId));
|
|||
// }
|
|||
// System.out.println(result.keys());
|
|||
//
|
|||
//
|
|||
//
|
|||
// }
|
|||
//
|
|||
// }
|
|||
//
|
|||
//
|
|||
//
|
|||
//
|
|||
//
|
|||
//
|
|||
// //获取所有关系
|
|||
// List<KcInfoRelation> listR = kcInfoRelationMapper.getAllRelation();
|
|||
// System.out.println(listR.size());
|
|||
//
|
|||
// for(int i=0;i<listR.size();i++){
|
|||
// List<String> charList = new ArrayList<>();
|
|||
//
|
|||
// for (int j = 0; j < listR.get(i).getRelation().length(); j++) {
|
|||
// if(!listR.get(i).getRelation().substring(j, j + 1).equals("、")){
|
|||
// charList.add(listR.get(i).getRelation().substring(j, j + 1));
|
|||
// }
|
|||
// }
|
|||
//
|
|||
// String re = "";
|
|||
// for (int k=0;k<charList.size();k++){
|
|||
// re = re + charList.get(k);
|
|||
// }
|
|||
// listR.get(i).setRelation(re);
|
|||
// }
|
|||
//
|
|||
//
|
|||
// //创建
|
|||
// for(int i=0;i<listR.size();i++){
|
|||
//
|
|||
// String cql = "MATCH (a:Doc),(b:Doc) WHERE a.docId = '"+listR.get(i).getSourceId() +"' AND " + "b.docId = '"+listR.get(i).getTargetId()+"'";
|
|||
// cql = cql + " CREATE (a)-[r:"+String.valueOf(listR.get(i).getRelation())+"{ name: '"+String.valueOf(listR.get(i).getRelation())+"'}] -> (b) RETURN r";
|
|||
// StatementResult result = neo4jUtil.excuteCypherSql(cql);
|
|||
// int bb = kcFile1Mapper.updateGraphRelation(listR.get(i));
|
|||
// }
|
|||
//
|
|||
//
|
|||
//
|
|||
//
|
|||
//
|
|||
// return "aa";
|
|||
// }
|
|||
|
|||
} |
|||
@ -0,0 +1,147 @@ |
|||
package com.main.woka.Web.Service.impl; |
|||
|
|||
import com.main.woka.Common.constant.Constants; |
|||
import com.main.woka.Common.util.FileUploadUtils; |
|||
import com.main.woka.Config.RuoYiConfig; |
|||
import com.main.woka.Config.ServerConfig; |
|||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException; |
|||
import org.apache.poi.util.Units; |
|||
import org.jsoup.Jsoup; |
|||
import org.jsoup.nodes.Document; |
|||
import org.jsoup.nodes.Element; |
|||
import org.jsoup.select.Elements; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.mock.web.MockMultipartFile; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
import org.apache.poi.xwpf.usermodel.XWPFDocument; |
|||
import org.apache.poi.xwpf.usermodel.XWPFParagraph; |
|||
import org.apache.poi.xwpf.usermodel.XWPFPictureData; |
|||
import org.apache.poi.xwpf.usermodel.XWPFRun; |
|||
import java.io.*; |
|||
import java.util.ArrayList; |
|||
import java.util.Base64; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
@Component |
|||
public class PdfUtil { |
|||
@Autowired |
|||
private ServerConfig serverConfig; |
|||
public static List<String> picList = new ArrayList<>(); |
|||
public static int picI = 0; |
|||
public String downLoad(String input,String fileName) { |
|||
File file1 = new File(input); |
|||
System.out.println(input); |
|||
String htmlContent = txt2String(file1); |
|||
String docxFilePath = Constants.outPath+ fileName+(new Date()).getTime()+".docx"; |
|||
System.out.println(docxFilePath); |
|||
|
|||
htmlContent = "<p style='line-height:2vw;text-align:center;'>"+fileName +"</p>"+htmlContent; |
|||
// 解析HTML
|
|||
Document doc = Jsoup.parse(htmlContent); |
|||
|
|||
picList = new ArrayList<>(); |
|||
|
|||
Elements paragraphs = doc.select("p"); |
|||
Elements paragraphs1 = doc.select("img"); |
|||
for (Element element : paragraphs1) { |
|||
int start = element.toString().indexOf("src="); |
|||
int end = element.toString().indexOf(">"); |
|||
System.out.println(start); |
|||
System.out.println(end); |
|||
String uu = element.toString().substring(start + 5, end-1); |
|||
picList.add(uu); |
|||
} |
|||
// 解码Base64字符串
|
|||
|
|||
try (XWPFDocument document = new XWPFDocument(); |
|||
FileOutputStream out = new FileOutputStream(docxFilePath)) { |
|||
|
|||
for (Element element : paragraphs) { |
|||
XWPFParagraph paragraph = document.createParagraph(); |
|||
if(!element.equals("<p></p>")){ |
|||
if (element.tagName().equals("p")) { |
|||
String text = element.text(); |
|||
if(!text.equals("")){ |
|||
XWPFRun run = paragraph.createRun(); |
|||
run.setText(text); |
|||
}else{ |
|||
XWPFRun run = paragraph.createRun(); |
|||
if(picList.size()!=0){ |
|||
byte[] imageBytes = Base64.getDecoder().decode(picList.get(0).split(",")[1]); |
|||
int pictureIdx = document.getRelations().size(); |
|||
String picName = "image" + pictureIdx + ".emf"; |
|||
document.addPictureData(imageBytes, 4); |
|||
// 查找图片数据
|
|||
XWPFPictureData foundPictureData = null; |
|||
foundPictureData = document.getAllPictures().get(picI); |
|||
// 插入图片
|
|||
if (foundPictureData != null) { |
|||
System.out.println("----------------------"); |
|||
System.out.println(picList.size()); |
|||
ByteArrayInputStream bais = new ByteArrayInputStream(foundPictureData.getData()); |
|||
run.addPicture(bais, XWPFDocument.PICTURE_TYPE_EMF, picName, Units.toEMU(150), Units.toEMU(150)); |
|||
picList.remove(0); |
|||
picI = picI+1; |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
// 写入文件
|
|||
document.write(out); |
|||
System.out.println(out); |
|||
|
|||
|
|||
File file = new File(docxFilePath); |
|||
MultipartFile cMultiFile = new MockMultipartFile("file", file.getName(), null, new FileInputStream(file)); |
|||
|
|||
String filePath = RuoYiConfig.getUploadPath(); |
|||
// 上传并返回新文件名称
|
|||
String fileName1 = FileUploadUtils.upload(filePath, cMultiFile); |
|||
String url = serverConfig.getUrl() + fileName1; |
|||
|
|||
System.out.println("Document created successfully."); |
|||
|
|||
document.close(); |
|||
return url; |
|||
|
|||
} catch (IOException | InvalidFormatException e) { |
|||
|
|||
e.printStackTrace(); |
|||
return ""; |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
public static String txt2String(File file) { |
|||
StringBuilder result = new StringBuilder(); |
|||
try { |
|||
// 构造一个BufferedReader类来读取文件
|
|||
BufferedReader br = new BufferedReader(new FileReader(file)); |
|||
String s = null; |
|||
// 使用readLine方法,一次读一行
|
|||
while ((s = br.readLine()) != null) { |
|||
result.append(System.lineSeparator() + s); |
|||
} |
|||
br.close(); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return result.toString(); |
|||
} |
|||
|
|||
|
|||
} |
|||
File diff suppressed because it is too large
@ -0,0 +1,263 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<!DOCTYPE mapper |
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.main.woka.Web.Mapper.KcFileMapper"> |
|||
|
|||
<resultMap type="com.main.woka.Common.util.KcInfo" id="KcInfoResult"> |
|||
<result property="id" column="id"/> |
|||
<result property="type" column="type"/> |
|||
<result property="name" column="name"/> |
|||
<result property="twUrl" column="tw_url"/> |
|||
<result property="spUrl" column="sp_url"/> |
|||
<result property="dwUrl" column="dw_url"/> |
|||
<result property="jsInfo" column="js_info"/> |
|||
<result property="parentId" column="parent_id"/> |
|||
<result property="createTime" column="create_time"/> |
|||
<result property="createBy" column="create_by"/> |
|||
<result property="updateTime" column="update_time"/> |
|||
<result property="updateBy" column="update_by"/> |
|||
<result property="isGraph" column="is_graph"/> |
|||
<result property="fileId" column="file_id"/> |
|||
<result property="level" column="level"/> |
|||
<result property="groupId" column="group_id"/> |
|||
</resultMap> |
|||
|
|||
<resultMap id="KcTlFileResult" type="com.main.woka.Common.util.KcTlFile"> |
|||
<result property="id" column="id"/> |
|||
<result property="fileUrl" column="file_url"/> |
|||
<result property="createTime" column="create_time"/> |
|||
<result property="updateTime" column="update_time"/> |
|||
<result property="createBy" column="create_by"/> |
|||
<result property="updateBy" column="update_by"/> |
|||
|
|||
</resultMap> |
|||
|
|||
|
|||
|
|||
|
|||
<select id="selectAllDoc" resultMap="KcInfoResult"> select * from kc_info where is_graph = 0</select> |
|||
<select id="selectAllDocOver" resultMap="KcInfoResult"> |
|||
select * from kc_info where is_graph = 1 |
|||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if> |
|||
</select> |
|||
|
|||
|
|||
<select id="selectAllDocByfileId" resultMap="KcInfoResult"> |
|||
select * from kc_info where is_graph = 0 and file_id = #{fileId} |
|||
</select> |
|||
<select id="selectAllDocList" resultMap="KcInfoResult"> select * from kc_info</select> |
|||
|
|||
<select id="selectAllDocListP" resultMap="KcInfoResult"> select * from kc_info where level = #{level}</select> |
|||
|
|||
|
|||
|
|||
<insert id="insertDoc" parameterType="com.main.woka.Common.util.KcInfo" useGeneratedKeys="true" keyProperty="id"> |
|||
insert into kcfz.kc_info |
|||
<trim prefix="(" suffix=")" suffixOverrides=","> |
|||
<if test="type != null">type,</if> |
|||
<if test="name != null">name,</if> |
|||
<if test="twUrl != null">tw_url,</if> |
|||
<if test="spUrl != null">sp_url,</if> |
|||
<if test="dwUrl != null">dw_url,</if> |
|||
<if test="jsInfo != null">js_info,</if> |
|||
<if test="parentId != null">parent_id,</if> |
|||
<if test="createTime != null">create_time,</if> |
|||
<if test="updateTime != null">update_time,</if> |
|||
<if test="createBy != null">create_by,</if> |
|||
<if test="updateBy != null">update_by,</if> |
|||
<if test="isGraph != null">is_graph,</if> |
|||
<if test="fileId != null">file_id,</if> |
|||
<if test="level != null">level,</if> |
|||
</trim> |
|||
<trim prefix="values (" suffix=")" suffixOverrides=","> |
|||
<if test="type != null">#{type},</if> |
|||
<if test="name != null and name != ''">#{name},</if> |
|||
<if test="twUrl != null">#{twUrl},</if> |
|||
<if test="spUrl != null">#{spUrl},</if> |
|||
<if test="dwUrl != null">#{dwUrl},</if> |
|||
<if test="jsInfo != null">#{jsInfo},</if> |
|||
<if test="parentId != null">#{parentId},</if> |
|||
<if test="createTime != null">#{createTime},</if> |
|||
<if test="updateTime != null">#{updateTime},</if> |
|||
<if test="createBy != null">#{createBy},</if> |
|||
<if test="updateBy != null">#{updateBy},</if> |
|||
<if test="isGraph != null">#{isGraph},</if> |
|||
<if test="fileId != null">#{fileId},</if> |
|||
<if test="level != null">#{level},</if> |
|||
</trim> |
|||
</insert> |
|||
|
|||
<update id="updateparentId" > |
|||
<foreach collection="list" item="item" index="index" separator=";"> |
|||
update kc_info |
|||
set parent_id = #{item.parentId} |
|||
where name = #{item.name} |
|||
and level = #{item.level} |
|||
</foreach> |
|||
</update> |
|||
|
|||
<!-- <update id="updateDocById" >--> |
|||
<!-- update kc_info--> |
|||
<!-- set doc_title = #{docTitle} , doc_url = #{docUrl},--> |
|||
<!-- where id = #{id}--> |
|||
<!-- </update>--> |
|||
|
|||
<update id="updateDocById" parameterType="com.main.woka.Common.util.KcInfo"> |
|||
update kc_info |
|||
<set> |
|||
<if test="name != null and name != ''">name = #{name},</if> |
|||
<if test="twUrl != null and twUrl != ''">tw_url = #{twUrl},</if> |
|||
<if test="spUrl != null and spUrl != ''">sp_url = #{spUrl},</if> |
|||
<if test="jsInfo != null and jsInfo != ''">js_info = #{jsInfo},</if> |
|||
<if test="parentId != null">parent_id = #{parentId},</if> |
|||
<if test="level != null">level = #{level},</if> |
|||
update_time = sysdate() |
|||
</set> |
|||
where id = #{id} |
|||
</update> |
|||
|
|||
<update id="updateParentId2" > |
|||
update kc_info |
|||
set parent_id = #{parentId},group_id=#{groupId} |
|||
where name = #{name} |
|||
and level = #{level} |
|||
</update> |
|||
|
|||
<update id="updateParentId1" > |
|||
update kc_info |
|||
set parent_id = #{parentId} |
|||
where name = #{name} |
|||
and level = #{level} |
|||
</update> |
|||
|
|||
<insert id="insertDocList" parameterType="java.util.List"> |
|||
INSERT INTO kcfz.kc_info |
|||
(file_id,name,level,tw_url) |
|||
VALUES |
|||
<foreach collection="list" separator="," item="item"> |
|||
(#{item.fileId},#{item.name},#{item.level},#{item.twUrl}) |
|||
</foreach> |
|||
</insert> |
|||
|
|||
|
|||
|
|||
<select id="selectDoc" resultMap="KcInfoResult"> |
|||
select * |
|||
from kc_info |
|||
where |
|||
level = #{level} and |
|||
tw_url = #{twUrl} |
|||
</select> |
|||
|
|||
|
|||
<select id="selectDocByURL" resultMap="KcInfoResult"> |
|||
select * |
|||
from kc_info |
|||
where tw_url = #{twUrl} |
|||
</select> |
|||
|
|||
<select id="selectDocById" resultMap="KcInfoResult"> |
|||
select * |
|||
from kc_info |
|||
where id = #{id} |
|||
</select> |
|||
|
|||
<select id="selectDocByIdId" resultMap="KcInfoResult"> |
|||
select * |
|||
from kc_info |
|||
where id = #{id} |
|||
</select> |
|||
|
|||
|
|||
<!-- 获取第一级标题 --> |
|||
<select id="getOneHeader" resultMap="KcInfoResult"> |
|||
select * |
|||
from kc_info |
|||
where parent_id = #{parentId} |
|||
</select> |
|||
|
|||
|
|||
|
|||
<select id="getHeaderByLevel" resultMap="KcInfoResult"> |
|||
select * |
|||
from kc_info |
|||
where level = #{param1} and file_id = #{param2} |
|||
</select> |
|||
|
|||
<select id="getFileList" resultMap="KcTlFileResult"> |
|||
select * from kc_tl_file order by id DESC limit 1 |
|||
</select> |
|||
|
|||
<select id="getFileList1" resultMap="KcTlFileResult"> |
|||
select * from kc_tl_file |
|||
</select> |
|||
|
|||
|
|||
|
|||
<select id="selectAllDocByPLeve" resultMap="KcInfoResult"> |
|||
select * |
|||
from kc_info where parent_id = #{parentId} |
|||
</select> |
|||
|
|||
|
|||
<select id="selectAllDocByPLeve1" resultMap="KcInfoResult"> |
|||
select * |
|||
from kc_info where name like concat('%', #{name}, '%') |
|||
</select> |
|||
|
|||
|
|||
|
|||
<select id="getFileById" resultMap="KcTlFileResult"> |
|||
select * from kc_tl_file where id = #{param1} |
|||
</select> |
|||
|
|||
<select id="getDocByFileId" resultMap="KcInfoResult"> |
|||
select * from kc_info where file_id = #{param1} |
|||
</select> |
|||
<select id="getDocByFileIdNew" resultMap="KcInfoResult"> |
|||
select * from kc_info where file_id = #{fileId} |
|||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if> |
|||
|
|||
</select> |
|||
<delete id="deleteTxtById"> |
|||
delete from kc_info where id = #{param1} |
|||
</delete> |
|||
<select id="selectDocByUrl" parameterType="java.util.List" resultMap="KcInfoResult"> |
|||
select * from kc_info where tw_url in ( |
|||
<foreach collection="list" separator="," item="item"> |
|||
#{item} |
|||
</foreach> |
|||
) |
|||
</select> |
|||
|
|||
|
|||
<update id="updateGraphStatus" > |
|||
update kc_info |
|||
set is_graph = 1 |
|||
where id = #{id} |
|||
</update> |
|||
|
|||
|
|||
|
|||
<update id="updateGraphRelation" > |
|||
update kc_relation |
|||
set is_graph = 1 |
|||
where id = #{id} |
|||
</update> |
|||
|
|||
|
|||
<select id="selectDocUrl" resultMap="KcInfoResult"> |
|||
select * |
|||
from kc_info |
|||
where tw_url = #{twUrl} |
|||
</select> |
|||
|
|||
<update id="updateDownLoadUrl"> |
|||
update kc_info |
|||
set download_url = #{downloadUrl} |
|||
where id = #{id} |
|||
</update> |
|||
|
|||
</mapper> |
|||
@ -0,0 +1,116 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<!DOCTYPE mapper |
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.main.woka.Web.Mapper.KcInfoRelationMapper"> |
|||
|
|||
<resultMap type="com.main.woka.Common.util.KcInfoRelation" id="KcInfoRelationResult"> |
|||
<result property="id" column="id"/> |
|||
<result property="sourceId" column="source_id"/> |
|||
<result property="targetId" column="target_id"/> |
|||
<result property="relation" column="relation"/> |
|||
<result property="sourceName" column="source_name"/> |
|||
<result property="targetName" column="target_name"/> |
|||
<result property="isGraph" column="is_graph"/> |
|||
</resultMap> |
|||
|
|||
|
|||
<insert id="insertDocRelation" parameterType="com.main.woka.Common.util.KcInfoRelation" useGeneratedKeys="true" |
|||
keyProperty="id"> |
|||
insert into kc_relation |
|||
<trim prefix="(" suffix=")" suffixOverrides=","> |
|||
<if test="relation != null">relation,</if> |
|||
<if test="sourceId != null">source_id,</if> |
|||
<if test="targetId != null">target_id,</if> |
|||
|
|||
</trim> |
|||
<trim prefix="values (" suffix=")" suffixOverrides=","> |
|||
<if test="relation != null and relation != ''">#{relation},</if> |
|||
<if test="sourceId != null">#{sourceId},</if> |
|||
<if test="targetId != null">#{targetId},</if> |
|||
</trim> |
|||
</insert> |
|||
|
|||
<select id="getAllRelation" resultMap="KcInfoRelationResult"> select * |
|||
from kc_relation where is_graph = 0</select> |
|||
|
|||
|
|||
<insert id="insertFile" parameterType="com.main.woka.Common.util.KcTlFile" useGeneratedKeys="true" keyProperty="id"> |
|||
INSERT INTO kc_tl_file (file_url, create_time,update_time, create_by, update_by,file_name) |
|||
VALUES ( |
|||
|
|||
#{fileUrl,jdbcType=VARCHAR}, |
|||
#{createTime,jdbcType=TIMESTAMP}, |
|||
#{updateTime,jdbcType=TIMESTAMP}, |
|||
#{createBy,jdbcType=BIGINT}, |
|||
#{updateBy,jdbcType=BIGINT}, |
|||
#{fileName,jdbcType=VARCHAR} |
|||
) |
|||
</insert> |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
<sql id="selectKcRelationshipVo"> |
|||
select id, source_id, target_id, relation, source_name, target_name,is_graph |
|||
from kc_relation </sql> |
|||
|
|||
<select id="selectKcRelationshipList" parameterType="com.main.woka.Common.util.KcInfoRelation" resultMap="KcInfoRelationResult"> |
|||
<include refid="selectKcRelationshipVo"/> |
|||
<where> |
|||
<if test="relation != null and relation != ''"> and relation = #{relation}</if> |
|||
<if test="sourceId != null "> and sourceId = #{sourceId}</if> |
|||
<if test="targetId != null "> and targetId = #{targetId}</if> |
|||
<if test="sourceName != null and sourceName != ''"> and sourceName = #{sourceName}</if> |
|||
<if test="targetName != null and targetName != ''"> and targetName = #{targetName}</if> |
|||
<if test="isGraph != null "> and isGraph = #{isGraph}</if> |
|||
</where> |
|||
</select> |
|||
<select id="selectKcRelationshipById" parameterType="Long" resultMap="KcInfoRelationResult"> |
|||
<include refid="selectKcRelationshipVo"/> |
|||
where id = #{id} |
|||
</select> |
|||
<insert id="insertKcRelationship" parameterType="com.main.woka.Common.util.KcInfoRelation" useGeneratedKeys="true" keyProperty="id"> |
|||
insert into kc_relation |
|||
<trim prefix="(" suffix=")" suffixOverrides=","> |
|||
<if test="relation != null and relation != ''">relation,</if> |
|||
<if test="sourceId != null">source_id,</if> |
|||
<if test="targetId != null">target_id,</if> |
|||
<if test="sourceName != null and sourceName != ''">source_name,</if> |
|||
<if test="targetName != null and targetName != ''">target_name,</if> |
|||
<if test="isGraph != null">is_graph,</if> |
|||
</trim> |
|||
<trim prefix="values (" suffix=")" suffixOverrides=","> |
|||
<if test="relation != null and relation != ''">#{relation},</if> |
|||
<if test="sourceId != null">#{sourceId},</if> |
|||
<if test="targetId != null">#{targetId},</if> |
|||
<if test="sourceName != null and sourceName != ''">#{sourceName},</if> |
|||
<if test="targetName != null and targetName != ''">#{targetName},</if> |
|||
<if test="isGraph != null">#{isGraph},</if> |
|||
</trim> |
|||
</insert> |
|||
<update id="updateKcRelationship" parameterType="com.main.woka.Common.util.KcInfoRelation"> |
|||
update kc_relation |
|||
<trim prefix="SET" suffixOverrides=","> |
|||
<if test="relation != null and relation != ''">relation = #{relation},</if> |
|||
<if test="sourceId != null">source_id = #{sourceId},</if> |
|||
<if test="targetId != null">targe_id = #{targetId},</if> |
|||
<if test="isGraph != null">is_graph = #{isGraph},</if> |
|||
</trim> |
|||
where id = #{id} |
|||
</update> |
|||
<delete id="deleteKcRelationshipById" parameterType="Long"> delete from kc_relation where id = #{id} </delete> |
|||
<delete id="deleteKcRelationshipByIds" parameterType="String"> |
|||
delete from kc_relation where id in |
|||
<foreach item="id" collection="array" open="(" separator="," close=")"> #{id} </foreach> |
|||
</delete> |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
</mapper> |
|||
Loading…
Reference in new issue