Skip to content

Commit

Permalink
数据血缘优化,增加screw数据库文档生成插件
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyachao committed Apr 5, 2022
1 parent b942494 commit d29e6e2
Show file tree
Hide file tree
Showing 15 changed files with 228 additions and 60 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ ssh.sh
quick.bat

*-RELEASE/
*-RELEASE.tar
*-RELEASE.tar

doc/*
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- [4.7.15迁移4.7.16](#4715%E8%BF%81%E7%A7%BB4716)
- [4.7.16迁移4.7.17](#4716%E8%BF%81%E7%A7%BB4717)
- [4.7.17迁移4.7.18](#4717%E8%BF%81%E7%A7%BB4718)
- [4.7.18迁移5.0.0](#4718%E8%BF%81%E7%A7%BB500)
- [未完成的功能](#%E6%9C%AA%E5%AE%8C%E6%88%90%E7%9A%84%E5%8A%9F%E8%83%BD)
- [支持的数据源](#%E6%94%AF%E6%8C%81%E7%9A%84%E6%95%B0%E6%8D%AE%E6%BA%90)
- [支持的调度对象](#%E6%94%AF%E6%8C%81%E7%9A%84%E8%B0%83%E5%BA%A6%E5%AF%B9%E8%B1%A1)
Expand Down Expand Up @@ -64,16 +65,16 @@
+ 4.7.18版本全部采用maven管理,并重构quartz源码,4.7.18不可和之前任何历史版本重用
+ 4.7.18为4.x最后一个版本,5.x版本会重构所有代码,自2022-02-06~2022-06-01不进行新功能开发,此段时间会完善使用文档

+ 4.7.17
+ [zdh_web_4.7.17](http://zycblog.cn:8080/zdh/download/4.7.17/zdh_web.tar)
+ [zdh_server_4.7.17](http://zycblog.cn:8080/zdh/download/4.7.17/zdh_server.tar)
+ [zdh_flink_4.7.17](http://zycblog.cn:8080/zdh/download/4.7.17/zdh_flink.tar)

+ 4.7.18
+ [zdh_web_4.7.18](http://zycblog.cn:8080/zdh/download/4.7.18/zdh_web.tar)
+ [zdh_server_4.7.18](http://zycblog.cn:8080/zdh/download/4.7.18/zdh_server.tar)
+ [zdh_flink_4.7.18](http://zycblog.cn:8080/zdh/download/4.7.18/zdh_flink.tar)

+ 5.0.0
+ [zdh_web_5.0.0](http://zycblog.cn:8080/zdh/download/5.0.0/zdh_web.tar)
+ [zdh_server_5.0.0](http://zycblog.cn:8080/zdh/download/5.0.0/zdh_server.tar)
+ [zdh_flink_5.0.0](http://zycblog.cn:8080/zdh/download/5.0.0/zdh_flink.tar)

+ 如果链接失效,可通过邮件方式(见底部)通知作者,作者会通过邮件发送编译包,也可登陆ZDH预览页面下载

# 在线预览
Expand Down Expand Up @@ -502,9 +503,10 @@
+ v5.0.0 优化登录页面背景
+ v5.0.0 appication相关配置文件修改编码为utf-8
+ v5.0.0 增加spark数据源解析
+ v5.0.0 pom增加screw数据库文档生成插件

+ v5.0.0 增加用户黑名单限制【开发中】
+ v5.0.0 增加接口黑名单限制【开发中】
+ v5.0.1 增加用户黑名单限制【开发中】
+ v5.0.1 增加接口黑名单限制【开发中】
+ v5.0.1 权限单独出SDK及分配身份码(身份码和产品id加密解密绑定)【开发中】
+ v5.0.1 数据资产-申请组信息【开发中】
+ v5.0.1 增加HTTP,EMAIL调度对象 【开发中】
Expand Down Expand Up @@ -965,6 +967,8 @@
(id, parent, `text`, `level`, owner, icon, resource_desc, `order`, is_enable, create_time, update_time, url, resource_type, notice_title, event_code, product_code)
VALUES(960132057952948224, '930966518835974144', '新增系统任务', '4', '1', 'fa fa-coffee', '', '7', '1', '2022-04-03 11:02:01', '2022-04-03 11:02:01', 'dispatch_system_task_add', '5', '', '', 'zdh');

alter table blood_source_info add column `input_json` text comment '输入源配置';
alter table blood_source_info add column `output_json` text comment '输出源配置';


# 未完成的功能
Expand Down
1 change: 1 addition & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mvn clean package -Dmaven.test.skip=true
42 changes: 42 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,48 @@
</configuration>
</plugin>

<!-- screws 生成数据库文档 -->
<plugin>
<groupId>cn.smallbun.screw</groupId>
<artifactId>screw-maven-plugin</artifactId>
<version>1.0.5</version>
<dependencies>
<!-- 数据库连接 -->
<!-- <dependency>-->
<!-- <groupId>com.zaxxer</groupId>-->
<!-- <artifactId>HikariCP</artifactId>-->
<!-- <version>3.4.5</version>-->
<!-- </dependency>-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.22</version>
</dependency>
</dependencies>
<configuration>
<!-- 数据库相关配置 -->
<driverClassName>com.mysql.cj.jdbc.Driver</driverClassName>
<jdbcUrl>jdbc:mysql://127.0.0.1:3306/zdh?serverTimezone=GMT%2B8&amp;useSSL=false</jdbcUrl>
<username>zyc</username>
<password>123456</password>
<!-- screw 配置 -->
<fileType>HTML</fileType><!--可选值HTML,WORD,MARKDOWN-->
<title>ZDH数据库文档</title> <!--标题-->
<fileName>ZDH数据库表说明</fileName> <!--文档名称 为空时:将采用[数据库名称-描述-版本号]作为文档名称-->
<description>ZDH数据库文档生成</description> <!--描述-->
<version>${project.version}</version> <!--版本-->
<openOutputDir>false</openOutputDir> <!--打开文件输出目录-->
<produceType>freemarker</produceType> <!--生成模板-->
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

<resources>
Expand Down
3 changes: 3 additions & 0 deletions refash_readme.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
npm config set registry http://registry.npm.taobao.org/
npm i doctoc -g
doctoc README.md
2 changes: 2 additions & 0 deletions release/db/zdh.sql
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ CREATE TABLE `blood_source_info` (
`version` varchar(100) DEFAULT NULL COMMENT 'version',
`owner` varchar(100) DEFAULT NULL COMMENT '拥有者',
`create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',
`output_json` text COMMENT '输出源配置',
`input_json` text COMMENT '输入源配置',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ;
/*!40101 SET character_set_client = @saved_cs_client */;
Expand Down
2 changes: 2 additions & 0 deletions release/db/zdh_v5.0.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ CREATE TABLE `blood_source_info` (
`version` varchar(100) DEFAULT NULL COMMENT 'version',
`owner` varchar(100) DEFAULT NULL COMMENT '拥有者',
`create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',
`output_json` text COMMENT '输出源配置',
`input_json` text COMMENT '输入源配置',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ;
/*!40101 SET character_set_client = @saved_cs_client */;
Expand Down
1 change: 1 addition & 0 deletions screw.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mvn screw:run
51 changes: 22 additions & 29 deletions src/main/java/com/zyc/zdh/controller/ZdhBloodSourceController.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.zyc.zdh.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zyc.zdh.dao.BloodSourceMapper;
Expand Down Expand Up @@ -66,9 +67,7 @@ public String blood_source_list(String input) {

List<Map<String,Object>> rs = jdbcTemplate.queryForList("select max(version) as version from blood_source_info");
if(rs==null || rs.size()<1){
JSONObject jsonObject= new JSONObject();
jsonObject.put("message", "未找到任何血源分析数据");
return jsonObject.toJSONString();
return ReturnInfo.createInfo(RETURN_CODE.FAIL.getCode(), "未找到任何血源分析数据", "未找到任何血源分析数据");
}

String version = rs.get(0).getOrDefault("version", "0").toString();
Expand All @@ -91,6 +90,7 @@ public String blood_source_list(String input) {
inputs.add(bsi.getInput_type()+bsi.getInput());
jsonObject.put("input_type", bsi.getInput_type());
jsonObject.put("input", bsi.getInput());
jsonObject.put("input_md5", bsi.getInput_md5());
jsonArray.add(jsonObject);
}
}
Expand All @@ -101,12 +101,13 @@ public String blood_source_list(String input) {
inputs.add(bsi.getOutput_type()+bsi.getOutput());
jsonObject1.put("input_type", bsi.getOutput_type());
jsonObject1.put("input", bsi.getOutput());
jsonObject1.put("input_md5", bsi.getOutput_md5());
jsonArray.add(jsonObject1);
}
}

}
return jsonArray.toJSONString();
return ReturnInfo.createInfo(RETURN_CODE.SUCCESS.getCode(), "查询成功", jsonArray);
}

/**
Expand All @@ -118,25 +119,29 @@ public String blood_source_list(String input) {
*/
@RequestMapping(value = "/blood_source_detail", method = RequestMethod.POST, produces = "text/html;charset=UTF-8")
@ResponseBody
public String blood_source_detail(String input, String level, String stream_type) {
public String blood_source_detail(String input, String input_md5, String level, String stream_type) {
DAG dag=new DAG();
Map<String, String> source_json = new HashMap<>();
JSONObject jsonObject=new JSONObject();
List<BloodSourceInfo> bloodSourceInfos = bloodSourceMapper.selectAll();
for (BloodSourceInfo bsi: bloodSourceInfos){
if(!StringUtils.isEmpty(bsi.getInput()) && !StringUtils.isEmpty(bsi.getOutput()) && !bsi.getInput().equalsIgnoreCase(bsi.getOutput())){
System.out.println(bsi.getInput()+"====="+bsi.getOutput());
boolean result = dag.addEdge(bsi.getInput(),bsi.getOutput());

boolean result = dag.addEdge(bsi.getInput()+"__-__"+bsi.getInput_md5(),bsi.getOutput()+"__-__"+bsi.getOutput_md5());
source_json.put(bsi.getInput()+"__-__"+bsi.getInput_md5(), bsi.getInput_json());
source_json.put(bsi.getOutput()+"__-__"+bsi.getOutput_md5(), bsi.getOutput_json());
if(!result){
jsonObject.put("result","失败");
return jsonObject.toJSONString();
}
}
}
Set<String> upstreams = (Set<String>)dag.getParent(input);
Set<String> downstreams = (Set<String>)dag.getChildren(input);
Set<String> upstreams = (Set<String>)dag.getParent(input+"__-__"+input_md5);
Set<String> downstreams = (Set<String>)dag.getChildren(input+"__-__"+input_md5);
Map<String,Set<String>> downstream_map = new HashMap<>();
Map<String,Set<String>> upstream_map = new HashMap<>();
downstream_map.put(input, downstreams);
downstream_map.put(input+"__-__"+input_md5, downstreams);
Queue queue=new LinkedList<String>();
queue.addAll(downstreams);
while (!queue.isEmpty()){
Expand All @@ -147,9 +152,9 @@ public String blood_source_detail(String input, String level, String stream_type
}


upstream_map.put(input, upstreams);
upstream_map.put(input+"__-__"+input_md5, upstreams);
Queue queue2=new LinkedList<String>();
queue2.add(input);
queue2.add(input+"__-__"+input_md5);
while (!queue.isEmpty()){
String v = queue.poll().toString();
Set<String> upstreams1 = (Set<String>)dag.getParent(v);
Expand All @@ -162,8 +167,9 @@ public String blood_source_detail(String input, String level, String stream_type

//生成根节点
JSONObject j2=new JSONObject();
j2.put("id", DigestUtils.md5DigestAsHex(input.getBytes()));
j2.put("id", DigestUtils.md5DigestAsHex((input+"__-__"+input_md5).getBytes()));
j2.put("topic", input);
j2.put("source_json", JSON.parseObject(source_json.get(input+"__-__"+input_md5)));
j2.put("background-color", "#C2DFFF");
j2.put("isroot", true);
jsonArray.add(j2);
Expand All @@ -180,7 +186,8 @@ public String blood_source_detail(String input, String level, String stream_type
for(String chilren:downstream_map.get(key)){
JSONObject j3=new JSONObject();
j3.put("id", DigestUtils.md5DigestAsHex(chilren.getBytes()));
j3.put("topic", chilren);
j3.put("topic", chilren.split("__-__")[0]);
j3.put("source_json", JSON.parseObject(source_json.get(chilren)));
j3.put("background-color", color_value);
j3.put("parentid", DigestUtils.md5DigestAsHex(key.getBytes()));
j3.put("direction","right");
Expand All @@ -196,28 +203,14 @@ public String blood_source_detail(String input, String level, String stream_type
for(String upstream: upstream_map.get(key)){
JSONObject j1=new JSONObject();
j1.put("id", DigestUtils.md5DigestAsHex(upstream.getBytes()) );
j1.put("topic", upstream);
j1.put("topic", upstream.split("__-__")[0]);
j1.put("source_json", JSON.parseObject(source_json.get(upstream)));
j1.put("background-color", "#00bb00");
j1.put("parentid", DigestUtils.md5DigestAsHex(key.getBytes()));
j1.put("direction","left");
jsonArray.add(j1);
}
}
// for(String upstream:upstreams){
// JSONObject j1=new JSONObject();
// j1.put("id", DigestUtils.md5DigestAsHex(upstream.getBytes()) );
// j1.put("topic", upstream);
// j1.put("background-color", "#00bb00");
// j1.put("parentid", DigestUtils.md5DigestAsHex(input.getBytes()));
// j1.put("direction","left");
// jsonArray.add(j1);
// }

//JSONObject jsonObject1=a(dag, input, "#C2DFFF");


//System.out.println(jsonObject1.toJSONString());


return jsonArray.toJSONString();
}
Expand Down
46 changes: 46 additions & 0 deletions src/main/java/com/zyc/zdh/entity/BloodSourceInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ public class BloodSourceInfo {
*/
private String output_type;

/**
* 输出源配置
*/
private String output_json;

/**
* 输入源配置
*/
private String input_json;

/**
* @return id
*/
Expand Down Expand Up @@ -244,4 +254,40 @@ public String getOutput_type() {
public void setOutput_type(String output_type) {
this.output_type = output_type;
}

/**
* 获取输出源配置
*
* @return output_json - 输出源配置
*/
public String getOutput_json() {
return output_json;
}

/**
* 设置输出源配置
*
* @param output_json 输出源配置
*/
public void setOutput_json(String output_json) {
this.output_json = output_json;
}

/**
* 获取输入源配置
*
* @return input_json - 输入源配置
*/
public String getInput_json() {
return input_json;
}

/**
* 设置输入源配置
*
* @param input_json 输入源配置
*/
public void setInput_json(String input_json) {
this.input_json = input_json;
}
}
Loading

0 comments on commit d29e6e2

Please sign in to comment.