commit 9f3717325b8e822550fb4a4c009bc6575355d0e4
Author: 55007 <55007@maojian>
Date: Tue Jan 7 16:57:05 2025 +0800
知识图谱应用(已弃用)
diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..f7e4a1d
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.project b/.project
new file mode 100644
index 0000000..cdaf1eb
--- /dev/null
+++ b/.project
@@ -0,0 +1,23 @@
+
+
+ crawl_zstp
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+ org.eclipse.m2e.core.maven2Nature
+
+
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..abdea9a
--- /dev/null
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,4 @@
+eclipse.preferences.version=1
+encoding//src/main/java=UTF-8
+encoding//src/main/resources=UTF-8
+encoding/=UTF-8
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..71df522
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,9 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
+org.eclipse.jdt.core.compiler.release=disabled
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..995d5a9
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,254 @@
+
+
+ 4.0.0
+ jar
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.2.4.RELEASE
+
+
+ com.bfd
+ crawl_zstp
+ 0.0.1-SNAPSHOT
+ crawl_zstp
+ crawl_zstp
+
+ 1.8
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+
+
+
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ com.alibaba
+ fastjson
+ 2.0.12
+
+
+ cn.hutool
+ hutool-all
+ 5.8.10
+
+
+ org.elasticsearch
+ elasticsearch
+ 6.0.0
+
+
+ org.elasticsearch.client
+ elasticsearch-rest-client
+ 6.0.0
+
+
+ org.elasticsearch.client
+ elasticsearch-rest-high-level-client
+ 6.0.0
+
+
+ org.elasticsearch.client
+ elasticsearch-rest-client
+
+
+
+
+ org.apache.kafka
+ kafka-clients
+ 2.7.1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ com.squareup.okhttp3
+ okhttp
+ 4.9.3
+
+
+ org.apache.httpcomponents
+ httpclient
+ 4.5.14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ de.codecentric
+ spring-boot-admin-client
+ 2.2.4
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ org.projectlombok
+ lombok
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+ false
+
+
+ true
+
+ lib/
+
+ com.bfd.crawl_zstp.CrawlZstpApplication
+
+
+ config/
+
+
+
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+ ZIP
+
+
+ ${project.groupId}
+ ${project.groupId}
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ copy-lib
+ package
+
+ copy-dependencies
+
+
+ target/lib
+ false
+ false
+ compile
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+
+ resources/
+
+
+
+
+ *.yml
+ *.xml
+ mqConfig/*.xml
+
+
+
+
+
+ maven-resources-plugin
+
+
+ copy-dependencies
+ package
+
+ copy-resources
+
+
+
+ ${project.build.directory}/resources
+
+
+ src/main/resources
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/com/bfd/crawl_zstp/CrawlZstpApplication.java b/src/main/java/com/bfd/crawl_zstp/CrawlZstpApplication.java
new file mode 100644
index 0000000..6dad830
--- /dev/null
+++ b/src/main/java/com/bfd/crawl_zstp/CrawlZstpApplication.java
@@ -0,0 +1,19 @@
+package com.bfd.crawl_zstp;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.ConfigurableApplicationContext;
+
+/**
+ * @author guowei
+ */
+@SpringBootApplication
+public class CrawlZstpApplication {
+ public static void main(String[] args) {
+
+
+ ConfigurableApplicationContext applicationContext = SpringApplication.run(CrawlZstpApplication.class, args);
+ CrawlZstpApplication application = applicationContext.getBean(CrawlZstpApplication.class);
+// application.run();
+ }
+}
diff --git a/src/main/java/com/bfd/crawl_zstp/controller/ApiController.java b/src/main/java/com/bfd/crawl_zstp/controller/ApiController.java
new file mode 100644
index 0000000..0070dc9
--- /dev/null
+++ b/src/main/java/com/bfd/crawl_zstp/controller/ApiController.java
@@ -0,0 +1,36 @@
+package com.bfd.crawl_zstp.controller;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+
+import com.bfd.crawl_zstp.service.DataProcessService;
+import com.bfd.crawl_zstp.util.Config;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author guowei
+ */
+@Slf4j
+@RestController
+@RequestMapping(value = "/tupu")
+@CrossOrigin(origins = "*", maxAge = 3600)
+public class ApiController {
+ @Resource
+ private DataProcessService dataProcessService;
+
+ @RequestMapping(value = "/correlation", method = RequestMethod.POST, produces = "application/json")
+ @ResponseBody
+ public String getchannelitems(@RequestBody JSONObject jsonObject) {
+ log.info("收到请求,"+jsonObject);
+ dataProcessService.process(jsonObject);
+// String author = jsonObject.getString("author");
+// System.out.println(author);
+ return "success";
+ }
+
+}
diff --git a/src/main/java/com/bfd/crawl_zstp/service/DataCorrelationService.java b/src/main/java/com/bfd/crawl_zstp/service/DataCorrelationService.java
new file mode 100644
index 0000000..258d815
--- /dev/null
+++ b/src/main/java/com/bfd/crawl_zstp/service/DataCorrelationService.java
@@ -0,0 +1,12 @@
+package com.bfd.crawl_zstp.service;
+
+import org.springframework.stereotype.Service;
+
+/**
+ * @author guowei
+ */
+@Service
+public interface DataCorrelationService{
+
+ void correlationData(String businessKey);
+}
diff --git a/src/main/java/com/bfd/crawl_zstp/service/DataProcessService.java b/src/main/java/com/bfd/crawl_zstp/service/DataProcessService.java
new file mode 100644
index 0000000..95f9af8
--- /dev/null
+++ b/src/main/java/com/bfd/crawl_zstp/service/DataProcessService.java
@@ -0,0 +1,13 @@
+package com.bfd.crawl_zstp.service;
+
+import com.alibaba.fastjson.JSONObject;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author guowei
+ */
+@Service
+public interface DataProcessService {
+
+ void process(JSONObject businessKey);
+}
diff --git a/src/main/java/com/bfd/crawl_zstp/service/impl/DataCorrelationServiceImpl.java b/src/main/java/com/bfd/crawl_zstp/service/impl/DataCorrelationServiceImpl.java
new file mode 100644
index 0000000..3e279c4
--- /dev/null
+++ b/src/main/java/com/bfd/crawl_zstp/service/impl/DataCorrelationServiceImpl.java
@@ -0,0 +1,332 @@
+package com.bfd.crawl_zstp.service.impl;
+
+import cn.hutool.core.util.IdUtil;
+import cn.hutool.crypto.SecureUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.JSONPath;
+import com.bfd.crawl_zstp.service.DataCorrelationService;
+import com.bfd.crawl_zstp.util.Config;
+import com.bfd.crawl_zstp.util.EsExecPorcess;
+import com.bfd.crawl_zstp.util.EsQueryUtil;
+import com.bfd.crawl_zstp.util.KfkUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author guowei
+ */
+@Service
+@Slf4j
+public class DataCorrelationServiceImpl implements DataCorrelationService {
+
+ @Override
+ @Async
+ public void correlationData(String businessKey) {
+
+ JSONObject atlas = (JSONObject) JSON.toJSON(Config.dataMap.get(businessKey));
+ JSONArray dataList = (JSONArray) JSON.toJSON(Config.dataListMap.get(businessKey));
+ Map appMap = (Map) Config.appMap.get(businessKey);
+ String app_code = (String) appMap.get("app_code");
+ String subject_id = (String) appMap.get("subject_id");
+ System.out.println(atlas);
+ System.out.println("dataList:" + dataList);
+ dataList.forEach(value -> {
+ try {
+ if (value == null || value.equals("null")) {
+ return;
+ }
+ JSONObject result = (JSONObject) value;
+ if (!result.containsKey("pageType")) {
+ log.error("数据组ID --> " + businessKey + ",没有pageType, value --> " + value);
+ return;
+ }
+ String pageType = result.getString("pageType");
+ String from_key = "";
+ if (businessKey.contains("fakeNews")) {
+ log.info("真假新闻数据组");
+ if (pageType.equals("fakeNewsPage") && (atlas.containsKey("storyDetailPage_fakeNewsPage") || atlas.containsKey("fakeNewsPage_storyDetailPage")) ) {
+
+ log.info("找到真假新闻");
+ JSONObject atla_comment = new JSONObject();
+ if (atlas.containsKey("storyDetailPage_fakeNewsPage")) {
+ atla_comment = atlas.getJSONObject("storyDetailPage_fakeNewsPage");
+ }else if (atlas.containsKey("fakeNewsPage_storyDetailPage")) {
+ atla_comment = atlas.getJSONObject("fakeNewsPage_storyDetailPage");
+ }
+ String to_content_comment = atla_comment.getString("to_content");
+ String[] to_split_comment = to_content_comment.split(":");
+ String to_value_comment = to_split_comment[1];
+ String to_comment = (String) JSONPath.eval(result, to_value_comment);
+ String postId = result.getString("postId");
+ if (to_comment.equals("假新闻")) {
+ //水军识别为机器人,更新用户的颜色
+ log.info("真假新闻识别为假新闻,更新帖子的颜色");
+ String ontology_icon = atla_comment.getString("to_ontology_icon");
+ EsQueryUtil.queryOtherNewsFromEs("from_id", postId, ontology_icon);
+ EsQueryUtil.queryOtherNewsFromEs("to_id", postId, ontology_icon);
+ }
+ Map