main
HuangHai 2 months ago
parent 637dd7f484
commit 52a6704106

@ -1,176 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>SQL Data Lineage Visualization</title>
<script src="https://d3js.org/d3.v7.min.js"></script>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
<style>
.node rect {
stroke: #333;
fill: #f8f8f8;
stroke-width: 1.5px;
rx: 5;
ry: 5;
}
.node text {
font-size: 12px;
fill: #333;
}
.link {
stroke: #666;
stroke-opacity: 0.8;
stroke-width: 2px;
}
.arrow {
fill: #666;
}
.title {
color: #333;
font-size: 20px;
margin-bottom: 20px;
}
</style>
.node text {
font-size: 12px;
}
.link {
stroke: #999;
stroke-opacity: 0.6;
stroke-width: 2px;
}
.arrow {
fill: #999;
stroke-opacity: 0.6;
}
.title {
font-size: 18px;
font-weight: bold;
margin-bottom: 20px;
}
</style>
</head>
<body>
<div class="title">SQL Data Lineage Visualization</div>
<div id="lineage"></div>
<script>
const data = {
nodes: [
{ id: "t_sys_loginperson", name: "t_sys_loginperson", columns: ["person_id", "person_name", "mz", "xb"] },
{ id: "t_dm_mz", name: "t_dm_mz", columns: ["mz_id", "mz_name"] },
{ id: "t_dm_xb", name: "t_dm_xb", columns: ["xb_id", "xb_name"] },
{ id: "result", name: "Result", columns: ["person_id", "person_name", "mz", "mz_name", "xb", "xb_name"] }
],
links: [
{ source: "t_sys_loginperson", target: "result", columns: ["person_id", "person_name", "mz", "xb"] },
{ source: "t_dm_mz", target: "result", columns: ["mz_name"], join: "t_sys_loginperson.mz = t_dm_mz.mz_id" },
{ source: "t_dm_xb", target: "result", columns: ["xb_name"], join: "t_sys_loginperson.xb = t_dm_xb.xb_id" }
]
};
const width = 800;
const height = 500;
const svg = d3.select("#lineage")
.append("svg")
.attr("width", width)
.attr("height", height);
const simulation = d3.forceSimulation(data.nodes)
.force("link", d3.forceLink(data.links).id(d => d.id).distance(150))
.force("charge", d3.forceManyBody().strength(-500))
.force("center", d3.forceCenter(width / 2, height / 2));
const link = svg.append("g")
.selectAll("line")
.data(data.links)
.enter().append("line")
.attr("class", "link")
.attr("marker-end", "url(#arrow)");
const node = svg.append("g")
.selectAll("g")
.data(data.nodes)
.enter().append("g")
.call(d3.drag()
.on("start", dragstarted)
.on("drag", dragged)
.on("end", dragended));
node.append("rect")
.attr("width", d => Math.max(120, d.name.length * 8))
.attr("height", d => 40 + d.columns.length * 20)
.attr("rx", 5)
.attr("ry", 5);
node.append("text")
.attr("x", 10)
.attr("y", 20)
.attr("font-weight", "bold")
.text(d => d.name);
data.nodes.forEach(d => {
const columnGroup = node.append("g")
.attr("transform", `translate(10, 30)`);
d.columns.forEach((col, i) => {
columnGroup.append("text")
.attr("x", 0)
.attr("y", 20 + i * 20)
.text(col);
});
});
svg.append("defs").append("marker")
.attr("id", "arrow")
.attr("viewBox", "0 -5 10 10")
.attr("refX", 25)
.attr("refY", 0)
.attr("markerWidth", 6)
.attr("markerHeight", 6)
.attr("orient", "auto")
.append("path")
.attr("class", "arrow")
.attr("d", "M0,-5L10,0L0,5");
simulation.on("tick", () => {
link
.attr("x1", d => d.source.x)
.attr("y1", d => d.source.y)
.attr("x2", d => d.target.x)
.attr("y2", d => d.target.y);
node.attr("transform", d => `translate(${d.x - Math.max(120, d.name.length * 8) / 2},${d.y - (40 + d.columns.length * 20) / 2})`);
});
function dragstarted(event, d) {
if (!event.active) simulation.alphaTarget(0.3).restart();
d.fx = d.x;
d.fy = d.y;
}
function dragged(event, d) {
d.fx = event.x;
d.fy = event.y;
}
function dragended(event, d) {
if (!event.active) simulation.alphaTarget(0);
d.fx = null;
d.fy = null;
}
node.on("mouseover", function() {
d3.select(this).select("rect")
.style("fill", "#e6f7ff");
}).on("mouseout", function() {
d3.select(this).select("rect")
.style("fill", "#f8f8f8");
});
</script>
</body>
</html>

@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONArray;
import com.jfinal.kit.PathKit;
import org.apache.commons.codec.digest.DigestUtils;
import java.io.File;
import java.net.URI;
import java.net.http.HttpClient;
@ -107,8 +108,8 @@ public class CallDeepSeek {
// 流结束后的处理
String htmlContent = fullResponse.toString();
if (htmlContent.contains("<!DOCTYPE html>") && htmlContent.contains("</html>")) {
FileUtil.writeString(htmlContent, new File("C:\\1.html"), "UTF-8");
listener.onComplete("HTML已成功保存到C:\\1.html");
FileUtil.writeString(htmlContent, new File(outputPath), "UTF-8");
listener.onComplete("HTML已成功保存到" + outputPath);
} else {
listener.onError("最终返回内容不是有效的HTML: " + htmlContent.substring(0, Math.min(htmlContent.length(), 200)) + "...");
}
@ -130,11 +131,13 @@ public class CallDeepSeek {
}).start();
}
public static String outputPath;
public static void main(String[] args) {
String sqlContent = FileUtil.readString("XueYuan.sql", CharsetUtil.CHARSET_UTF_8);
String md5 = DigestUtils.md5Hex(sqlContent);
String outputPath = "C:\\" + md5 + ".html";
outputPath = "C:\\" + md5 + ".html";
File outputFile = new File(outputPath);
if (outputFile.exists()) {

@ -1,3 +1,9 @@
select tsl.person_id,tsl.person_name,tsl.mz,tdm.mz_name,tsl.xb,tdx.xb_name from t_sys_loginperson as tsl
inner join t_dm_mz as tdm on tsl.mz=tdm.mz_id
inner join t_dm_xb as tdx on tsl.xb=tdx.xb_id;
select tsl.person_id,tsl.person_name,tsl.mz,tdm.mz_name,tsl.xb,tdx.xb_name,tsl.bureau_id,
tbo.org_name as bureau_name from t_sys_loginperson as tsl
inner join t_dm_mz as tdm on tsl.mz=tdm.mz_id
inner join t_dm_xb as tdx on tsl.xb=tdx.xb_id
inner join t_base_organization as tbo on tsl.bureau_id=tbo.org_id;
select tbc.class_id,tbc.class_name,tbo.bureau_id,tbo.org_name from t_base_class as tbc inner join t_base_organization as tbo on
tbc.bureau_id=tbo.org_id;

@ -1,3 +1,9 @@
select tsl.person_id,tsl.person_name,tsl.mz,tdm.mz_name,tsl.xb,tdx.xb_name from t_sys_loginperson as tsl
inner join t_dm_mz as tdm on tsl.mz=tdm.mz_id
inner join t_dm_xb as tdx on tsl.xb=tdx.xb_id;
select tsl.person_id,tsl.person_name,tsl.mz,tdm.mz_name,tsl.xb,tdx.xb_name,tsl.bureau_id,
tbo.org_name as bureau_name from t_sys_loginperson as tsl
inner join t_dm_mz as tdm on tsl.mz=tdm.mz_id
inner join t_dm_xb as tdx on tsl.xb=tdx.xb_id
inner join t_base_organization as tbo on tsl.bureau_id=tbo.org_id;
select tbc.class_id,tbc.class_name,tbo.bureau_id,tbo.org_name from t_base_class as tbc inner join t_base_organization as tbo on
tbc.bureau_id=tbo.org_id;
Loading…
Cancel
Save