Compare commits
30 Commits
Author | SHA1 | Date |
---|---|---|
|
9df23e4aa5 | |
|
0b54d0e840 | |
|
b8ff0aefe2 | |
|
b40b5b908a | |
|
5a88b571ae | |
|
e4d2d5db6d | |
|
7a1dfe1f90 | |
|
eb692d1e59 | |
|
7744803e41 | |
|
1a92ed6566 | |
|
eb0bfc5ed6 | |
|
d5aefb1383 | |
|
a0c15e85e6 | |
|
b760cc7927 | |
|
e62a81aca2 | |
|
17f1ec6357 | |
|
df0c5f403f | |
|
ebb669b42c | |
|
42ca5f147d | |
|
dcdf51f4e2 | |
|
9713efaf23 | |
|
ddf83fb546 | |
|
72a263f1b2 | |
|
3a445b42db | |
|
bf25dfba5e | |
|
e35e84dbf7 | |
|
76eca7b3ef | |
|
395c750eed | |
|
072e42f135 | |
|
61067dca43 |
|
@ -7,8 +7,14 @@
|
|||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="etl-common" />
|
||||
<module name="etl-cleaning" />
|
||||
<module name="etl-spike" />
|
||||
<module name="etl-gateway" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
<bytecodeTargetLevel>
|
||||
<module name="ays" target="1.8" />
|
||||
<module name="etl-ays-security" target="1.8" />
|
||||
</bytecodeTargetLevel>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="dataSourceStorageLocal" created-in="IU-241.17011.79">
|
||||
<data-source name="aysData" uuid="06140e5c-6fdb-4f9a-bb2b-176dc64f7745">
|
||||
<database-info product="MySQL" version="8.0.26" jdbc-version="4.2" driver-name="MySQL Connector/J" driver-version="mysql-connector-j-8.2.0 (Revision: 06a1f724497fd81c6a659131fda822c9e5085b6c)" dbms="MYSQL" exact-version="8.0.26" exact-driver-version="8.2">
|
||||
<extra-name-characters>#@</extra-name-characters>
|
||||
<identifier-quote-string>`</identifier-quote-string>
|
||||
</database-info>
|
||||
<case-sensitivity plain-identifiers="exact" quoted-identifiers="exact" />
|
||||
<secret-storage>master_key</secret-storage>
|
||||
<user-name>root</user-name>
|
||||
<schema-mapping>
|
||||
<introspection-scope>
|
||||
<node kind="schema" qname="@" />
|
||||
</introspection-scope>
|
||||
</schema-mapping>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="aysData" uuid="06140e5c-6fdb-4f9a-bb2b-176dc64f7745">
|
||||
<driver-ref>mysql.8</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:mysql://47.101.130.221:3306/etl</jdbc-url>
|
||||
<jdbc-additional-properties>
|
||||
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||
</jdbc-additional-properties>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,2 @@
|
|||
#n:etl
|
||||
!<md> [0, 0, null, null, -2147483648, -2147483648]
|
|
@ -1,10 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/etl-ays/etl-ays-security/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/etl-ays/etl-ays-security/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/etl-ays/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/etl-ays/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/etl-cleaning/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/etl-cleaning/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/etl-common/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/etl-common/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/etl-gateway/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/etl-gateway/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/etl-spike/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/etl-spike/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GitToolBoxProjectSettings">
|
||||
<option name="commitMessageIssueKeyValidationOverride">
|
||||
<BoolValueOverride>
|
||||
<option name="enabled" value="true" />
|
||||
</BoolValueOverride>
|
||||
</option>
|
||||
<option name="commitMessageValidationEnabledOverride">
|
||||
<BoolValueOverride>
|
||||
<option name="enabled" value="true" />
|
||||
</BoolValueOverride>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,9 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="AliAccessStaticViaInstance" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AliDeprecation" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AliEqualsAvoidNull" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="AliMissingOverrideAnnotation" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
</profile>
|
||||
</component>
|
|
@ -5,8 +5,14 @@
|
|||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/etl-cleaning/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="ignoredFiles">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$/etl-ays/pom.xml" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK" />
|
||||
<component name="SuppressionsComponent">
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="arthas.idea.plugin">
|
||||
<option name="selectProjectName" value="" />
|
||||
<option name="redisAddress" value="" />
|
||||
<option name="redisAuth" value="" />
|
||||
<option name="redisCacheKey" value="" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,4 @@
|
|||
<changelist name="在进行签出之前于_2024_6_19_下午6_50_取消提交了更改_[更改]" date="1718794249139" recycled="false" toDelete="true">
|
||||
<option name="PATH" value="$PROJECT_DIR$/.idea/shelf/在进行签出之前于_2024_6_19_下午6_50_取消提交了更改_[更改]/shelved.patch" />
|
||||
<option name="DESCRIPTION" value="在进行签出之前于 2024/6/19 下午6:50 取消提交了更改 [更改]" />
|
||||
</changelist>
|
|
@ -0,0 +1,13 @@
|
|||
Index: etl-common/src/main/java/com/etl/common/util/Test.java
|
||||
IDEA additional info:
|
||||
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
|
||||
<+>package com.etl.common.util;\r\n\r\npublic class Test {\r\n\r\n}\r\n
|
||||
===================================================================
|
||||
diff --git a/etl-common/src/main/java/com/etl/common/util/Test.java b/etl-common/src/main/java/com/etl/common/util/Test.java
|
||||
--- a/etl-common/src/main/java/com/etl/common/util/Test.java
|
||||
+++ b/etl-common/src/main/java/com/etl/common/util/Test.java
|
||||
@@ -3,3 +3,4 @@
|
||||
public class Test {
|
||||
|
||||
}
|
||||
+
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="SqlDialectMappings">
|
||||
<file url="file://$PROJECT_DIR$/etl-cleaning/src/main/java/com/etl/cleaning/server/MysqlServerTest.java" dialect="GenericSQL" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,124 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,33 @@
|
|||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
|
@ -0,0 +1,117 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.etl.cleaning</groupId>
|
||||
<artifactId>etl-cleaning</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>etl-cleaning</name>
|
||||
<description>etl-cleaning</description>
|
||||
<parent>
|
||||
<groupId>com.bwie</groupId>
|
||||
<artifactId>etl-cloud</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<spring-boot.version>2.6.13</spring-boot.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
<version>3.0.5</version>
|
||||
</dependency>
|
||||
<!-- Jedis -->
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
<version>3.7.0</version> <!-- 请检查并使用最新版本 -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.anji-plus</groupId>
|
||||
<artifactId>spring-boot-starter-captcha</artifactId>
|
||||
<version>1.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-jdbc</artifactId>
|
||||
<version>5.3.22</version> <!-- 请根据需要选择合适的版本 -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.29</version> <!-- 请根据需要选择合适的版本 -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bwie</groupId>
|
||||
<artifactId>etl-common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-annotation</artifactId>
|
||||
<version>3.5.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<configuration>
|
||||
<mainClass>com.etl.cleaning.EtlCleaningApplication</mainClass>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>repackage</id>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,18 @@
|
|||
package com.etl.cleaning;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
/**
|
||||
* 数据清洗模块
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.etl.cleaning.mapper")
|
||||
@EnableScheduling
|
||||
public class EtlCleaningApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(EtlCleaningApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.etl.cleaning.config;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* mysql链接数据源测试
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class DatabaseConfig {
|
||||
/**
|
||||
* jdbc路径
|
||||
*/
|
||||
private String url;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* 端口
|
||||
*/
|
||||
private String port;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.etl.cleaning.config;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 分页插件
|
||||
*/
|
||||
@Configuration
|
||||
public class MybatisPlusConfig {
|
||||
/**
|
||||
* 添加分页插件
|
||||
*/
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); // 如果配置多个插件, 切记分页最后添加
|
||||
// 如果有多数据源可以不配具体类型, 否则都建议配上具体的 DbType
|
||||
return interceptor;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.etl.cleaning.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.etl.cleaning.domian.pojo.DataPlace;
|
||||
import com.etl.cleaning.domian.request.TableRequest;
|
||||
import com.etl.cleaning.enums.EnumMsg;
|
||||
import com.etl.cleaning.server.GetTableServerTest;
|
||||
import com.etl.cleaning.service.PlaceService;
|
||||
import com.etl.common.result.Result;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 获取表名控制器
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/dataTable")
|
||||
public class GetTableController {
|
||||
|
||||
|
||||
private final PlaceService placeService;
|
||||
|
||||
public GetTableController(PlaceService placeService) {
|
||||
this.placeService = placeService;
|
||||
}
|
||||
/**
|
||||
* 获取所有表名
|
||||
*
|
||||
* @param tableRequest
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getTableName")
|
||||
public Result getTableName(@RequestBody @Valid TableRequest tableRequest) {
|
||||
LambdaUpdateWrapper<DataPlace> eqed = new LambdaUpdateWrapper<DataPlace>().eq(DataPlace::getName, tableRequest.getName()).or().eq(DataPlace::getTypeId, tableRequest.getTypeId());
|
||||
DataPlace dataPlace = placeService.getOne(eqed);
|
||||
if (dataPlace == null) {
|
||||
throw new RuntimeException("您所选中的数据源不存在");
|
||||
}
|
||||
String dataUrl = dataPlace.getDataUrl();
|
||||
String dataName = dataPlace.getDataName();
|
||||
String password = dataPlace.getPassword();
|
||||
String username = dataPlace.getUsername();
|
||||
String url = EnumMsg.URL_PRE.getMessage() + "://" + dataUrl + "/" + dataName;
|
||||
List<String> tableNames = GetTableServerTest.getTableNames(url, dataName, username, password);
|
||||
return Result.success(tableNames);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package com.etl.cleaning.controller;
|
||||
|
||||
import com.etl.cleaning.domian.request.InsertPlaceRequest;
|
||||
import com.etl.cleaning.domian.request.PlaceRequest;
|
||||
import com.etl.cleaning.service.PlaceService;
|
||||
import com.etl.common.result.Result;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 数据源管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/place")
|
||||
public class PlaceController {
|
||||
private final PlaceService placeService;
|
||||
|
||||
public PlaceController(PlaceService placeService) {
|
||||
this.placeService = placeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据源管理列表展示
|
||||
* @param placeRequest
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/showPlacePage")
|
||||
public Result showPlacePage(@RequestBody PlaceRequest placeRequest){
|
||||
Map<String, Object> stringObjectMap = placeService.showPlacePage(placeRequest);
|
||||
return Result.success(stringObjectMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/delAdd")
|
||||
public Result delAll(@RequestBody List<Long> ids){
|
||||
boolean b = placeService.removeBatchByIds(ids);
|
||||
return Result.success(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试连接
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/testMysql/{id}")
|
||||
public Result testMysql(@PathVariable Long id){
|
||||
String s = placeService.dataTest(id);
|
||||
return Result.success(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加数据源
|
||||
* @param insertPlaceRequest
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/insertData")
|
||||
public Result insertData(@RequestBody @Validated InsertPlaceRequest insertPlaceRequest){
|
||||
Boolean b = placeService.insertDataPlace(insertPlaceRequest);
|
||||
return Result.success(b);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package com.etl.cleaning.controller;
|
||||
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.etl.cleaning.domian.pojo.DataPlace;
|
||||
import com.etl.cleaning.service.PlaceService;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
||||
/**
|
||||
* 导入导出规整
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/poi/excel")
|
||||
public class PoiExcelApi {
|
||||
private final PlaceService placeService;
|
||||
|
||||
public PoiExcelApi(PlaceService placeService){
|
||||
this.placeService=placeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出到指定路径
|
||||
*/
|
||||
@PostMapping("/outPoi")
|
||||
public void outPoi(){
|
||||
//设置文件导出的路径
|
||||
String path = "D://poi/";
|
||||
File file=new File( path );
|
||||
if(!file.isDirectory()){
|
||||
file.mkdirs();
|
||||
}
|
||||
String fileName = path + "User" + System.currentTimeMillis() + ".xlsx";
|
||||
EasyExcel.write(fileName, DataPlace.class).sheet("数据源管理").doWrite(placeService.list());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package com.etl.cleaning.controller;
|
||||
|
||||
|
||||
import com.etl.cleaning.domian.pojo.DataRole;
|
||||
import com.etl.cleaning.service.RoleService;
|
||||
import com.etl.common.result.Result;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 规则表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author test
|
||||
* @since 2024-06-30
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/data-role")
|
||||
public class RoleController {
|
||||
private final RoleService roleService;
|
||||
|
||||
public RoleController(RoleService roleService) {
|
||||
this.roleService = roleService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加规则
|
||||
* @param dataRole
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/insertRole")
|
||||
public Result insertRole(@RequestBody DataRole dataRole){
|
||||
boolean save = roleService.save(dataRole);
|
||||
return Result.success(save);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package com.etl.cleaning.controller;
|
||||
|
||||
|
||||
import com.etl.cleaning.domian.pojo.RoleType;
|
||||
import com.etl.cleaning.service.RoleTypeService;
|
||||
import com.etl.common.result.Result;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 规则类型表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author test
|
||||
* @since 2024-06-30
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/role-type")
|
||||
public class RoleTypeController {
|
||||
private final RoleTypeService roleTypeService;
|
||||
public RoleTypeController(RoleTypeService roleTypeService) {
|
||||
this.roleTypeService = roleTypeService;
|
||||
}
|
||||
/**
|
||||
* 规则类型列表
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/showTypeList")
|
||||
public Result showTypeList(){
|
||||
List<RoleType> list = roleTypeService.list();
|
||||
return Result.success(list);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
package com.etl.cleaning.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.etl.cleaning.domian.pojo.DataTask;
|
||||
import com.etl.cleaning.domian.request.InsertTaskRequest;
|
||||
import com.etl.cleaning.domian.request.TaskRequest;
|
||||
import com.etl.cleaning.mapper.TaskMapper;
|
||||
import com.etl.cleaning.service.TaskService;
|
||||
import com.etl.common.result.Result;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 任务表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author test
|
||||
* @since 2024-06-30
|
||||
*/
|
||||
@Log4j2
|
||||
@RestController
|
||||
@RequestMapping("/data-task")
|
||||
public class TaskController {
|
||||
private final TaskMapper taskMapper;
|
||||
private final TaskService taskService;
|
||||
|
||||
public TaskController(TaskMapper taskMapper, TaskService taskService) {
|
||||
this.taskMapper = taskMapper;
|
||||
this.taskService = taskService;
|
||||
}
|
||||
|
||||
private final ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
/**
|
||||
* 展示任务列表
|
||||
* @param taskRequest
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/showListPage")
|
||||
public Result showListPage(@RequestBody TaskRequest taskRequest){
|
||||
LambdaUpdateWrapper<DataTask> wrapper = new LambdaUpdateWrapper<>();
|
||||
if(taskRequest.getId() != null){
|
||||
wrapper.eq(DataTask::getTaskId, taskRequest.getId());
|
||||
}
|
||||
if(StringUtils.isNotBlank(taskRequest.getUrgentLevel())){
|
||||
wrapper.like(DataTask::getWeight, taskRequest.getUrgentLevel());
|
||||
}
|
||||
Page<DataTask> dataTaskPage = new Page<>(taskRequest.getPageNum(), taskRequest.getPageSize());
|
||||
List<DataTask> records = dataTaskPage.getRecords();
|
||||
long total = dataTaskPage.getTotal();
|
||||
HashMap<String, Object> hashMap = new HashMap<>();
|
||||
hashMap.put("total",total);
|
||||
hashMap.put("data",records);
|
||||
return Result.success(hashMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加任务管理
|
||||
* @param insertTaskRequest
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/insertTask")
|
||||
public Result insertTask(@RequestBody @Validated InsertTaskRequest insertTaskRequest){
|
||||
//获取锁
|
||||
lock.lock();
|
||||
try {
|
||||
DataTask task = taskService.getOne(new LambdaQueryWrapper<DataTask>().eq(DataTask::getTaskName, insertTaskRequest.getTaskName()));
|
||||
if(task != null){
|
||||
throw new RuntimeException("任务名称已存在");
|
||||
}
|
||||
DataTask dataTask = DataTask.builder().taskId(insertTaskRequest.getTaskCode()).taskName(insertTaskRequest.getTaskName())
|
||||
.statue(1L).remark(insertTaskRequest.getRemark()).updateTime(new Date()).build();
|
||||
boolean save = taskService.save(dataTask);
|
||||
return Result.success(save);
|
||||
}catch (Exception e){
|
||||
log.info(e.getMessage());
|
||||
return Result.error();
|
||||
}finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package com.etl.cleaning.controller;
|
||||
|
||||
import com.etl.cleaning.domian.pojo.DateType;
|
||||
import com.etl.cleaning.service.TypeService;
|
||||
import com.etl.common.result.Result;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据源类型
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/type")
|
||||
public class TypeController {
|
||||
private final TypeService typeService;
|
||||
public TypeController(TypeService typeService) {
|
||||
this.typeService = typeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示类型列表
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/showTypeList")
|
||||
public Result showTypeList(){
|
||||
List<DateType> list = typeService.list();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/*
|
||||
测试mysql链接
|
||||
@return
|
||||
*/
|
||||
/*
|
||||
@GetMapping("/testMysql")
|
||||
public Result testMysql(){
|
||||
ServerTest.testDatabaseConnection()
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.etl.cleaning.controller;
|
||||
|
||||
import com.etl.cleaning.domian.request.UserRequest;
|
||||
import com.etl.common.result.Result;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 登录测试(滑块验证码)
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
public class UserController {
|
||||
/**
|
||||
* 登录测试
|
||||
* @param userRequest
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/login")
|
||||
public Result loginUser(@RequestBody UserRequest userRequest){
|
||||
if(!userRequest.getName().equals("admin")){
|
||||
throw new RuntimeException("用户名错误");
|
||||
}
|
||||
if(!userRequest.getPassword().equals("admin")){
|
||||
throw new RuntimeException("密码错误");
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
package com.etl.cleaning.domian.pojo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 数据源管理表
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@TableName("data_place")
|
||||
public class DataPlace {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
@ExcelProperty("主键ID")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 数据源描述
|
||||
*/
|
||||
@ExcelProperty("数据源描述")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ExcelProperty("备注")
|
||||
private String bank;
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@ExcelProperty("修改时间")
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 类型ID
|
||||
*/
|
||||
@ExcelProperty("类型ID")
|
||||
private Long typeId;
|
||||
/**
|
||||
* 链接状态
|
||||
*/
|
||||
@ExcelProperty("/连接状态")
|
||||
private Long statue;
|
||||
/**
|
||||
* 连接类型
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
@ExcelIgnore
|
||||
private String typeName;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@ExcelProperty("用户名")
|
||||
private String username;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@ExcelProperty("密码")
|
||||
private String password;
|
||||
/**
|
||||
* 端口
|
||||
*/
|
||||
@ExcelProperty("端口")
|
||||
private String port;
|
||||
/**
|
||||
* 数据库名称
|
||||
*/
|
||||
@ExcelProperty("数据库")
|
||||
private String dataName;
|
||||
/**
|
||||
* 额外配置
|
||||
*/
|
||||
@ExcelProperty("配置")
|
||||
private String yaml;
|
||||
/**
|
||||
* 链接路径
|
||||
*/
|
||||
@ExcelProperty("路径")
|
||||
private String dataUrl;
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package com.etl.cleaning.domian.pojo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 清洗规则表
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@TableName("data_role")
|
||||
public class DataRole {
|
||||
/**
|
||||
* 规则ID
|
||||
*/
|
||||
private Long roleId;
|
||||
/**
|
||||
* 规则名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* classPath
|
||||
*/
|
||||
private String rolePath;
|
||||
/**
|
||||
* 打开方式
|
||||
*/
|
||||
private String roleManner;
|
||||
/**
|
||||
* 类型关联ID
|
||||
*/
|
||||
private Long typeId;
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
package com.etl.cleaning.domian.pojo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 任务表
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@TableName("data_task")
|
||||
public class DataTask {
|
||||
/**
|
||||
* 主键ID自增
|
||||
*/
|
||||
private Long taskId;
|
||||
/**
|
||||
* 任务名称
|
||||
*/
|
||||
private String taskName;
|
||||
/**
|
||||
* 最后更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 权重
|
||||
*/
|
||||
private String weight;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Long statue;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package com.etl.cleaning.domian.pojo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 数据源类型
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@TableName("data_type")
|
||||
public class DateType {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.etl.cleaning.domian.pojo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 规则类型表
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@TableName("role_type")
|
||||
public class RoleType {
|
||||
/**
|
||||
* id自增
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 规则类型名称
|
||||
*/
|
||||
private String name;
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
package com.etl.cleaning.domian.request;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 添加数据源参数
|
||||
*/
|
||||
@Data
|
||||
public class InsertPlaceRequest {
|
||||
/**
|
||||
* 数据源描述
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String bank;
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 类型ID
|
||||
*/
|
||||
@NotNull(message = "连接类型不能为空")
|
||||
private Long typeId;
|
||||
/**
|
||||
* 链接状态
|
||||
*/
|
||||
private Long statue;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* 端口
|
||||
*/
|
||||
@NotBlank(message = "端口不能为空")
|
||||
private String port;
|
||||
/**
|
||||
* 数据库名称
|
||||
*/
|
||||
private String dataName;
|
||||
/**
|
||||
* 额外配置
|
||||
*/
|
||||
private String yaml;
|
||||
/**
|
||||
* 链接路径
|
||||
*/
|
||||
@NotBlank(message = "连接地址不能为空")
|
||||
private String dataUrl;
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.etl.cleaning.domian.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 添加任务
|
||||
*/
|
||||
@Data
|
||||
public class InsertTaskRequest {
|
||||
/**
|
||||
* 任务名称
|
||||
*/
|
||||
|
||||
@NotBlank(message = "任务名称不能为空")
|
||||
private String taskName;
|
||||
|
||||
/**
|
||||
* 任务编号
|
||||
*/
|
||||
|
||||
@NotNull(message = "任务编号不能为空")
|
||||
private Long taskCode;
|
||||
|
||||
/**
|
||||
* 任务权重
|
||||
*/
|
||||
|
||||
@NotBlank(message = "任务权重不能为空")
|
||||
private String taskWeight;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
||||
@NotBlank(message = "任务备注不能为空")
|
||||
private String remark;
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package com.etl.cleaning.domian.request;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* mysql链接参数
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class MysqlRequest {
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@NotBlank(message = "用户名不能为空")
|
||||
private String itemUsername;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@NotBlank(message = "密码不能为空")
|
||||
private String itemPass;
|
||||
/**
|
||||
* 端口
|
||||
*/
|
||||
@NotBlank(message = "端口号不能为空")
|
||||
private String itemPort;
|
||||
/**
|
||||
* 连接数据库名称
|
||||
*/
|
||||
@NotBlank(message = "数据库名称不能为空")
|
||||
private String itemName;
|
||||
/**
|
||||
* 连接地址
|
||||
*/
|
||||
@NotBlank(message = "链接地址不能为空")
|
||||
private String place;
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.etl.cleaning.domian.request;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 数据源管理查询参数
|
||||
*/
|
||||
@Data
|
||||
public class PlaceRequest {
|
||||
private String bank;
|
||||
private Long typeId;
|
||||
private Integer pageNum;
|
||||
private Integer pageSize;
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.etl.cleaning.domian.request;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* redis链接参数
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class RedisRequest {
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@NotBlank(message = "密码不能为空")
|
||||
private String itemPass;
|
||||
/**
|
||||
* 端口
|
||||
*/
|
||||
@NotNull(message = "端口号不能为空")
|
||||
private Integer port;
|
||||
/**
|
||||
* 连接地址
|
||||
*/
|
||||
@NotBlank(message = "链接地址不能为空")
|
||||
private String host;
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.etl.cleaning.domian.request;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 加载表参数
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TableRequest {
|
||||
/**
|
||||
* 数据源类型ID
|
||||
*/
|
||||
@NotNull(message = "数据源类型ID不能为空")
|
||||
private Long typeId;
|
||||
|
||||
|
||||
/**
|
||||
* 数据源描述
|
||||
*/
|
||||
@NotBlank(message = "数据源描述不能为空")
|
||||
private String name;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.etl.cleaning.domian.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 任务管理列表查询参数
|
||||
*/
|
||||
@Data
|
||||
public class TaskRequest {
|
||||
/**
|
||||
* 配置ID说明
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 紧急程度
|
||||
*/
|
||||
private String urgentLevel;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer statue;
|
||||
private Integer pageNum;
|
||||
private Integer pageSize;
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.etl.cleaning.domian.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 登录参数
|
||||
*/
|
||||
@Data
|
||||
public class UserRequest {
|
||||
private String name;
|
||||
private String password;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.etl.cleaning.domian.response;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 数据源管理返回列表
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class PlaceResponse {
|
||||
/**
|
||||
* 数据源描述
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String bank;
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 链接状态
|
||||
*/
|
||||
private Long statue;
|
||||
/**
|
||||
* 连接类型
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String typeName;
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.etl.cleaning.enums;
|
||||
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 枚举常量类
|
||||
*/
|
||||
@Getter
|
||||
public enum EnumMsg {
|
||||
// 定义一个带有错误码和描述性字符串的枚举常量
|
||||
NO_TYPE(401, "暂无类型"),
|
||||
DRIVER_CLASS_NAME(402,"com.mysql.cj.jdbc.Driver"),
|
||||
URL_PRE(403,"jdbc:mysql");
|
||||
|
||||
private final int code;
|
||||
private final String message;
|
||||
|
||||
EnumMsg(int code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.etl.cleaning.handler;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.etl.common.result.Result;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
/**
|
||||
* 全局异常捕获类
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
@Configuration
|
||||
@Log4j2
|
||||
public class CatchExceptions {
|
||||
@ExceptionHandler(value = RuntimeException.class)
|
||||
public Result<String> catchException(RuntimeException exception) {
|
||||
log.error("请求异常: [{}]",exception.getMessage(),exception);
|
||||
return Result.error(JSONObject.toJSONString(exception.getMessage()));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.etl.cleaning.job;
|
||||
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class Testaa {
|
||||
@Scheduled(fixedRate = 1000)
|
||||
public void test(){
|
||||
System.out.println ("aaaaaaaa");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.etl.cleaning.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.etl.cleaning.domian.pojo.DataPlace;
|
||||
|
||||
/**
|
||||
* 数据源管理
|
||||
*/
|
||||
public interface PlaceMapper extends BaseMapper<DataPlace> {
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.etl.cleaning.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.etl.cleaning.domian.pojo.DataRole;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 规则表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author test
|
||||
* @since 2024-06-30
|
||||
*/
|
||||
public interface RoleMapper extends BaseMapper<DataRole> {
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.etl.cleaning.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.etl.cleaning.domian.pojo.RoleType;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 规则类型表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author test
|
||||
* @since 2024-06-30
|
||||
*/
|
||||
public interface RoleTypeMapper extends BaseMapper<RoleType> {
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.etl.cleaning.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.etl.cleaning.domian.pojo.DataTask;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 任务表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author test
|
||||
* @since 2024-06-30
|
||||
*/
|
||||
public interface TaskMapper extends BaseMapper<DataTask> {
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.etl.cleaning.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.etl.cleaning.domian.pojo.DateType;
|
||||
|
||||
/**
|
||||
* 数据源类型
|
||||
*/
|
||||
public interface TypeMapper extends BaseMapper<DateType> {
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.etl.cleaning.server;
|
||||
|
||||
|
||||
import com.etl.cleaning.enums.EnumMsg;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 获取数据库下的所有表名
|
||||
*/
|
||||
public class GetTableServerTest {
|
||||
public static List<String> getTableNames(String url,String dataName,String username,String password){
|
||||
ArrayList<String> tableNames = new ArrayList<>();
|
||||
Connection connection = null;
|
||||
try {
|
||||
Class.forName(EnumMsg.DRIVER_CLASS_NAME.getMessage());
|
||||
connection = DriverManager.getConnection(url, username, password);
|
||||
DatabaseMetaData metaData = connection.getMetaData();
|
||||
ResultSet tables = metaData.getTables(dataName, null, "%", new String[]{"TABLE"});
|
||||
while (tables.next()){
|
||||
tableNames.add(tables.getString(3));
|
||||
}
|
||||
tables.close();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}finally {
|
||||
// 关闭连接(如果已打开)
|
||||
try {
|
||||
if (connection != null && !connection.isClosed()) {
|
||||
try {
|
||||
connection.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return tableNames;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.etl.cleaning.server;
|
||||
|
||||
import com.etl.cleaning.config.DatabaseConfig;
|
||||
import com.etl.cleaning.enums.EnumMsg;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
||||
|
||||
/**
|
||||
* mysql测试连接
|
||||
*/
|
||||
public class MysqlServerTest {
|
||||
public static String testDatabaseConnection(DatabaseConfig databaseConfig) {
|
||||
try {
|
||||
//创建数据源
|
||||
DriverManagerDataSource dataSource = new DriverManagerDataSource();
|
||||
//设置数据源的驱动类名,URL,用户名,密码
|
||||
dataSource.setDriverClassName(EnumMsg.DRIVER_CLASS_NAME.getMessage());
|
||||
dataSource.setUrl(databaseConfig.getUrl());
|
||||
dataSource.setUsername(databaseConfig.getUsername());
|
||||
dataSource.setPassword(databaseConfig.getPassword());
|
||||
//创建数据源
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
//sql测试
|
||||
jdbcTemplate.execute("select 1");
|
||||
return "ok";
|
||||
}catch (Exception e){
|
||||
//如果发生异常,打印异常信息
|
||||
e.printStackTrace();
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.etl.cleaning.server;
|
||||
|
||||
import com.etl.cleaning.domian.request.RedisRequest;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
/**
|
||||
* redis测试连接
|
||||
*/
|
||||
public class RedisServerTest {
|
||||
public static String testRedisData(RedisRequest redisRequest){
|
||||
try {
|
||||
// 创建Jedis对象(Redis客户端)
|
||||
Jedis jedis = new Jedis(redisRequest.getHost(), redisRequest.getPort());
|
||||
// 如果设置了密码,则进行认证
|
||||
if (redisRequest.getItemPass() != null && !redisRequest.getItemPass().isEmpty()) {
|
||||
jedis.auth(redisRequest.getItemPass());
|
||||
}
|
||||
// 测试连接是否成功,可以执行一个简单的命令,如ping
|
||||
String response = jedis.ping();
|
||||
if ("PONG".equals(response)) {
|
||||
// 连接成功
|
||||
return "ok";
|
||||
} else {
|
||||
// 连接失败或其他错误
|
||||
return "error";
|
||||
}
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return "error";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.etl.cleaning.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.etl.cleaning.domian.pojo.DataPlace;
|
||||
import com.etl.cleaning.domian.request.InsertPlaceRequest;
|
||||
import com.etl.cleaning.domian.request.PlaceRequest;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 数据源管理
|
||||
*/
|
||||
public interface PlaceService extends IService<DataPlace> {
|
||||
/**
|
||||
* 展示数据源管理列表
|
||||
* @param placeRequest
|
||||
* @return
|
||||
*/
|
||||
Map<String,Object> showPlacePage(PlaceRequest placeRequest);
|
||||
|
||||
|
||||
/**
|
||||
* 链接测试
|
||||
* @param id
|
||||
*/
|
||||
String dataTest(Long id);
|
||||
|
||||
/**
|
||||
* 添加数据源
|
||||
* @param insertItemRequest
|
||||
* @return
|
||||
*/
|
||||
Boolean insertDataPlace(InsertPlaceRequest insertItemRequest);
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.etl.cleaning.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.etl.cleaning.domian.pojo.DataRole;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 规则表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author test
|
||||
* @since 2024-06-30
|
||||
*/
|
||||
public interface RoleService extends IService<DataRole> {
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.etl.cleaning.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.etl.cleaning.domian.pojo.RoleType;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 规则类型表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author test
|
||||
* @since 2024-06-30
|
||||
*/
|
||||
public interface RoleTypeService extends IService<RoleType> {
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.etl.cleaning.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.etl.cleaning.domian.pojo.DataTask;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 任务表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author test
|
||||
* @since 2024-06-30
|
||||
*/
|
||||
public interface TaskService extends IService<DataTask> {
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.etl.cleaning.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.etl.cleaning.domian.pojo.DateType;
|
||||
|
||||
/**
|
||||
* 数据源类型
|
||||
*/
|
||||
public interface TypeService extends IService<DateType> {
|
||||
}
|
|
@ -0,0 +1,143 @@
|
|||
package com.etl.cleaning.serviceimpl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.etl.cleaning.config.DatabaseConfig;
|
||||
import com.etl.cleaning.domian.pojo.DataPlace;
|
||||
import com.etl.cleaning.domian.pojo.DateType;
|
||||
import com.etl.cleaning.domian.request.InsertPlaceRequest;
|
||||
import com.etl.cleaning.domian.request.MysqlRequest;
|
||||
import com.etl.cleaning.domian.request.PlaceRequest;
|
||||
import com.etl.cleaning.domian.request.RedisRequest;
|
||||
import com.etl.cleaning.domian.response.PlaceResponse;
|
||||
import com.etl.cleaning.enums.EnumMsg;
|
||||
import com.etl.cleaning.mapper.PlaceMapper;
|
||||
import com.etl.cleaning.server.MysqlServerTest;
|
||||
import com.etl.cleaning.server.RedisServerTest;
|
||||
import com.etl.cleaning.service.PlaceService;
|
||||
import com.etl.cleaning.service.TypeService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 数据源管理
|
||||
*/
|
||||
@Service
|
||||
public class PlaceServiceImpl extends ServiceImpl<PlaceMapper, DataPlace> implements PlaceService {
|
||||
private final TypeService typeService;
|
||||
private final PlaceMapper placeMapper;
|
||||
public PlaceServiceImpl(TypeService typeService, PlaceMapper placeMapper) {
|
||||
this.typeService = typeService;
|
||||
this.placeMapper = placeMapper;
|
||||
}
|
||||
@Override
|
||||
public Map<String,Object> showPlacePage(PlaceRequest placeRequest) {
|
||||
LambdaQueryWrapper<DataPlace> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
if(StringUtils.isNotBlank(placeRequest.getBank())){
|
||||
lambdaQueryWrapper.like(DataPlace::getName, placeRequest.getBank());
|
||||
}
|
||||
if(placeRequest.getTypeId()!=null){
|
||||
lambdaQueryWrapper.eq(DataPlace::getTypeId,placeRequest.getTypeId());
|
||||
}
|
||||
Page<DataPlace> page = new Page<>(placeRequest.getPageNum(), placeRequest.getPageSize());
|
||||
|
||||
Page<DataPlace> dataPlacePage = placeMapper.selectPage(page, lambdaQueryWrapper);
|
||||
|
||||
List<DataPlace> records = dataPlacePage.getRecords();
|
||||
if(CollectionUtils.isEmpty(records)){
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
List<Long> typeIds = records.stream().map(DataPlace::getTypeId).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
List<DateType> dateTypes = typeService.listByIds(typeIds);
|
||||
Map<Long, DateType> typeMap = dateTypes.stream().collect(Collectors.toMap(DateType::getId, Function.identity()));
|
||||
List<PlaceResponse> dataPlaceList = records.stream().map(item -> {
|
||||
Long typeId = item.getTypeId();
|
||||
DateType dateType = typeMap.get(typeId);
|
||||
String typeName = dateType == null ? EnumMsg.NO_TYPE.getMessage() : dateType.getName();
|
||||
return PlaceResponse.builder()
|
||||
.typeName(typeName)
|
||||
.name(item.getName())
|
||||
.bank(item.getBank())
|
||||
.statue(item.getStatue())
|
||||
.updateTime(item.getUpdateTime())
|
||||
.build();
|
||||
}).collect(Collectors.toList());
|
||||
//查询总条数
|
||||
long total = dataPlacePage.getTotal();
|
||||
//查询当前页的总条数
|
||||
long size = dataPlacePage.getSize();
|
||||
//计算得出的总页数
|
||||
long pages = dataPlacePage.getPages();
|
||||
//当前页码
|
||||
long current = dataPlacePage.getCurrent();
|
||||
System.out.println(total);
|
||||
System.out.println(size);
|
||||
System.out.println(pages);
|
||||
System.out.println(current);
|
||||
HashMap<String,Object> map = new HashMap<>();
|
||||
map.put("total", total);
|
||||
map.put("data", dataPlaceList);
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String dataTest(Long id) {
|
||||
DataPlace dataPlace = this.getOne(new LambdaQueryWrapper<DataPlace>().eq(DataPlace::getId, id));
|
||||
if(dataPlace.getTypeId() == 1){
|
||||
MysqlRequest mysqlRequest = MysqlRequest.builder()
|
||||
.place(dataPlace.getDataUrl())
|
||||
.itemPass(dataPlace.getPassword())
|
||||
.itemUsername(dataPlace.getUsername())
|
||||
.itemPort(dataPlace.getPort())
|
||||
.itemName(dataPlace.getDataName())
|
||||
.build();
|
||||
return this.insertItem(mysqlRequest);
|
||||
}
|
||||
if(dataPlace.getTypeId() == 2){
|
||||
RedisRequest redisRequest = RedisRequest.builder()
|
||||
.itemPass(dataPlace.getPassword())
|
||||
.host(dataPlace.getDataUrl())
|
||||
.port(Integer.valueOf(dataPlace.getPort()))
|
||||
.build();
|
||||
return RedisServerTest.testRedisData(redisRequest);
|
||||
}
|
||||
return "redis连接数据源失败";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean insertDataPlace(InsertPlaceRequest insertItemRequest) {
|
||||
DataPlace dataPlace = DataPlace.builder()
|
||||
.dataName(insertItemRequest.getDataName())
|
||||
.password(insertItemRequest.getPassword())
|
||||
.bank(insertItemRequest.getBank())
|
||||
.dataUrl(insertItemRequest.getDataUrl())
|
||||
.port(insertItemRequest.getPort())
|
||||
.username(insertItemRequest.getUsername())
|
||||
.yaml(insertItemRequest.getYaml())
|
||||
.typeId(insertItemRequest.getTypeId())
|
||||
.name(insertItemRequest.getName())
|
||||
.statue(insertItemRequest.getStatue())
|
||||
.updateTime(new Date())
|
||||
.build();
|
||||
return this.save(dataPlace);
|
||||
}
|
||||
|
||||
|
||||
private String insertItem(MysqlRequest mysqlRequest) {
|
||||
//拼接路径 测试mysql数据库连接
|
||||
String url =EnumMsg.URL_PRE.getMessage() + "://" + mysqlRequest.getPlace() + "/" +mysqlRequest.getItemName();
|
||||
DatabaseConfig databaseConfig = DatabaseConfig.builder()
|
||||
.url(url)
|
||||
.port(mysqlRequest.getItemPort())
|
||||
.username(mysqlRequest.getItemUsername())
|
||||
.password(mysqlRequest.getItemPass())
|
||||
.build();
|
||||
return MysqlServerTest.testDatabaseConnection(databaseConfig);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.etl.cleaning.serviceimpl;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.etl.cleaning.domian.pojo.DataRole;
|
||||
import com.etl.cleaning.mapper.RoleMapper;
|
||||
import com.etl.cleaning.service.RoleService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 规则表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author test
|
||||
* @since 2024-06-30
|
||||
*/
|
||||
@Service
|
||||
public class RoleServiceImpl extends ServiceImpl<RoleMapper, DataRole> implements RoleService {
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.etl.cleaning.serviceimpl;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.etl.cleaning.domian.pojo.RoleType;
|
||||
import com.etl.cleaning.mapper.RoleTypeMapper;
|
||||
import com.etl.cleaning.service.RoleTypeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 规则类型表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author test
|
||||
* @since 2024-06-30
|
||||
*/
|
||||
@Service
|
||||
public class RoleTypeServiceImpl extends ServiceImpl<RoleTypeMapper, RoleType> implements RoleTypeService {
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.etl.cleaning.serviceimpl;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.etl.cleaning.domian.pojo.DataTask;
|
||||
import com.etl.cleaning.mapper.TaskMapper;
|
||||
import com.etl.cleaning.service.TaskService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 任务表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author test
|
||||
* @since 2024-06-30
|
||||
*/
|
||||
@Service
|
||||
public class TaskServiceImpl extends ServiceImpl<TaskMapper, DataTask> implements TaskService {
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.etl.cleaning.serviceimpl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.etl.cleaning.domian.pojo.DateType;
|
||||
import com.etl.cleaning.mapper.TypeMapper;
|
||||
import com.etl.cleaning.service.TypeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 数据源类型
|
||||
*/
|
||||
@Service
|
||||
public class TypeServiceImpl extends ServiceImpl<TypeMapper, DateType> implements TypeService {
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
server.port=10001
|
||||
spring.redis.host=47.101.130.221
|
||||
spring.redis.port=6379
|
||||
spring.redis.password=123456
|
||||
mybatis-plus.type-aliases-package=com.etl.cleaning.domain
|
||||
mybatis-plus.mapper-locations=classpath:mapper/*.xml
|
||||
mybatis-plus.configuration.map-underscore-to-camel-case=true
|
||||
logging.level.com.etl.**=debug
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.url=jdbc:mysql://47.101.130.221:3306/etl?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=ays@123
|
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
Binary file not shown.
After Width: | Height: | Size: 42 KiB |
|
@ -0,0 +1,13 @@
|
|||
package com.etl.cleaning.etlcleaning;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class EtlCleaningApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
|
@ -16,6 +16,11 @@
|
|||
<spring-boot.version>2.6.13</spring-boot.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.tess4j</groupId>
|
||||
<artifactId>tess4j</artifactId>
|
||||
|
@ -64,7 +69,6 @@
|
|||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.22</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,5 +1,5 @@
|
|||
#Generated by Maven
|
||||
#Tue Jun 18 19:06:20 CST 2024
|
||||
version=1.0-SNAPSHOT
|
||||
#Wed Jul 10 15:32:05 CST 2024
|
||||
groupId=com.bwie
|
||||
artifactId=etl-common
|
||||
version=1.0-SNAPSHOT
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
com\etl\common\constants\Constants.class
|
||||
com\etl\common\result\PageResult.class
|
||||
com\etl\common\constants\JwtConstants.class
|
||||
com\etl\common\Entity.class
|
||||
com\etl\common\handler\ExceptionHandlers.class
|
||||
com\etl\common\util\JwtUtils.class
|
||||
com\etl\common\util\RequestUtil.class
|
||||
com\etl\common\exception\ServiceException.class
|
||||
com\etl\common\result\ResultBody.class
|
||||
com\etl\common\exception\AllException.class
|
||||
com\etl\common\util\RestTemplateUtil.class
|
||||
com\etl\common\result\Result.class
|
||||
com\etl\common\BaseEntity.class
|
||||
com\etl\common\exception\GlobalException.class
|
||||
com\etl\common\util\RestTemplateConfig.class
|
||||
com\etl\common\constants\TokenConstants.class
|
||||
com\etl\common\util\StringUtils.class
|
|
@ -0,0 +1,17 @@
|
|||
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\result\ResultBody.java
|
||||
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\util\RestTemplateConfig.java
|
||||
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\exception\GlobalException.java
|
||||
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\handler\ExceptionHandlers.java
|
||||
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\BaseEntity.java
|
||||
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\result\Result.java
|
||||
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\constants\TokenConstants.java
|
||||
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\util\JwtUtils.java
|
||||
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\util\RequestUtil.java
|
||||
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\exception\AllException.java
|
||||
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\util\StringUtils.java
|
||||
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\constants\Constants.java
|
||||
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\Entity.java
|
||||
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\result\PageResult.java
|
||||
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\constants\JwtConstants.java
|
||||
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\exception\ServiceException.java
|
||||
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\util\RestTemplateUtil.java
|
|
@ -1,5 +1,4 @@
|
|||
package com.etl.gateway.filters;
|
||||
|
||||
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
||||
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
||||
import org.springframework.core.Ordered;
|
||||
|
@ -7,7 +6,7 @@ import org.springframework.web.server.ServerWebExchange;
|
|||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* @ClassName:
|
||||
// * @ClassName:
|
||||
* @Description:
|
||||
* @Author: dongyan Ma
|
||||
* @Date: 2024/2/28
|
||||
|
|
|
@ -11,7 +11,6 @@ import org.springframework.http.server.reactive.ServerHttpResponse;
|
|||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* @author dongyan Ma
|
||||
* @description: 网关处理工具类
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
|
@ -0,0 +1,154 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.etl</groupId>
|
||||
<artifactId>etl-spike</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>etl-spike</name>
|
||||
<description>etl-spike</description>
|
||||
<parent>
|
||||
<groupId>com.bwie</groupId>
|
||||
<artifactId>etl-cloud</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<spring-boot.version>2.6.13</spring-boot.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-jdbc</artifactId>
|
||||
<version>5.3.22</version> <!-- 请根据需要选择合适的版本 -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.29</version> <!-- 请根据需要选择合适的版本 -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
<version>2.1.3.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.58</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.bwie</groupId>
|
||||
<artifactId>etl-common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-annotation</artifactId>
|
||||
<version>3.5.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!--导出pdf相关-->
|
||||
<dependency>
|
||||
<groupId>com.itextpdf</groupId>
|
||||
<artifactId>itextpdf</artifactId>
|
||||
<version>5.5.10</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.itextpdf</groupId>
|
||||
<artifactId>itext-asian</artifactId>
|
||||
<version>5.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.itextpdf.tool</groupId>
|
||||
<artifactId>xmlworker</artifactId>
|
||||
<version>5.5.11</version>
|
||||
</dependency>
|
||||
<!--处理html相关 -->
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>1.11.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.jklasd</groupId>
|
||||
<artifactId>spring-junit-test</artifactId>
|
||||
<version>2.0.1-RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.redisson</groupId>
|
||||
<artifactId>redisson</artifactId>
|
||||
<version>3.5.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<configuration>
|
||||
<mainClass>com.etl.spike.EtlSpikeApplication</mainClass>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>repackage</id>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,17 @@
|
|||
package com.etl.spike;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.etl.spike.mapper")
|
||||
@EnableScheduling
|
||||
@EnableDiscoveryClient
|
||||
public class EtlSpikeApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(EtlSpikeApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.etl.spike.config;
|
||||
|
||||
import org.springframework.amqp.core.Binding;
|
||||
import org.springframework.amqp.core.DirectExchange;
|
||||
import org.springframework.amqp.core.Exchange;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* mq配置类
|
||||
*/
|
||||
|
||||
@Configuration
|
||||
public class RabbitMqConfig {
|
||||
|
||||
//创建一个普通队列
|
||||
@Bean
|
||||
public Queue createPublicQueue(){
|
||||
return new Queue ("public_queue");
|
||||
}
|
||||
|
||||
|
||||
//创建一个延迟队列
|
||||
@Bean
|
||||
public Queue createDelayQueue(){
|
||||
HashMap<String, Object> map = new HashMap<> ();
|
||||
map.put ("x-message-ttl",60000);
|
||||
map.put ("x-dead-letter-exchange","order_change");
|
||||
map.put ("x-dead-letter-routing-key","public_queue");
|
||||
return new Queue ("delay_queue",true,false,false,map);
|
||||
}
|
||||
|
||||
//创建一个交换机
|
||||
@Bean
|
||||
public Exchange createExchange(){
|
||||
return new DirectExchange ("order_change");
|
||||
}
|
||||
|
||||
//绑定
|
||||
@Bean
|
||||
public Binding createBinding(){
|
||||
return new Binding ("public_queue",Binding.DestinationType.QUEUE,"order_change", "public_queue",null);
|
||||
}
|
||||
|
||||
//绑定
|
||||
@Bean
|
||||
public Binding createDelayBinding(){
|
||||
return new Binding ("delay_queue",Binding.DestinationType.QUEUE,"order_change", "delay_queue",null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.etl.spike.config;
|
||||
|
||||
import org.redisson.Redisson;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.redisson.config.Config;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* redisson配置类
|
||||
*/
|
||||
@Configuration
|
||||
public class RedissonConfig {
|
||||
@Value ("${redisson.address}")
|
||||
private String addressUrl;
|
||||
@Value ("${redisson.password}")
|
||||
private String password;
|
||||
|
||||
|
||||
/**
|
||||
* 单机模式配置
|
||||
*/
|
||||
@Bean
|
||||
public RedissonClient getRedisson(){
|
||||
Config config = new Config ();
|
||||
config.useSingleServer ()
|
||||
.setAddress (addressUrl).setPassword (password)
|
||||
.setReconnectionTimeout (10000)
|
||||
.setRetryInterval (5000)
|
||||
.setTimeout (10000)
|
||||
.setConnectTimeout (10000);
|
||||
return Redisson.create (config);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
package com.etl.spike.config;
|
||||
|
||||
/**
|
||||
* 雪花算法
|
||||
*/
|
||||
public class SnowFlake {
|
||||
/**
|
||||
* 起始的时间戳
|
||||
*/
|
||||
private final static long START_STMP = 1480166465631L;
|
||||
|
||||
/**
|
||||
* 每一部分占用的位数
|
||||
*/
|
||||
private final static long SEQUENCE_BIT = 12; //序列号占用的位数
|
||||
private final static long MACHINE_BIT = 5; //机器标识占用的位数
|
||||
private final static long DATACENTER_BIT = 5;//数据中心占用的位数
|
||||
|
||||
/**
|
||||
* 每一部分的最大值
|
||||
*/
|
||||
//支持的最大数据标识id,结果是31
|
||||
private final static long MAX_DATACENTER_NUM = -1L ^ (-1L << DATACENTER_BIT);
|
||||
//支持的最大机器id,结果是31 (这个移位算法可以很快的计算出几位二进制数所能表示的最大十进制数)
|
||||
private final static long MAX_MACHINE_NUM = -1L ^ (-1L << MACHINE_BIT);
|
||||
// 生成序列的掩码,这里为4095 (0b111111111111=0xfff=4095)
|
||||
private final static long MAX_SEQUENCE = -1L ^ (-1L << SEQUENCE_BIT);
|
||||
|
||||
/**
|
||||
* 每一部分向左的位移
|
||||
*/
|
||||
//机器ID向左移12位
|
||||
private final static long MACHINE_LEFT = SEQUENCE_BIT;
|
||||
//数据标识id向左移17位(12+5)
|
||||
private final static long DATACENTER_LEFT = SEQUENCE_BIT + MACHINE_BIT;
|
||||
//时间截向左移22位(5+5+12)
|
||||
private final static long TIMESTMP_LEFT = DATACENTER_LEFT + DATACENTER_BIT;
|
||||
|
||||
private long datacenterId; //数据中心
|
||||
private long machineId; //机器标识
|
||||
private long sequence = 0L; //序列号
|
||||
private long lastStmp = -1L;//上一次时间戳
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
* @param datacenterId 数据标识Id(0-31)
|
||||
* @param machineId //机器标识Id(0-31)
|
||||
*/
|
||||
public SnowFlake(long datacenterId, long machineId) {
|
||||
if (datacenterId > MAX_DATACENTER_NUM || datacenterId < 0) {
|
||||
throw new IllegalArgumentException("datacenterId can't be greater than MAX_DATACENTER_NUM or less than 0");
|
||||
}
|
||||
if (machineId > MAX_MACHINE_NUM || machineId < 0) {
|
||||
throw new IllegalArgumentException("machineId can't be greater than MAX_MACHINE_NUM or less than 0");
|
||||
}
|
||||
this.datacenterId = datacenterId;
|
||||
this.machineId = machineId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 产生下一个ID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public synchronized long nextId() {
|
||||
//获取当前时间戳
|
||||
long currStmp = getNewstmp();
|
||||
|
||||
//如果当前时间小于上一次ID生成的时间戳,说明系统时钟回退过这个时候应当抛出异常
|
||||
if (currStmp < lastStmp) {
|
||||
throw new RuntimeException("Clock moved backwards. Refusing to generate id");
|
||||
}
|
||||
|
||||
//如果是同一时间生成的,则进行毫秒内序列递增
|
||||
if (currStmp == lastStmp) {
|
||||
//相同毫秒内,序列号自增
|
||||
sequence = (sequence + 1) & MAX_SEQUENCE;
|
||||
//同一毫秒的序列数已经达到最大
|
||||
if (sequence == 0L) {
|
||||
currStmp = getNextMill();
|
||||
}
|
||||
} else {
|
||||
//不同毫秒内,序列号置为0
|
||||
sequence = 0L;
|
||||
}
|
||||
|
||||
lastStmp = currStmp;
|
||||
|
||||
return (currStmp - START_STMP) << TIMESTMP_LEFT //时间戳部分
|
||||
| datacenterId << DATACENTER_LEFT //数据中心部分
|
||||
| machineId << MACHINE_LEFT //机器标识部分
|
||||
| sequence; //序列号部分
|
||||
}
|
||||
|
||||
private long getNextMill() {
|
||||
long mill = getNewstmp();
|
||||
while (mill <= lastStmp) {
|
||||
mill = getNewstmp();
|
||||
}
|
||||
return mill;
|
||||
}
|
||||
|
||||
private long getNewstmp() {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SnowFlake snowFlake = new SnowFlake(2, 5);
|
||||
long start = System.currentTimeMillis();
|
||||
for (int i = 0; i < 1000000; i++) {
|
||||
System.out.println(snowFlake.nextId());
|
||||
}
|
||||
System.out.println((System.currentTimeMillis() - start)/1000 + "秒");
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue