作者 yedais

Initial commit

正在显示 53 个修改的文件 包含 2673 行增加0 行删除
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/
... ...
!SESSION 2024-08-30 12:48:33.221 -----------------------------------------------
eclipse.buildId=4.12.0.202109130635
java.version=16.0.2
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=zh_CN
Framework arguments: -product org.springframework.boot.ide.branding.sts4
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.springframework.boot.ide.branding.sts4
!ENTRY org.eclipse.jface 2 0 2024-08-30 12:49:00.733
!MESSAGE Keybinding conflicts occurred. They may interfere with normal accelerator operation.
!SUBENTRY 1 org.eclipse.jface 2 0 2024-08-30 12:49:00.733
!MESSAGE A conflict occurred for CTRL+SHIFT+T:
Binding(CTRL+SHIFT+T,
ParameterizedCommand(Command(org.eclipse.jdt.ui.navigate.open.type,Open Type,
Open a type in a Java editor,
Category(org.eclipse.ui.category.navigate,Navigate,null,true),
org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@169d1f92,
,,true),null),
org.eclipse.ui.defaultAcceleratorConfiguration,
org.eclipse.ui.contexts.window,,,system)
Binding(CTRL+SHIFT+T,
ParameterizedCommand(Command(org.eclipse.lsp4e.symbolinworkspace,Go to Symbol in Workspace,
,
Category(org.eclipse.lsp4e.category,Language Servers,null,true),
org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@7fcbc336,
,,true),null),
org.eclipse.ui.defaultAcceleratorConfiguration,
org.eclipse.ui.contexts.window,,,system)
!ENTRY org.eclipse.egit.ui 2 0 2024-08-30 12:49:03.524
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
user global configuration and to define the default location to store repositories: 'C:\Users\woshiyedai'. If this is
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
EGit might behave differently since they see different configuration options.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
!ENTRY org.eclipse.ui 2 2 2024-08-30 12:50:50.298
!MESSAGE Invalid property category path: org.springframework.ide.eclipse.beans.ui.properties.ProjectPropertyPage (bundle: org.springframework.ide.eclipse.xml.namespaces, propertyPage: org.springframework.ide.eclipse.beans.ui.namespaces.projectPropertyPage)
!SESSION 2024-08-30 12:50:51.729 -----------------------------------------------
eclipse.buildId=4.12.0.202109130635
java.version=16.0.2
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=zh_CN
Framework arguments: -product org.springframework.boot.ide.branding.sts4
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.springframework.boot.ide.branding.sts4
!ENTRY org.eclipse.jface 2 0 2024-08-30 12:50:56.452
!MESSAGE Keybinding conflicts occurred. They may interfere with normal accelerator operation.
!SUBENTRY 1 org.eclipse.jface 2 0 2024-08-30 12:50:56.452
!MESSAGE A conflict occurred for CTRL+SHIFT+T:
Binding(CTRL+SHIFT+T,
ParameterizedCommand(Command(org.eclipse.jdt.ui.navigate.open.type,Open Type,
Open a type in a Java editor,
Category(org.eclipse.ui.category.navigate,Navigate,null,true),
org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@742dbac8,
,,true),null),
org.eclipse.ui.defaultAcceleratorConfiguration,
org.eclipse.ui.contexts.window,,,system)
Binding(CTRL+SHIFT+T,
ParameterizedCommand(Command(org.eclipse.lsp4e.symbolinworkspace,Go to Symbol in Workspace,
,
Category(org.eclipse.lsp4e.category,Language Servers,null,true),
org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@2ce62e27,
,,true),null),
org.eclipse.ui.defaultAcceleratorConfiguration,
org.eclipse.ui.contexts.window,,,system)
!ENTRY org.eclipse.egit.ui 2 0 2024-08-30 12:50:58.875
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
user global configuration and to define the default location to store repositories: 'C:\Users\woshiyedai'. If this is
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
EGit might behave differently since they see different configuration options.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
!ENTRY org.eclipse.ui 2 2 2024-08-30 12:51:16.694
!MESSAGE Invalid property category path: org.springframework.ide.eclipse.beans.ui.properties.ProjectPropertyPage (bundle: org.springframework.ide.eclipse.xml.namespaces, propertyPage: org.springframework.ide.eclipse.beans.ui.namespaces.projectPropertyPage)
... ...
java
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<typeInfoHistroy/>
... ...
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<qualifiedTypeNameHistroy/>
... ...
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<section name="org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart">
<item key="group_libraries" value="true"/>
<item key="layout" value="2"/>
<item key="rootMode" value="1"/>
<item key="linkWithEditor" value="false"/>
<item key="memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#x0D;&#x0A;&lt;packageExplorer group_libraries=&quot;1&quot; layout=&quot;2&quot; linkWithEditor=&quot;0&quot; rootMode=&quot;1&quot; workingSetName=&quot;&quot;&gt;&#x0D;&#x0A;&lt;customFilters userDefinedPatternsEnabled=&quot;false&quot;&gt;&#x0D;&#x0A;&lt;xmlDefinedFilters&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.StaticsFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.buildship.ui.packageexplorer.filter.gradle.buildfolder&quot; isEnabled=&quot;true&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.NonSharedProjectsFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.internal.ui.PackageExplorer.EmptyInnerPackageFilter&quot; isEnabled=&quot;true&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.m2e.MavenModuleFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.buildship.ui.packageexplorer.filter.gradle.subProject&quot; isEnabled=&quot;true&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.ClosedProjectsFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.EmptyLibraryContainerFilter&quot; isEnabled=&quot;true&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.PackageDeclarationFilter&quot; isEnabled=&quot;true&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.pde.ui.BinaryProjectFilter1&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.LocalTypesFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.pde.ui.ExternalPluginLibrariesFilter1&quot; isEnabled=&quot;true&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.FieldsFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.NonJavaProjectsFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer_patternFilterId_.*&quot; isEnabled=&quot;true&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.SyntheticMembersFilter&quot; isEnabled=&quot;true&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.ContainedLibraryFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.internal.ui.PackageExplorer.HideInnerClassFilesFilter&quot; isEnabled=&quot;true&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.DeprecatedMembersFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.ImportDeclarationFilter&quot; isEnabled=&quot;true&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.NonJavaElementFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.LibraryFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.CuAndClassFileFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.internal.ui.PackageExplorer.EmptyPackageFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;child filterId=&quot;org.eclipse.jdt.ui.PackageExplorer.NonPublicFilter&quot; isEnabled=&quot;false&quot;/&gt;&#x0D;&#x0A;&lt;/xmlDefinedFilters&gt;&#x0D;&#x0A;&lt;/customFilters&gt;&#x0D;&#x0A;&lt;/packageExplorer&gt;"/>
</section>
</section>
... ...
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<section name="MavenProjectImportWizardPage">
<list key="rootDirectory">
<item value="D:\workspace\syncData"/>
</list>
<list key="projectNameTemplate">
<item value="[artifactId]"/>
<item value="[artifactId]-TRUNK"/>
<item value="[artifactId]-[version]"/>
<item value="[groupId].[artifactId]"/>
<item value="[groupId].[artifactId]-[version]"/>
<item value="[name]"/>
</list>
</section>
</section>
... ...
2024-08-30 12:49:03,505 [Worker-6: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is out-of-date. Trying to update.
2024-08-30 12:50:58,854 [Worker-6: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is up-to-date. Trying to read.
... ...
<configuration scan="true">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%date [%thread] %-5level %logger{35} - %msg%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>OFF</level> <!-- change to DEBUG to mimic '-consolelog' behaviour -->
</filter>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${org.eclipse.m2e.log.dir}/0.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<FileNamePattern>${org.eclipse.m2e.log.dir}/%i.log</FileNamePattern>
<MinIndex>1</MinIndex>
<MaxIndex>10</MaxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>100MB</MaxFileSize>
</triggeringPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%date [%thread] %-5level %logger{35} - %msg%n</pattern>
</encoder>
</appender>
<appender name="EclipseLog" class="org.eclipse.m2e.logback.appender.EclipseLogAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>WARN</level>
</filter>
</appender>
<appender name="MavenConsoleLog" class="org.eclipse.m2e.logback.appender.MavenConsoleAppender">
</appender>
<root level="INFO">
<appender-ref ref="FILE" />
<appender-ref ref="STDOUT" />
<appender-ref ref="EclipseLog" />
<appender-ref ref="MavenConsoleLog" />
</root>
<logger name="com.ning.http.client" level="INFO" />
<logger name="net.schmizz" level="OFF" />
</configuration>
... ...
#Cached timestamps
#Fri Aug 30 12:51:16 CST 2024
... ...
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
</section>
... ...
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<list key="installedFeatures">
<item value="com.ianbrandt.tools.m2e.mdp.feature:0.0.4.201409291703"/>
<item value="net.mihai-nita.ansicon:1.4.4.202102080044"/>
<item value="org.eclipse.buildship:3.1.5.v20210113-0929"/>
<item value="org.eclipse.egit.gitflow.feature:5.13.0.202109080827-r"/>
<item value="org.eclipse.egit:5.13.0.202109080827-r"/>
<item value="org.eclipse.emf.common:2.31.0.v20240314-0928"/>
<item value="org.eclipse.emf.ecore:2.37.0.v20240203-0859"/>
<item value="org.eclipse.epp.mpc:1.9.1.v20210204-1408"/>
<item value="org.eclipse.help:2.3.700.v20210906-0500"/>
<item value="org.eclipse.jdt:3.18.900.v20210906-0500"/>
<item value="org.eclipse.jgit.gpg.bc:6.10.0.202406032230-r"/>
<item value="org.eclipse.jgit.http.apache:5.13.0.202109080827-r"/>
<item value="org.eclipse.jgit.lfs:5.13.0.202109080827-r"/>
<item value="org.eclipse.jgit.ssh.apache:5.13.0.202109080827-r"/>
<item value="org.eclipse.jgit:5.13.0.202109080827-r"/>
<item value="org.eclipse.jst.common.fproj.enablement.jdt:3.23.0.v202108200205"/>
<item value="org.eclipse.justj.openjdk.hotspot.jre.full:16.0.2.v20210721-1149"/>
<item value="org.eclipse.m2e.feature:1.18.1.20210618-2246"/>
<item value="org.eclipse.m2e.logback.feature:1.17.1.20210603-1006"/>
<item value="org.eclipse.m2e.wtp.feature:1.4.4.20201128-1705"/>
<item value="org.eclipse.mylyn.wikitext.editors_feature:3.0.39.202102270010"/>
<item value="org.eclipse.pde:3.14.900.v20210906-0500"/>
<item value="org.eclipse.platform:4.21.0.v20210906-0842"/>
<item value="org.eclipse.rcp:4.21.0.v20210906-0842"/>
<item value="org.eclipse.tm.terminal.connector.ssh.feature:10.4.0.202106130052"/>
<item value="org.eclipse.tm.terminal.control.feature:10.4.0.202107100131"/>
<item value="org.eclipse.tm.terminal.feature:10.4.0.202106130052"/>
<item value="org.eclipse.tm.terminal.view.feature:10.4.0.202108241639"/>
<item value="org.eclipse.userstorage:1.2.0.v20210517-0327"/>
<item value="org.eclipse.wst.common.fproj:3.7.3.v202007142017"/>
<item value="org.eclipse.wst.json_ui.feature:1.1.10.v202103121626"/>
<item value="org.eclipse.wst.web_ui.feature:3.23.0.v202107272335"/>
<item value="org.eclipse.wst.xml_ui.feature:3.23.0.v202107101937"/>
<item value="org.jboss.tools.m2e.wro4j.feature:1.1.0.201406251020"/>
<item value="org.jboss.tools.maven.apt.feature:1.5.2.201812241535"/>
<item value="org.sonatype.m2e.buildhelper.feature:0.15.0.201207090124"/>
<item value="org.sonatype.m2e.egit.feature:0.15.1.201806191431"/>
<item value="org.sonatype.m2e.mavenarchiver.feature:0.17.5.202002191804"/>
</list>
<section name="ExternalProjectImportWizard">
</section>
</section>
... ...
<?xml version="1.0" encoding="UTF-8"?>
<section name="Workbench">
<section name="ImportExportAction">
</section>
</section>
... ...
<?xml version="1.0" encoding="UTF-8"?>
<workingSetManager>
<workingSet editPageId="org.eclipse.jdt.internal.ui.DynamicSourcesWorkingSet" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1724993341454_0" label="Java Main Sources" name="Java Main Sources"/>
<workingSet editPageId="org.eclipse.jdt.internal.ui.DynamicSourcesWorkingSet" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1724993341467_1" label="Java Test Sources" name="Java Test Sources"/>
<workingSet aggregate="true" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1724993343206_2" label="Window Working Set" name="Aggregate for window 1724993343206"/>
</workingSetManager>
\ No newline at end of file
... ...
#Fri Aug 30 12:50:55 CST 2024
org.eclipse.core.runtime=2
org.eclipse.platform=4.21.0.v20210906-0500
... ...
<?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>org.yrhl</groupId>
<artifactId>syncData</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>syncData</name>
<description>syncData</description>
<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>
<sqlserver.version>4.0</sqlserver.version>
<mybatisplus.version>3.3.1</mybatisplus.version>
<druid.version>1.2.13</druid.version>
<mysql.version>8.0.18</mysql.version>
<mssql.driver.version>1.3.1</mssql.driver.version>
<mybatis-spring.version>2.2.2</mybatis-spring.version>
<hutool.version>5.1.2</hutool.version>
<knife4j.version>3.0.3</knife4j.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</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>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<!-- AOP begin -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.7.4</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.7.4</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.1</version>
</dependency>
<!-- AOP end -->
<!-- sqlserver驱动 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${druid.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis-spring.version}</version>
</dependency>
<!--mybatis-plus -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatisplus.version}</version>
<exclusions>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<version>${mssql.driver.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>${hutool.version}</version>
</dependency>
<!-- swaggerconf-->
<!-- <dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>${knife4j.version}</version>
</dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<!-- lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatisplus.version}</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>org.yrhl.syncdata.SyncDataApplication</mainClass>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!-- 阿里云maven仓库 -->
<repositories>
<repository>
<id>public</id>
<name>aliyun nexus</name>
<url>https://maven.aliyun.com/repository/public/</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>public</id>
<name>aliyun nexus</name>
<url>https://maven.aliyun.com/repository/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
... ...
package org.yrhl.syncdata.Retention;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 描述:
*
* @author : zzq
* @date : 2024-06-02 12:36
**/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface BatchInsert {
}
... ...
package org.yrhl.syncdata;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@MapperScan("org.yrhl.syncdata.mapper")
public class SyncDataApplication {
public static void main(String[] args) {
SpringApplication.run(SyncDataApplication.class, args);
System.out.println("启动成功");
}
}
... ...
package org.yrhl.syncdata.config;
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import javax.annotation.Resource;
import javax.sql.DataSource;
/**
*
* @date :Created in 2023/12/2 19:51
* @description:本地数据源
* @modified By:
* @version:
*/
@Configuration
@MapperScan(basePackages = "org.yrhl.syncdata.mapper.local", sqlSessionTemplateRef = "sqlSessionTemplate1")
public class MybatisLocalConfig {
@Bean
@ConfigurationProperties(prefix = "spring.datasource.local")
public DataSource dataSource1() {
return DataSourceBuilder.create().build();
}
@Bean
public SqlSessionFactory sqlSessionFactory1(@Qualifier("dataSource1") DataSource dataSource) throws Exception {
MybatisSqlSessionFactoryBean factoryBean = new MybatisSqlSessionFactoryBean();
factoryBean.setDataSource(dataSource);
// 设置mapper.xml文件的位置
factoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath*:localmapper/*.xml"));
return factoryBean.getObject();
}
@Bean
public SqlSessionTemplate sqlSessionTemplate1(@Qualifier("sqlSessionFactory1") SqlSessionFactory sqlSessionFactory) {
return new SqlSessionTemplate(sqlSessionFactory);
}
}
\ No newline at end of file
... ...
package org.yrhl.syncdata.config;
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import javax.annotation.Resource;
import javax.sql.DataSource;
/**
*
* @date :Created in 2023/12/2 19:51
* @description:本地数据源
* @modified By:
* @version:
*/
@Configuration
@MapperScan(basePackages = "org.yrhl.syncdata.mapper.remote", sqlSessionTemplateRef = "sqlSessionTemplate2")
public class MybatisRemoteConfig {
@Bean
@ConfigurationProperties(prefix = "spring.datasource.remote")
public DataSource dataSource2() {
return DataSourceBuilder.create().build();
}
@Bean
public SqlSessionFactory sqlSessionFactory2(@Qualifier("dataSource2") DataSource dataSource) throws Exception {
MybatisSqlSessionFactoryBean factoryBean = new MybatisSqlSessionFactoryBean();
factoryBean.setDataSource(dataSource);
// 设置mapper.xml文件的位置
factoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath*:remotemapper/*.xml"));
return factoryBean.getObject();
}
@Bean
public SqlSessionTemplate sqlSessionTemplate2(@Qualifier("sqlSessionFactory2") SqlSessionFactory sqlSessionFactory) {
return new SqlSessionTemplate(sqlSessionFactory);
}
}
\ No newline at end of file
... ...
package org.yrhl.syncdata.domain;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 一网同步推送结果
*
* @author Mark sunlightcs@gmail.com
* @since 1.0.0 2022-04-25
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("allinonepushresults")
public class AllinonepushresultsEntity extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 租户编码
*/
@TableField(fill = FieldFill.INSERT)
private Long tenantCode;
/**
*
*/
private Long id;
/**
*
*/
private String tenderprojectid;
/**
*
*/
private String module;
/**
*
*/
private String tablename;
/**
*
*/
private String infoid;
/**
*
*/
private Boolean success;
/**
*
*/
private String senddata;
/**
*
*/
private String optype;
/**
*
*/
private Date createtime;
/**
*
*/
private Date updatetime;
/**
*
*/
private String remark;
/**
*
*/
private String tenderflowkey;
private String blockChainHash;
private String blockChainUrl;
private String blockChainTime;
private String blockChainPrev;
private String pushInfo;
private String desData;
private String mqKey;
private String date;
}
... ...
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有,侵权必究!
*/
package org.yrhl.syncdata.domain;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 基础实体类,所有实体都需要继承
*
* @author Mark sunlightcs@gmail.com
*/
@Data
public abstract class BaseEntity implements Serializable {
/**
* id
*/
@JsonSerialize(using = ToStringSerializer.class)
@TableId(value = "id", type = IdType.ID_WORKER)
private Long id;
/**
* 创建者
*/
@TableField(fill = FieldFill.INSERT)
@JsonSerialize(using = ToStringSerializer.class)
private Long creator;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createDate;
}
... ...
package org.yrhl.syncdata.domain;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import java.util.Map;
/**
* 上链入参参数
*
* @author Mark sunlightcs@gmail.com
* @since 1.0.0 2023-06-12
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("block_new_source_data")
public class BlockNewSourceDataEntity extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 平台编码
*/
private String platformCode;
/**
* 系统编码
*/
private String pubServicePlatCode;
/**
* 系统标识码
*/
private String systemCode;
/**
* 上一区块hash
*/
private String blockChainPrev;
/**
* 加密的业务数据
*/
private String data;
/**
* 解密的业务数据
*/
private String desData;
/**
* 回调地址
*/
private String callbackUrl;
/**
* ip地址
*/
private String ip;
/**
* 项目id
*/
private String tenderProjectId;
/**
* 项目业务流程环节
*/
private String module;
/**
* 业务审批唯一标识。若无审批流程则为-1
*/
private String tenderFlowKey;
/**
* 操作类型
*/
private String opType;
/**
* 业务表名称
*/
private String tableName;
/**
* 业务表主键
*/
private String tableInfoId;
/**
* 数据类型(0:存证上链,1:专家抽取合约,2:投标文件校验合约,3:开标时间校验合约)
*/
private String datasType;
public static BlockNewSourceDataEntity fromMap(Map<String, Object> map) {
BlockNewSourceDataEntity entity = new BlockNewSourceDataEntity();
entity.setId(null== map.get("id")?null:(Long) map.get("id"));
entity.setPlatformCode(null==map.get("platform_code")?null:(String) map.get("platform_code"));
entity.setPubServicePlatCode(null== map.get("pub_service_plat_code")?null:(String) map.get("pub_service_plat_code"));
entity.setSystemCode(null==map.get("system_code")?null:(String) map.get("system_code"));
entity.setBlockChainPrev(null== map.get("block_chain_prev")?null:(String) map.get("block_chain_prev"));
entity.setData(null==map.get("data")?null:(String) map.get("data"));
entity.setDesData(null==map.get("des_data")?null:(String) map.get("des_data"));
entity.setCallbackUrl(null== map.get("callback_url")?null:(String) map.get("callback_url"));
entity.setIp(null== map.get("ip")?null:(String) map.get("ip"));
entity.setCreator(null==map.get("creator")?null:(long) map.get("creator"));
entity.setCreateDate(null==map.get("create_date")?null:(Date) map.get("create_date"));
entity.setTenderProjectId(null==map.get("tender_project_id")?null:(String) map.get("tender_project_id"));
entity.setModule(null==map.get("module")?null:(String) map.get("module"));
entity.setTenderFlowKey(null==map.get("tender_flow_key")?null:(String) map.get("tender_flow_key"));
entity.setOpType(null== map.get("op_type")?null:(String) map.get("op_type"));
entity.setTableName(null==map.get("table_name")?null:(String) map.get("table_name"));
entity.setTableInfoId(null==map.get("table_info_id")?null:(String) map.get("table_info_id"));
entity.setDatasType(null==map.get("datas_type")?null:(String) map.get("datas_type"));
return entity;
}
}
\ No newline at end of file
... ...
package org.yrhl.syncdata.domain;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import java.util.Map;
/**
* @ClassName BlockSourceDataEntity
* @Description 存证传入数据
* @Author kun
* @Date 2022-3-12 10:59
* @Version 1.0
**/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("block_source_data")
public class BlockSourceDataEntity extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 平台编码
*/
private String platformCode;
/**
* 系统编码
*/
private String pubservicePlatCode;
/**
* 系统标识码
*/
private String systemCode;
/**
* 招标项目id
*/
private String tenderProjectId;
/**
* 项目流程环节
*/
private String module;
/**
* 业务审批流程唯一标识
*/
private String tenderFlowKey;
/**
* 操作类型
*/
private String opType;
/**
* 业务表名
*/
private String tableName;
/**
* 业务id
*/
private String tableInfoId;
/**
* 上一区块
*/
private String blockChainPrev;
/**
* 区块链存证hash
*/
private String blockChainHash;
/**
* 区块链查证url
*/
private String blockChainUrl;
/**
* 签名值
*/
private String signValue;
/**
* 原始数据
*/
private String data;
/**
* 解密数据
*/
private String desData;
/**
* 0:解密失败,1:解密成功
*/
private String status;
private String ip;
/**
* 修改时间
*/
private Date updateDate;
/**
* 上链时间
*/
private Date blockChainTime;
/**
* 标段编号(多个标段用英文逗号分隔)
*/
private String bidSectionCodes;
/**
* 是否推送一网通办(0-为推送,1-为不推送)
*/
private Integer isPush;
// 静态方法,用于从 Map 转换到 BusinessDataResultsEntity
public static BlockSourceDataEntity fromMap(Map<String, Object> map) {
BlockSourceDataEntity entity = new BlockSourceDataEntity();
// 假设 map 中有与 entity 字段对应的键
entity.setId((Long) map.get("id"));
entity.setPlatformCode(null==map.get("platform_code")?null:(String) map.get("platform_code"));
entity.setPubservicePlatCode(null== map.get("pubservice_plat_code")?null:(String) map.get("pubservice_plat_code"));
entity.setSystemCode(null== map.get("system_code")?null:(String) map.get("system_code"));
entity.setTenderProjectId(null==map.get("tender_project_id")?null:(String) map.get("tender_project_id"));
entity.setModule(null==map.get("module")?null:(String) map.get("module"));
entity.setTenderFlowKey(null== map.get("tender_flow_key")?null:(String) map.get("tender_flow_key"));
entity.setOpType(null==map.get("op_type")?null:(String) map.get("op_type"));
entity.setTableName(null== map.get("table_name")?null:(String) map.get("table_name"));
entity.setTableInfoId(null==map.get("table_info_id")?null:(String) map.get("table_info_id"));
entity.setBlockChainPrev(null== map.get("block_chain_prev")?null:(String) map.get("block_chain_prev"));
entity.setBlockChainHash(null==map.get("block_chain_hash")?null:(String) map.get("block_chain_hash"));
entity.setBlockChainUrl(null==map.get("block_chain_url")?null:(String) map.get("block_chain_url"));
entity.setStatus(null== map.get("status")?null:(String) map.get("status"));
entity.setSignValue(null== map.get("sign_value")?null:(String) map.get("sign_value"));
entity.setCreator(null==map.get("creator")?null:(long) map.get("creator"));
entity.setCreateDate(null==map.get("create_date")?null:(Date) map.get("create_date"));
entity.setData(null==map.get("data")?null:(String) map.get("data"));
entity.setDesData(null==map.get("des_data")?null:(String) map.get("des_data"));
entity.setIp(null==map.get("ip")?null:(String) map.get("ip"));
entity.setUpdateDate(null== map.get("update_date")?null:(Date) map.get("update_date"));
entity.setBidSectionCodes(null== map.get("bid_section_codes")?null:(String) map.get("bid_section_codes"));
entity.setBlockChainTime(null==map.get("block_chain_time")?null:(Date) map.get("block_chain_time"));
entity.setIsPush(null==map.get("is_push")?null:(int) map.get("is_push"));
return entity;
}
}
... ...
package org.yrhl.syncdata.domain;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import java.util.Map;
/**
* 数据凭证结果表
*
* @author Mark sunlightcs@gmail.com
* @since 1.0.0 2022-03-01
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("business_data_results")
public class BusinessDataResultsEntity extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 平台编码
*/
private String platformCode;
/**
* 系统编码
*/
private String pubservicePlatCode;
/**
* 系统标识码
*/
private String systemCode;
/**
* 项目id
*/
private String tenderProjectId;
/**
* 模块名称
*/
private String module;
/**
*
*/
private String tenderFlowKey;
/**
*
*/
private String opType;
/**
* 业务节点名称
*/
private String tableName;
/**
* 业务id
*/
private String tableInfoId;
/**
* 业务数据json
*/
private String dataValue;
/**
*
*/
private String blockChainPrev;
/**
* 执行结果
*/
private String blockChainHash;
/**
*
*/
private String blockChainUrl;
/**
* 执行状态(0:存证失败 1:存证成功)
*/
private Integer status;
/**
* 块号
*/
private String blockNum;
private String date;
// 静态方法,用于从 Map 转换到 BusinessDataResultsEntity
public static BusinessDataResultsEntity fromMap(Map<String, Object> map) {
BusinessDataResultsEntity entity = new BusinessDataResultsEntity();
// 假设 map 中有与 entity 字段对应的键
entity.setId(null== map.get("id")?null:(Long) map.get("id"));
entity.setPlatformCode(null== map.get("platform_code")?null:(String) map.get("platform_code"));
entity.setPubservicePlatCode(null== map.get("pubservice_plat_code")?null:(String) map.get("pubservice_plat_code"));
entity.setSystemCode(null==map.get("system_code")?null:(String) map.get("system_code"));
entity.setTenderProjectId((String) map.get("tender_project_id"));
entity.setModule(null==map.get("module")?null:(String) map.get("module"));
entity.setTenderFlowKey(null== map.get("tender_flow_key")?null:(String) map.get("tender_flow_key"));
entity.setOpType(null==map.get("op_type")?null:(String) map.get("op_type"));
entity.setTableName(null== map.get("table_name")?null:(String) map.get("table_name"));
entity.setTableInfoId(null==map.get("table_info_id")?null:(String) map.get("table_info_id"));
entity.setDataValue(null== map.get("data_value")?null:(String) map.get("data_value"));
entity.setBlockChainPrev(null== map.get("block_chain_prev")?null:(String) map.get("block_chain_prev"));
entity.setBlockChainHash(null== map.get("block_chain_hash")?null:(String) map.get("block_chain_hash"));
entity.setBlockChainUrl(null== map.get("block_chain_url")?null:(String) map.get("block_chain_url"));
entity.setStatus(null==map.get("status")?null:(int) map.get("status"));
entity.setBlockNum(null==map.get("block_num")?null:(String) map.get("block_num"));
entity.setCreator(null==map.get("creator")?null:(long) map.get("creator"));
entity.setCreateDate(null== map.get("create_date")?null:(Date) map.get("create_date"));
// 其他字段的设置...
return entity;
}
}
\ No newline at end of file
... ...
package org.yrhl.syncdata.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/***
* 同步结果表
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("sync_result")
public class SyncResult {
@JsonSerialize(using = ToStringSerializer.class)
@TableId(value = "id", type = IdType.ID_WORKER)
private Long id;
// 同步表名
private String TableName;
//业务id
private Long InfoId;
//数据源表创建时间
private Date DateCreateTime;
//同步状态 0:待同步 1:同步成功 -1:同步失败
private Integer Status;
//创建时间
private Date CreateDateTime;
//更新时间
private Date UpdateTime;
}
\ No newline at end of file
... ...
package org.yrhl.syncdata.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.EqualsAndHashCode;
/***
* 需要同步的表名
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("sync_table")
public class SyncTable {
@JsonSerialize(using = ToStringSerializer.class)
@TableId(value = "id", type = IdType.ID_WORKER)
private Long id;
private String tableName;
private String isDelete;
}
\ No newline at end of file
... ...
package org.yrhl.syncdata.mapper.local;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.yrhl.syncdata.Retention.BatchInsert;
import org.yrhl.syncdata.domain.*;
import java.util.List;
import java.util.Map;
@Mapper
public interface CourseOneMapper extends BaseMapper<SyncResult> {
List<SyncTable> getSyncTableList();
//查询待同步的数据
List<SyncResult> getSyncResultListForWaitForAllinonepushresults(@Param("tableName") String tableName,@Param("page") int page,@Param("size") int size);
List<SyncResult> getSyncResultListForWait(@Param("tableName") String tableName,@Param("page") int page,@Param("size") int size);
List<BusinessDataResultsEntity> getList();
List<BlockSourceDataEntity> getBlockSourceDataEntityList();
List<BlockNewSourceDataEntity> getBlockNewSourceDataEntityList();
List<AllinonepushresultsEntity> getAllinonepushresultsEntityList();
void insertSyncResult(List<SyncResult> syncResultListForWait);
List<AllinonepushresultsEntity> getSyncResultListForWaitForConsumer(@Param("tableName") String tableName,@Param("page") int page,@Param("size") int size);
List<Map<String, Object>> getSyncResultListForWaitForOtherConsumer(@Param("tableName") String tableName,@Param("page") int page,@Param("size") int size);
void updateSyncResult(@Param("infoId") Long infoId);
void updateSyncResultFail(@Param("infoId") Long infoId);
int isExesit(@Param("infoId") Long infoId);
}
... ...
package org.yrhl.syncdata.mapper.remote;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.yrhl.syncdata.domain.AllinonepushresultsEntity;
import org.yrhl.syncdata.domain.BlockNewSourceDataEntity;
import org.yrhl.syncdata.domain.BlockSourceDataEntity;
import org.yrhl.syncdata.domain.BusinessDataResultsEntity;
import java.util.List;
@Mapper
public interface CourseTwoMapper {
/**
* 批量插入
* @param list
*/
void insertBusinessDataResultsBatch(@Param("list") List<BusinessDataResultsEntity> list);
void insertBlockSourceDataEntityBatch(@Param("list") List<BlockSourceDataEntity> list);
void insertBlockNewSourceDataEntityBatch(@Param("list") List<BlockNewSourceDataEntity> list);
void insertAllinonepushresultsEntityBatch(@Param("list") List<AllinonepushresultsEntity> list);
int isExist(@Param("tableName") String tableName ,@Param("infoId") Long infoId);
}
... ...
package org.yrhl.syncdata.service;
public interface BlockNewSourceDataEntityService {
}
... ...
package org.yrhl.syncdata.task;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.yrhl.syncdata.domain.*;
import org.yrhl.syncdata.mapper.local.CourseOneMapper;
import org.yrhl.syncdata.mapper.remote.CourseTwoMapper;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@EnableScheduling //开启定时
@Component
public class MySchedule {
private static final Logger log = LoggerFactory.getLogger(MySchedule.class);
@Resource
private CourseOneMapper courseOneMapper;
@Resource
private CourseTwoMapper courseTwoMapper;
/**
* 每隔10秒执行一次 执行生产者 准备数据
*/
@Scheduled(fixedDelay = 20000)
public void test(){
//先查询需要同步的表信息
List<SyncTable> syncTableList = courseOneMapper.getSyncTableList();
if(syncTableList.isEmpty()){
log.error("没有可用的同步表,请查看sync_table表是否有可用的数据");
return ;
}
for(SyncTable syncTable:syncTableList){
int i = insertIntoSyncResult(syncTable.getTableName());
log.error("插入SyncResult状态为{}",i==1?"成功":"失败");
}
}
@Scheduled(fixedDelay = 40000)
public void test1() {
//从中间表查询需要同步的数据
List<SyncTable> syncTableList = courseOneMapper.getSyncTableList();
for (SyncTable syncTable : syncTableList) {
int i = syncTargetSoucre(syncTable.getTableName());
log.error("数据同步到目标数据库{}",i==0?"成功":"失败");
}
}
/***
* 获取可备份的业务数据并将数据插入到SyncResult中待备份
* @param tablename
* @return
*/
private int insertIntoSyncResult(String tablename ) {
int page = 1;
while (true) {
log.info("生产者:当前第{}页",page);
//将数据插入到sync_result 中
List<SyncResult> syncResultListForWait = null;
if("allinonepushresults".equals(tablename)){
syncResultListForWait = courseOneMapper.getSyncResultListForWaitForAllinonepushresults(tablename,(page-1)*100,100);
}else{
syncResultListForWait = courseOneMapper.getSyncResultListForWait(tablename,(page-1)*100,100);
}
if(CollectionUtils.isEmpty(syncResultListForWait)) {
break;
}
try {
// 1.在中间表查询是否存在数据(根据业务主键):如果存在,忽略,如果不存在,插入
List<SyncResult> res= new ArrayList<>();
for(SyncResult syncResult:syncResultListForWait){
// 遍历逐条分析:
int exesit = courseOneMapper.isExesit(syncResult.getInfoId());
if(0==exesit){
res.add(syncResult);
}
}
if(CollectionUtils.isNotEmpty(res)){
log.info("一共:"+res.size()+ "条");
long start = System.currentTimeMillis();
courseOneMapper.insertSyncResult(res);
long end = System.currentTimeMillis();
log.info("数据总耗时:" + (end-start) + "ms");
}
}catch (Exception e){
log.error("插入数据失败", e);
return 0;
}
page++;
}
return 0;
}
private int syncTargetSoucre(String tableName){
if ("allinonepushresults".equals(tableName)) {
int page = 1;
while (true) {
log.info("消费者:表名{}当前第{}页","allinonepushresults",page);
List<AllinonepushresultsEntity> syncResultListForWait = courseOneMapper.getSyncResultListForWaitForConsumer(tableName,(page-1)*100,100);
List<Long> ids = null;
if (CollectionUtils.isEmpty(syncResultListForWait)) {
break;
}
try {
List<AllinonepushresultsEntity> resData = new ArrayList<>();
for (AllinonepushresultsEntity allinonepushresultsEntity : syncResultListForWait) {
int count = courseTwoMapper.isExist("allinonepushresults", allinonepushresultsEntity.getId());
if (0 == count) {
resData.add(allinonepushresultsEntity);
}
}
if (CollectionUtils.isNotEmpty(resData)) {
courseTwoMapper.insertAllinonepushresultsEntityBatch(resData);
}
ids = syncResultListForWait.stream()
.map(AllinonepushresultsEntity::getId)
.collect(Collectors.toList());
for (Long id : ids) {
courseOneMapper.updateSyncResult(id);
}
} catch (Exception e) {
ids = syncResultListForWait.stream()
.map(AllinonepushresultsEntity::getId)
.collect(Collectors.toList());
for (Long id : ids) {
courseOneMapper.updateSyncResultFail(id);
}
}
page++;
}
log.info("消费者:表名{}同步完毕,一共{}页数据",tableName,page);
}
else if ("block_new_source_data".equals(tableName)) {
int page = 1;
while (true) {
log.info("消费者:表名{}当前第{}页","block_new_source_data",page);
List<Long> ids = null;
List<Map<String, Object>> list3 = courseOneMapper.getSyncResultListForWaitForOtherConsumer(tableName,(page-1)*100,100);
if (CollectionUtils.isEmpty(list3)) {
break;
}
List<BlockNewSourceDataEntity> res1 = list3.stream()
.map(BlockNewSourceDataEntity::fromMap)
.collect(Collectors.toList());
page++;
try {
List<BlockNewSourceDataEntity> resData = new ArrayList<>();
for (BlockNewSourceDataEntity blockNewSourceDataEntity : res1) {
int count = courseTwoMapper.isExist("block_new_source_data", blockNewSourceDataEntity.getId());
if (0 == count) {
resData.add(blockNewSourceDataEntity);
}
}
if (CollectionUtils.isNotEmpty(resData)) {
long start = System.currentTimeMillis();
courseTwoMapper.insertBlockNewSourceDataEntityBatch(resData);
long end = System.currentTimeMillis();
log.info("消费者插入数据总耗时:" + (end-start) + "ms");
}
ids = res1.stream()
.map(BlockNewSourceDataEntity::getId)
.collect(Collectors.toList());
for (Long id : ids) {
courseOneMapper.updateSyncResult(id);
}
} catch (Exception e) {
ids = res1.stream()
.map(BlockNewSourceDataEntity::getId)
.collect(Collectors.toList());
for (Long id : ids) {
courseOneMapper.updateSyncResultFail(id);
}
}
}
log.info("消费者:表名{}同步完毕,一共{}页数据",tableName);
}
else if("block_source_data".equals(tableName)){
{
int page = 1;
while (true) {
log.info("消费者:表名{}当前第{}页","block_source_data",page);
List<Long> ids = null;
List<Map<String, Object>> list3 = courseOneMapper.getSyncResultListForWaitForOtherConsumer(tableName,(page-1)*100,100);
if (CollectionUtils.isEmpty(list3)) {
break;
}
List<BlockSourceDataEntity> res1 = list3.stream()
.map(BlockSourceDataEntity::fromMap)
.collect(Collectors.toList());
page++;
try {
List<BlockSourceDataEntity> resData = new ArrayList<>();
for (BlockSourceDataEntity blockSourceDataEntity : res1) {
int count = courseTwoMapper.isExist("block_source_data", blockSourceDataEntity.getId());
if (0 == count) {
resData.add(blockSourceDataEntity);
}
}
if (CollectionUtils.isNotEmpty(resData)) {
courseTwoMapper.insertBlockSourceDataEntityBatch(resData);
}
ids = res1.stream()
.map(BlockSourceDataEntity::getId)
.collect(Collectors.toList());
for (Long id : ids) {
courseOneMapper.updateSyncResult(id);
}
} catch (Exception e) {
ids = res1.stream()
.map(BlockSourceDataEntity::getId)
.collect(Collectors.toList());
for (Long id : ids) {
courseOneMapper.updateSyncResultFail(id);
}
}
}
log.info("消费者:表名{}同步完毕,一共{}页数据",tableName,page);
}
}
else if("business_data_results".equals(tableName)){
{
int page = 1;
while (true) {
log.info("消费者:表名{}当前第{}页","business_data_results",page);
List<Long> ids = null;
List<Map<String, Object>> list3 = courseOneMapper.getSyncResultListForWaitForOtherConsumer(tableName,(page-1)*100,100);
if (CollectionUtils.isEmpty(list3)) {
break;
}
List<BusinessDataResultsEntity> res1 = list3.stream()
.map(BusinessDataResultsEntity::fromMap)
.collect(Collectors.toList());
page++;
try {
List<BusinessDataResultsEntity> resData = new ArrayList<>();
for (BusinessDataResultsEntity businessDataResultsEntity : res1) {
int count = courseTwoMapper.isExist("business_data_results", businessDataResultsEntity.getId());
if (0 == count) {
resData.add(businessDataResultsEntity);
}
}
if (CollectionUtils.isNotEmpty(resData)) {
courseTwoMapper.insertBusinessDataResultsBatch(resData);
}
ids = res1.stream()
.map(BusinessDataResultsEntity::getId)
.collect(Collectors.toList());
for (Long id : ids) {
courseOneMapper.updateSyncResult(id);
}
} catch (Exception e) {
ids = res1.stream()
.map(BusinessDataResultsEntity::getId)
.collect(Collectors.toList());
for (Long id : ids) {
courseOneMapper.updateSyncResultFail(id);
}
}
}
log.info("消费者:表名{}同步完毕,一共{}页数据",tableName,page);
}
}
return 0;
}
}
\ No newline at end of file
... ...
//package org.yrhl.syncdata.task;
//
//import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//import org.yrhl.syncdata.domain.*;
//import org.yrhl.syncdata.mapper.local.CourseOneMapper;
//import org.yrhl.syncdata.mapper.remote.CourseTwoMapper;
//
//import javax.annotation.Resource;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Map;
//import java.util.stream.Collectors;
//
//@EnableScheduling //开启定时
//@Component
//public class MySchedule1 {
// private static final Logger log = LoggerFactory.getLogger(MySchedule1.class);
// @Resource
// private CourseOneMapper courseOneMapper;
// @Resource
// private CourseTwoMapper courseTwoMapper;
// /**
// * 每隔10秒执行一次 执行生产者 准备数据
// */
// @Scheduled(fixedDelay = 20000)
// public void test(){
// //先查询需要同步的表信息
// List<SyncTable> syncTableList = courseOneMapper.getSyncTableList();
// if(syncTableList.isEmpty()){
// log.error("没有可用的同步表,请查看sync_table表是否有可用的数据");
// return ;
// }
// for(SyncTable syncTable:syncTableList){
// //查询需要待同步的表数据
// if("allinonepushresults".equals(syncTable.getTableName())){
// int page = 1;
// while (true) {
// log.info("生产者:当前第{}页",page);
// //将数据插入到sync_result 中
// List<SyncResult> syncResultListForWait = courseOneMapper.getSyncResultListForWaitForAllinonepushresults(syncTable.getTableName(),(page-1)*100,100);
// if(CollectionUtils.isEmpty(syncResultListForWait)) {
// break;
// }
// page++;
// try {
// // 1.在中间表查询是否存在数据(根据业务主键):如果存在,忽略,如果不存在,插入
// List<SyncResult> res= new ArrayList<>();
// for(SyncResult syncResult:syncResultListForWait){
// // 遍历逐条分析:
// int exesit = courseOneMapper.isExesit(syncResult.getInfoId());
// if(0==exesit){
// res.add(syncResult);
// }
// }
// if(CollectionUtils.isNotEmpty(res)){
// courseOneMapper.insertSyncResult(res);
// }
// }catch (Exception e){
// log.error("插入数据失败", e);
// }
// }
// }
// else{
// int page = 1;
// while (true) {
// log.info("生产者:表名{}第{}页",syncTable,page);
// List<SyncResult> syncResultListForWait = courseOneMapper.getSyncResultListForWait(syncTable.getTableName(),(page-1)*100,100);
// if(CollectionUtils.isEmpty(syncResultListForWait)) {
// break;
// }
// page++;
// try {
// // 1.在中间表查询是否存在数据(根据业务主键):如果存在,忽略,如果不存在,插入
// List<SyncResult> res = new ArrayList<>();
// for (SyncResult syncResult : syncResultListForWait) {
// // 遍历逐条分析:
// int exesit = courseOneMapper.isExesit(syncResult.getInfoId());
// if (0 == exesit) {
// res.add(syncResult);
// }
// }
// if (CollectionUtils.isNotEmpty(res)) {
// courseOneMapper.insertSyncResult(res);
// }
// log.info("生产者:表名{}插入中间表结束",syncTable);
// } catch (Exception e) {
// log.error("插入数据失败", e);
// }
// }
// }
//
// }
// }
//
//
// @Scheduled(fixedDelay = 40000)
// public void test1() {
// //从中间表查询需要同步的数据
// List<SyncTable> syncTableList = courseOneMapper.getSyncTableList();
// for (SyncTable syncTable : syncTableList) {
// if ("allinonepushresults".equals(syncTable.getTableName())) {
// int page = 1;
// while (true) {
// log.info("消费者:表名{}当前第{}页","allinonepushresults",page);
// List<AllinonepushresultsEntity> syncResultListForWait = courseOneMapper.getSyncResultListForWaitForConsumer(syncTable.getTableName(),(page-1)*100,100);
// List<Long> ids = null;
// if (CollectionUtils.isEmpty(syncResultListForWait)) {
// break;
// }
// page++;
// try {
// List<AllinonepushresultsEntity> resData = new ArrayList<>();
// for (AllinonepushresultsEntity allinonepushresultsEntity : syncResultListForWait) {
// int count = courseTwoMapper.isExist("allinonepushresults", allinonepushresultsEntity.getId());
// if (0 == count) {
// resData.add(allinonepushresultsEntity);
// }
// }
// if (CollectionUtils.isNotEmpty(resData)) {
// courseTwoMapper.insertAllinonepushresultsEntityBatch(resData);
// }
// ids = syncResultListForWait.stream()
// .map(AllinonepushresultsEntity::getId)
// .collect(Collectors.toList());
// for (Long id : ids) {
// courseOneMapper.updateSyncResult(id);
// }
// } catch (Exception e) {
// ids = syncResultListForWait.stream()
// .map(AllinonepushresultsEntity::getId)
// .collect(Collectors.toList());
// for (Long id : ids) {
// courseOneMapper.updateSyncResultFail(id);
// }
// }
// }
// log.info("消费者:表名{}同步完毕,一共{}页数据",syncTable,page);
// }
// else if ("block_new_source_data".equals(syncTable.getTableName())) {
// int page = 1;
// while (true) {
// log.info("消费者:表名{}当前第{}页","block_new_source_data",page);
// List<Long> ids = null;
// List<Map<String, Object>> list3 = courseOneMapper.getSyncResultListForWaitForOtherConsumer(syncTable.getTableName(),(page-1)*100,100);
// if (CollectionUtils.isEmpty(list3)) {
// break;
// }
// List<BlockNewSourceDataEntity> res1 = list3.stream()
// .map(BlockNewSourceDataEntity::fromMap)
// .collect(Collectors.toList());
// page++;
// try {
// List<BlockNewSourceDataEntity> resData = new ArrayList<>();
// for (BlockNewSourceDataEntity blockNewSourceDataEntity : res1) {
// int count = courseTwoMapper.isExist("block_new_source_data", blockNewSourceDataEntity.getId());
// if (0 == count) {
// resData.add(blockNewSourceDataEntity);
// }
// }
// if (CollectionUtils.isNotEmpty(resData)) {
// courseTwoMapper.insertBlockNewSourceDataEntityBatch(resData);
// }
// ids = res1.stream()
// .map(BlockNewSourceDataEntity::getId)
// .collect(Collectors.toList());
// for (Long id : ids) {
// courseOneMapper.updateSyncResult(id);
// }
// } catch (Exception e) {
// ids = res1.stream()
// .map(BlockNewSourceDataEntity::getId)
// .collect(Collectors.toList());
// for (Long id : ids) {
// courseOneMapper.updateSyncResultFail(id);
// }
// }
// }
// log.info("消费者:表名{}同步完毕,一共{}页数据",syncTable);
// }
// else if("block_source_data".equals(syncTable.getTableName())){
// {
// int page = 1;
// while (true) {
// log.info("消费者:表名{}当前第{}页","block_source_data",page);
// List<Long> ids = null;
// List<Map<String, Object>> list3 = courseOneMapper.getSyncResultListForWaitForOtherConsumer(syncTable.getTableName(),(page-1)*100,100);
// if (CollectionUtils.isEmpty(list3)) {
// break;
// }
// List<BlockSourceDataEntity> res1 = list3.stream()
// .map(BlockSourceDataEntity::fromMap)
// .collect(Collectors.toList());
// page++;
// try {
// List<BlockSourceDataEntity> resData = new ArrayList<>();
// for (BlockSourceDataEntity blockSourceDataEntity : res1) {
// int count = courseTwoMapper.isExist("block_source_data", blockSourceDataEntity.getId());
// if (0 == count) {
// resData.add(blockSourceDataEntity);
// }
// }
// if (CollectionUtils.isNotEmpty(resData)) {
// courseTwoMapper.insertBlockSourceDataEntityBatch(resData);
// }
// ids = res1.stream()
// .map(BlockSourceDataEntity::getId)
// .collect(Collectors.toList());
// for (Long id : ids) {
// courseOneMapper.updateSyncResult(id);
// }
// } catch (Exception e) {
// ids = res1.stream()
// .map(BlockSourceDataEntity::getId)
// .collect(Collectors.toList());
// for (Long id : ids) {
// courseOneMapper.updateSyncResultFail(id);
// }
// }
// }
// log.info("消费者:表名{}同步完毕,一共{}页数据",syncTable,page);
// }
//
// }
// else if("business_data_results".equals(syncTable.getTableName())){
// {
// int page = 1;
// while (true) {
// log.info("消费者:表名{}当前第{}页","business_data_results",page);
// List<Long> ids = null;
// List<Map<String, Object>> list3 = courseOneMapper.getSyncResultListForWaitForOtherConsumer(syncTable.getTableName(),(page-1)*100,100);
// if (CollectionUtils.isEmpty(list3)) {
// break;
// }
// List<BusinessDataResultsEntity> res1 = list3.stream()
// .map(BusinessDataResultsEntity::fromMap)
// .collect(Collectors.toList());
// page++;
// try {
// List<BusinessDataResultsEntity> resData = new ArrayList<>();
// for (BusinessDataResultsEntity businessDataResultsEntity : res1) {
// int count = courseTwoMapper.isExist("business_data_results", businessDataResultsEntity.getId());
// if (0 == count) {
// resData.add(businessDataResultsEntity);
// }
// }
// if (CollectionUtils.isNotEmpty(resData)) {
// courseTwoMapper.insertBusinessDataResultsBatch(resData);
// }
// ids = res1.stream()
// .map(BusinessDataResultsEntity::getId)
// .collect(Collectors.toList());
// for (Long id : ids) {
// courseOneMapper.updateSyncResult(id);
// }
// } catch (Exception e) {
// ids = res1.stream()
// .map(BusinessDataResultsEntity::getId)
// .collect(Collectors.toList());
// for (Long id : ids) {
// courseOneMapper.updateSyncResultFail(id);
// }
// }
// }
// log.info("消费者:表名{}同步完毕,一共{}页数据",syncTable,page);
// }
// }
//
// }
//
// }
//}
\ No newline at end of file
... ...
//package org.yrhl.syncdata.task;
//
//import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//import org.yrhl.syncdata.domain.*;
//import org.yrhl.syncdata.mapper.local.CourseOneMapper;
//import org.yrhl.syncdata.mapper.remote.CourseTwoMapper;
//
//import javax.annotation.Resource;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Map;
//import java.util.stream.Collectors;
//
//@EnableScheduling //开启定时
//@Component
//public class MySchedule2 {
// private static final Logger log = LoggerFactory.getLogger(MySchedule2.class);
// @Resource
// private CourseOneMapper courseOneMapper;
// @Resource
// private CourseTwoMapper courseTwoMapper;
// /**
// * 每隔10秒执行一次 执行生产者 准备数据
// */
// @Scheduled(fixedDelay = 20000)
// public void test(){
// //先查询需要同步的表信息
// List<SyncTable> syncTableList = courseOneMapper.getSyncTableList();
// if(syncTableList.isEmpty()){
// log.error("没有可用的同步表,请查看sync_table表是否有可用的数据");
// return ;
// }
// for(SyncTable syncTable:syncTableList){
// int i = insertIntoSyncResult(syncTable.getTableName());
// log.error("插入SyncResult状态为{}",i==1?"成功":"失败");
// }
// log.info("--------------------插入SyncResult表成功--------------------");
// log.info("--------------------开始备份数据到目标库--------------------");
// test1();
// }
//
//
//// @Scheduled(fixedDelay = 40000)
// public void test1() {
// //从中间表查询需要同步的数据
// List<SyncTable> syncTableList = courseOneMapper.getSyncTableList();
// for (SyncTable syncTable : syncTableList) {
// syncTargetSoucre(syncTable.getTableName());
// }
// log.error("数据同步到目标数据库成功");
// }
//
//
// /***
// * 获取可备份的业务数据并将数据插入到SyncResult中待备份
// * @param tablename
// * @return
// */
// private int insertIntoSyncResult(String tablename ) {
//
// int page = 1;
// while (true) {
// //将数据插入到sync_result 中
// List<SyncResult> syncResultListForWait = null;
// if("allinonepushresults".equals(tablename)){
// syncResultListForWait = courseOneMapper.getSyncResultListForWaitForAllinonepushresults(tablename,(page-1)*100,100);
// }else{
// syncResultListForWait = courseOneMapper.getSyncResultListForWait(tablename,(page-1)*100,100);
// }
// if(CollectionUtils.isEmpty(syncResultListForWait)) {
// break;
// }
// page++;
// try {
// // 1.在中间表查询是否存在数据(根据业务主键):如果存在,忽略,如果不存在,插入
// List<SyncResult> res= new ArrayList<>();
// for(SyncResult syncResult:syncResultListForWait){
// // 遍历逐条分析:
// int exesit = courseOneMapper.isExesit(syncResult.getInfoId());
// if(0==exesit){
// res.add(syncResult);
// }
// }
// if(CollectionUtils.isNotEmpty(res)){
// courseOneMapper.insertSyncResult(res);
// return 1;
// }
// }catch (Exception e){
// log.error("向SyncResult表插入数据失败", e);
// return 0;
// }
// }
//
// return 0;
// }
//
//
// private int syncTargetSoucre(String tableName){
//
// if ("allinonepushresults".equals(tableName)) {
// int page = 1;
// while (true) {
// log.info("消费者:获取{}的数据","allinonepushresults");
// List<AllinonepushresultsEntity> syncResultListForWait = courseOneMapper.getSyncResultListForWaitForConsumer(tableName,(page-1)*100,100);
// List<Long> ids = null;
// if (CollectionUtils.isEmpty(syncResultListForWait)) {
// break;
// }
// page++;
// try {
// List<AllinonepushresultsEntity> resData = new ArrayList<>();
// for (AllinonepushresultsEntity allinonepushresultsEntity : syncResultListForWait) {
// int count = courseTwoMapper.isExist("allinonepushresults", allinonepushresultsEntity.getId());
// if (0 == count) {
// resData.add(allinonepushresultsEntity);
// }
// }
// if (CollectionUtils.isNotEmpty(resData)) {
// courseTwoMapper.insertAllinonepushresultsEntityBatch(resData);
// }
// ids = syncResultListForWait.stream()
// .map(AllinonepushresultsEntity::getId)
// .collect(Collectors.toList());
// for (Long id : ids) {
// courseOneMapper.updateSyncResult(id);
// }
// } catch (Exception e) {
// ids = syncResultListForWait.stream()
// .map(AllinonepushresultsEntity::getId)
// .collect(Collectors.toList());
// for (Long id : ids) {
// courseOneMapper.updateSyncResultFail(id);
// }
// }
// }
// log.info("消费者:表名{}同步完毕","allinonepushresults");
// }
// else if ("block_new_source_data".equals(tableName)) {
// int page = 1;
// while (true) {
// log.info("消费者:获取{}数据","block_new_source_data");
// List<Long> ids = null;
// List<Map<String, Object>> list3 = courseOneMapper.getSyncResultListForWaitForOtherConsumer(tableName,(page-1)*100,100);
// if (CollectionUtils.isEmpty(list3)) {
// break;
// }
// List<BlockNewSourceDataEntity> res1 = list3.stream()
// .map(BlockNewSourceDataEntity::fromMap)
// .collect(Collectors.toList());
// page++;
// try {
// List<BlockNewSourceDataEntity> resData = new ArrayList<>();
// for (BlockNewSourceDataEntity blockNewSourceDataEntity : res1) {
// int count = courseTwoMapper.isExist("block_new_source_data", blockNewSourceDataEntity.getId());
// if (0 == count) {
// resData.add(blockNewSourceDataEntity);
// }
// }
// if (CollectionUtils.isNotEmpty(resData)) {
// courseTwoMapper.insertBlockNewSourceDataEntityBatch(resData);
// }
// ids = res1.stream()
// .map(BlockNewSourceDataEntity::getId)
// .collect(Collectors.toList());
// for (Long id : ids) {
// courseOneMapper.updateSyncResult(id);
// }
// } catch (Exception e) {
// ids = res1.stream()
// .map(BlockNewSourceDataEntity::getId)
// .collect(Collectors.toList());
// for (Long id : ids) {
// courseOneMapper.updateSyncResultFail(id);
// }
// }
// }
// log.info("消费者:表名{}同步完毕","block_new_source_data");
// }
// else if("block_source_data".equals(tableName)){
// {
// int page = 1;
// while (true) {
// log.info("消费者:获取{}的数据","block_source_data");
// List<Long> ids = null;
// List<Map<String, Object>> list3 = courseOneMapper.getSyncResultListForWaitForOtherConsumer(tableName,(page-1)*100,100);
// if (CollectionUtils.isEmpty(list3)) {
// break;
// }
// List<BlockSourceDataEntity> res1 = list3.stream()
// .map(BlockSourceDataEntity::fromMap)
// .collect(Collectors.toList());
// page++;
// try {
// List<BlockSourceDataEntity> resData = new ArrayList<>();
// for (BlockSourceDataEntity blockSourceDataEntity : res1) {
// int count = courseTwoMapper.isExist("block_source_data", blockSourceDataEntity.getId());
// if (0 == count) {
// resData.add(blockSourceDataEntity);
// }
// }
// if (CollectionUtils.isNotEmpty(resData)) {
// courseTwoMapper.insertBlockSourceDataEntityBatch(resData);
// }
// ids = res1.stream()
// .map(BlockSourceDataEntity::getId)
// .collect(Collectors.toList());
// for (Long id : ids) {
// courseOneMapper.updateSyncResult(id);
// }
// } catch (Exception e) {
// ids = res1.stream()
// .map(BlockSourceDataEntity::getId)
// .collect(Collectors.toList());
// for (Long id : ids) {
// courseOneMapper.updateSyncResultFail(id);
// }
// }
// }
// log.info("消费者:表名{}同步完毕","block_source_data");
// }
//
// }
// else if("business_data_results".equals(tableName)){
// {
// int page = 1;
// while (true) {
// log.info("消费者:获取{}数据","business_data_results");
// List<Long> ids = null;
// List<Map<String, Object>> list3 = courseOneMapper.getSyncResultListForWaitForOtherConsumer(tableName,(page-1)*100,100);
// if (CollectionUtils.isEmpty(list3)) {
// break;
// }
// List<BusinessDataResultsEntity> res1 = list3.stream()
// .map(BusinessDataResultsEntity::fromMap)
// .collect(Collectors.toList());
// page++;
// try {
// List<BusinessDataResultsEntity> resData = new ArrayList<>();
// for (BusinessDataResultsEntity businessDataResultsEntity : res1) {
// int count = courseTwoMapper.isExist("business_data_results", businessDataResultsEntity.getId());
// if (0 == count) {
// resData.add(businessDataResultsEntity);
// }
// }
// if (CollectionUtils.isNotEmpty(resData)) {
// courseTwoMapper.insertBusinessDataResultsBatch(resData);
// }
// ids = res1.stream()
// .map(BusinessDataResultsEntity::getId)
// .collect(Collectors.toList());
// for (Long id : ids) {
// courseOneMapper.updateSyncResult(id);
// }
// } catch (Exception e) {
// ids = res1.stream()
// .map(BusinessDataResultsEntity::getId)
// .collect(Collectors.toList());
// for (Long id : ids) {
// courseOneMapper.updateSyncResultFail(id);
// }
// }
// }
// log.info("消费者:表名{}同步完毕","business_data_results");
// }
// }
//
// return 0;
// }
//}
\ No newline at end of file
... ...
//package org.yrhl.syncdata.task;
//
//import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//import org.yrhl.syncdata.domain.*;
//import org.yrhl.syncdata.mapper.local.CourseOneMapper;
//import org.yrhl.syncdata.mapper.remote.CourseTwoMapper;
//
//import javax.annotation.Resource;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Map;
//import java.util.stream.Collectors;
//
//@EnableScheduling //开启定时
//@Component
//public class MySchedule4 {
// private static final Logger log = LoggerFactory.getLogger(MySchedule4.class);
// @Resource
// private CourseOneMapper courseOneMapper;
// @Resource
// private CourseTwoMapper courseTwoMapper;
// /**
// * 每隔10秒执行一次 执行生产者 准备数据
// */
// @Scheduled(fixedDelay = 70000)
// public void test(){
// List<BlockNewSourceDataEntity> list = courseOneMapper.getBlockNewSourceDataEntityList();
// courseTwoMapper.insertBlockNewSourceDataEntityBatch(list);
// System.out.println("===================成功======================");
// }
//
//
// // @Scheduled(fixedDelay = 40000)
// public void test1() {
// //从中间表查询需要同步的数据
// List<SyncTable> syncTableList = courseOneMapper.getSyncTableList();
// for (SyncTable syncTable : syncTableList) {
// int i = syncTargetSoucre(syncTable.getTableName());
// log.error("数据同步到目标数据库{}",i==0?"成功":"失败");
// }
//
// }
//
//
// /***
// * 获取可备份的业务数据并将数据插入到SyncResult中待备份
// * @param tablename
// * @return
// */
// private int insertIntoSyncResult(String tablename ) {
//
// int page = 1;
// while (true) {
// log.info("生产者:当前第{}页",page);
// //将数据插入到sync_result 中
// List<SyncResult> syncResultListForWait = null;
// if("allinonepushresults".equals(tablename)){
// syncResultListForWait = courseOneMapper.getSyncResultListForWaitForAllinonepushresults(tablename,(page-1)*100,1000);
// }else{
// syncResultListForWait = courseOneMapper.getSyncResultListForWait(tablename,(page-1)*100,10000);
// }
// if(CollectionUtils.isEmpty(syncResultListForWait)) {
// break;
// }
// page++;
// try {
// // 1.在中间表查询是否存在数据(根据业务主键):如果存在,忽略,如果不存在,插入
// List<SyncResult> res= new ArrayList<>();
// for(SyncResult syncResult:syncResultListForWait){
// // 遍历逐条分析:
// int exesit = courseOneMapper.isExesit(syncResult.getInfoId());
// if(0==exesit){
// res.add(syncResult);
// }
// }
// if(CollectionUtils.isNotEmpty(res)){
// courseOneMapper.insertSyncResult(res);
// }
// }catch (Exception e){
// log.error("插入数据失败", e);
// return 0;
// }
// }
//
// return 0;
// }
//
//
// private int syncTargetSoucre(String tableName){
//
// if ("allinonepushresults".equals(tableName)) {
// int page = 1;
// while (true) {
// log.info("消费者:表名{}当前第{}页","allinonepushresults",page);
// List<AllinonepushresultsEntity> syncResultListForWait = courseOneMapper.getSyncResultListForWaitForConsumer(tableName,(page-1)*100,100);
// List<Long> ids = null;
// if (CollectionUtils.isEmpty(syncResultListForWait)) {
// break;
// }
// page++;
// try {
// List<AllinonepushresultsEntity> resData = new ArrayList<>();
// for (AllinonepushresultsEntity allinonepushresultsEntity : syncResultListForWait) {
// int count = courseTwoMapper.isExist("allinonepushresults", allinonepushresultsEntity.getId());
// if (0 == count) {
// resData.add(allinonepushresultsEntity);
// }
// }
// if (CollectionUtils.isNotEmpty(resData)) {
// courseTwoMapper.insertAllinonepushresultsEntityBatch(resData);
// }
// ids = syncResultListForWait.stream()
// .map(AllinonepushresultsEntity::getId)
// .collect(Collectors.toList());
// for (Long id : ids) {
// courseOneMapper.updateSyncResult(id);
// }
// } catch (Exception e) {
// ids = syncResultListForWait.stream()
// .map(AllinonepushresultsEntity::getId)
// .collect(Collectors.toList());
// for (Long id : ids) {
// courseOneMapper.updateSyncResultFail(id);
// }
// }
// }
// log.info("消费者:表名{}同步完毕,一共{}页数据",tableName,page);
// }
// else if ("block_new_source_data".equals(tableName)) {
// int page = 1;
// while (true) {
// log.info("消费者:表名{}当前第{}页","block_new_source_data",page);
// List<Long> ids = null;
// List<Map<String, Object>> list3 = courseOneMapper.getSyncResultListForWaitForOtherConsumer(tableName,(page-1)*100,100);
// if (CollectionUtils.isEmpty(list3)) {
// break;
// }
// List<BlockNewSourceDataEntity> res1 = list3.stream()
// .map(BlockNewSourceDataEntity::fromMap)
// .collect(Collectors.toList());
// page++;
// try {
// List<BlockNewSourceDataEntity> resData = new ArrayList<>();
// for (BlockNewSourceDataEntity blockNewSourceDataEntity : res1) {
// int count = courseTwoMapper.isExist("block_new_source_data", blockNewSourceDataEntity.getId());
// if (0 == count) {
// resData.add(blockNewSourceDataEntity);
// }
// }
// if (CollectionUtils.isNotEmpty(resData)) {
// courseTwoMapper.insertBlockNewSourceDataEntityBatch(resData);
// }
// ids = res1.stream()
// .map(BlockNewSourceDataEntity::getId)
// .collect(Collectors.toList());
// for (Long id : ids) {
// courseOneMapper.updateSyncResult(id);
// }
// } catch (Exception e) {
// ids = res1.stream()
// .map(BlockNewSourceDataEntity::getId)
// .collect(Collectors.toList());
// for (Long id : ids) {
// courseOneMapper.updateSyncResultFail(id);
// }
// }
// }
// log.info("消费者:表名{}同步完毕,一共{}页数据",tableName);
// }
// else if("block_source_data".equals(tableName)){
// {
// int page = 1;
// while (true) {
// log.info("消费者:表名{}当前第{}页","block_source_data",page);
// List<Long> ids = null;
// List<Map<String, Object>> list3 = courseOneMapper.getSyncResultListForWaitForOtherConsumer(tableName,(page-1)*100,100);
// if (CollectionUtils.isEmpty(list3)) {
// break;
// }
// List<BlockSourceDataEntity> res1 = list3.stream()
// .map(BlockSourceDataEntity::fromMap)
// .collect(Collectors.toList());
// page++;
// try {
// List<BlockSourceDataEntity> resData = new ArrayList<>();
// for (BlockSourceDataEntity blockSourceDataEntity : res1) {
// int count = courseTwoMapper.isExist("block_source_data", blockSourceDataEntity.getId());
// if (0 == count) {
// resData.add(blockSourceDataEntity);
// }
// }
// if (CollectionUtils.isNotEmpty(resData)) {
// courseTwoMapper.insertBlockSourceDataEntityBatch(resData);
// }
// ids = res1.stream()
// .map(BlockSourceDataEntity::getId)
// .collect(Collectors.toList());
// for (Long id : ids) {
// courseOneMapper.updateSyncResult(id);
// }
// } catch (Exception e) {
// ids = res1.stream()
// .map(BlockSourceDataEntity::getId)
// .collect(Collectors.toList());
// for (Long id : ids) {
// courseOneMapper.updateSyncResultFail(id);
// }
// }
// }
// log.info("消费者:表名{}同步完毕,一共{}页数据",tableName,page);
// }
//
// }
// else if("business_data_results".equals(tableName)){
// {
// int page = 1;
// while (true) {
// log.info("消费者:表名{}当前第{}页","business_data_results",page);
// List<Long> ids = null;
// List<Map<String, Object>> list3 = courseOneMapper.getSyncResultListForWaitForOtherConsumer(tableName,(page-1)*100,100);
// if (CollectionUtils.isEmpty(list3)) {
// break;
// }
// List<BusinessDataResultsEntity> res1 = list3.stream()
// .map(BusinessDataResultsEntity::fromMap)
// .collect(Collectors.toList());
// page++;
// try {
// List<BusinessDataResultsEntity> resData = new ArrayList<>();
// for (BusinessDataResultsEntity businessDataResultsEntity : res1) {
// int count = courseTwoMapper.isExist("business_data_results", businessDataResultsEntity.getId());
// if (0 == count) {
// resData.add(businessDataResultsEntity);
// }
// }
// if (CollectionUtils.isNotEmpty(resData)) {
// courseTwoMapper.insertBusinessDataResultsBatch(resData);
// }
// ids = res1.stream()
// .map(BusinessDataResultsEntity::getId)
// .collect(Collectors.toList());
// for (Long id : ids) {
// courseOneMapper.updateSyncResult(id);
// }
// } catch (Exception e) {
// ids = res1.stream()
// .map(BusinessDataResultsEntity::getId)
// .collect(Collectors.toList());
// for (Long id : ids) {
// courseOneMapper.updateSyncResultFail(id);
// }
// }
// }
// log.info("消费者:表名{}同步完毕,一共{}页数据",tableName,page);
// }
// }
//
// return 0;
// }
//}
\ No newline at end of file
... ...
server:
port: 8087
spring:
datasource:
local :
driver-class-name: com.mysql.cj.jdbc.Driver
# jdbc-url: jdbc:mysql://www.lepin51.com:23306/block_chain_test?&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&autoReconnect=true&failOverReadOnly=false&allow
# username: root
# password: Admin@2023@09
jdbc-url: jdbc:mysql://rm-bp1z30vh0pyf4j013o.mysql.rds.aliyuncs.com:3306/block_service?&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&autoReconnect=true&failOverReadOnly=false&allow
username: block
password: Block@2022#31
remote :
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://192.168.31.224:3306/block_service_back?&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&allowMultiQueries=true&autoReconnect=true&failOverReadOnly=false&allow
username: block
password: Block@2024#03
mybatis-plus:
configuration:
map-underscore-to-camel-case: true
executor-type: BATCH
incomplete-statements:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 显示完整sql语句
mybatis:
executor-type: batch
... ...
__ __ _____ _ _ _____ __ __ _____ _______ ______ __ __
\ \ / / |_ _| | \ | | / ____| \ \ / / / ____| |__ __| | ____| | \/ |
\ \ /\ / / | | | \| | | (___ \ \_/ / | (___ | | | |__ | \ / |
\ \/ \/ / | | | . ` | \___ \ \ / \___ \ | | | __| | |\/| |
\ /\ / _| |_ | |\ | ____) | | | ____) | | | | |____ | | | |
\/ \/ |_____| |_| \_| |_____/ |_| |_____/ |_| |______| |_| |_|
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.yrhl.syncdata.mapper.local.CourseOneMapper">
<select id="getList" resultType="org.yrhl.syncdata.domain.BusinessDataResultsEntity">
select * from business_data_results where create_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 DAY) AND DATE_SUB(CURDATE(), INTERVAL 1 SECOND);
</select>
<select id="getBlockSourceDataEntityList" resultType="org.yrhl.syncdata.domain.BlockSourceDataEntity">
select * from block_source_data where create_date BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 DAY) AND DATE_SUB(CURDATE(), INTERVAL 1 SECOND);
</select>
<select id="getBlockNewSourceDataEntityList" resultType="org.yrhl.syncdata.domain.BlockNewSourceDataEntity">
select * from block_new_source_data ;
</select>
<select id="getAllinonepushresultsEntityList" resultType="org.yrhl.syncdata.domain.AllinonepushresultsEntity">
select * from allinonepushresults where CreateTime BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 DAY) AND DATE_SUB(CURDATE(), INTERVAL 1 SECOND);
</select>
<select id="getSyncTableList" resultType="org.yrhl.syncdata.domain.SyncTable">
select TableName from sync_table where isDelete=0 ;
</select>
<select id="getSyncResultListForWaitForAllinonepushresults" resultType="org.yrhl.syncdata.domain.SyncResult" parameterType="string">
SELECT
#{tableName} as TableName ,a.Id as InfoId ,a.CreateTime AS DateCreateTime,0 AS STATUS,now() AS CreateDateTime,now() AS UpdateTime
FROM ${tableName} a
WHERE
a.CreateTime >( SELECT IF ( max( datecreatetime ) IS NULL, '2024-09-01 00:00:00', max( datecreatetime )) FROM sync_result sr WHERE sr.TableName = #{tableName} )
ORDER BY
a.CreateTime
LIMIT #{page},
#{size}
</select>
<select id="isExist" resultType="int" parameterType="long">
SELECT count(1) from sync_result where InfoId=#{infoId}
</select>
<select id="getSyncResultListForWait" resultType="org.yrhl.syncdata.domain.SyncResult" parameterType="string">
SELECT
#{tableName} as TableName ,a.Id as InfoId ,a.create_date AS DateCreateTime,0 AS STATUS,now() AS CreateDateTime,now() AS UpdateTime
FROM ${tableName} a
WHERE
a.create_date >( SELECT IF ( max( datecreatetime ) IS NULL, '2024-01-01 00:00:00', max( datecreatetime )) FROM sync_result sr WHERE sr.TableName = #{tableName} )
ORDER BY
a.create_date
LIMIT #{page},
#{size}
</select>
<insert id="insertSyncResult">
INSERT INTO sync_result (
Id,
TableName,
InfoId,
DateCreateTime,
Status,
CreateDateTime,
UpdateTime
)
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.id},
#{item.TableName},
#{item.InfoId},
#{item.DateCreateTime},
0,
#{item.CreateDateTime},
#{item.UpdateTime}
)
</foreach>
</insert>
<update id="updateSyncResult" parameterType="long" >
UPDATE sync_result
SET Status =1
WHERE InfoId = #{infoId}
</update>
<update id="updateSyncResultFail" parameterType="long" >
UPDATE sync_result
SET Status =-1
WHERE InfoId = #{infoId}
</update>
<select id="getSyncTableList" resultType="org.yrhl.syncdata.domain.SyncTable">
select * from sync_table where isDelete=0 ;
</select>
<select id="getSyncResultListForWaitForConsumer" resultType="org.yrhl.syncdata.domain.AllinonepushresultsEntity" parameterType="string">
select * from ${tableName} a where a.Id in(select InfoId from sync_result where TableName =#{tableName} and Status !=1) order by a.CreateTime asc limit #{page},#{size}
</select>
<select id="getSyncResultListForWaitForOtherConsumer" resultType="map" parameterType="string">
select * from ${tableName} a where a.Id in(select InfoId from sync_result where TableName =#{tableName} and Status !=1) order by a.create_date asc limit #{page},#{size}
</select>
<select id="isExesit" resultType="int" parameterType="long">
select count(1) from sync_result where InfoId=#{infoId}
</select>
</mapper>
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.yrhl.syncdata.mapper.remote.CourseTwoMapper">
<insert id="insertBusinessDataResultsBatch">
INSERT INTO business_data_results (id,
platform_code,
pubservice_plat_code,
system_code,
tender_project_id,
module,
tender_flow_key,
op_type,
table_name,
table_info_id,
data_value,
block_chain_prev,
block_chain_hash,
block_chain_url,
status,
block_num,
creator,
create_date )
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.id},
#{item.platformCode},
#{item.pubservicePlatCode},
#{item.systemCode},
#{item.tenderProjectId},
#{item.module},
#{item.tenderFlowKey},
#{item.opType},
#{item.tableName},
#{item.tableInfoId},
#{item.dataValue},
#{item.blockChainPrev},
#{item.blockChainHash},
#{item.blockChainUrl},
#{item.status},
#{item.blockNum},
#{item.creator},
#{item.createDate} )
</foreach>
</insert>
<insert id="insertBlockSourceDataEntityBatch">
INSERT INTO block_source_data (id,
platform_code,
pubservice_plat_code,
system_code,
tender_project_id,
module,
tender_flow_key,
op_type,
table_name,
table_info_id,
block_chain_prev,
block_chain_hash,
block_chain_url,
sign_value,
data,
des_data,
status,
ip,
create_date,
update_date,
creator,
bid_section_codes,
block_chain_time,
is_push )
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.id},
#{item.platformCode},
#{item.pubservicePlatCode},
#{item.systemCode},
#{item.tenderProjectId},
#{item.module},
#{item.tenderFlowKey},
#{item.opType},
#{item.tableName},
#{item.tableInfoId},
#{item.blockChainPrev},
#{item.blockChainHash},
#{item.blockChainUrl},
#{item.signValue},
#{item.data},
#{item.desData},
#{item.status},
#{item.ip},
#{item.createDate},
#{item.updateDate},
#{item.creator},
#{item.bidSectionCodes},
#{item.blockChainTime},
#{item.isPush} )
</foreach>
</insert>
<insert id="insertBlockNewSourceDataEntityBatch">
INSERT INTO block_new_source_data (id,
platform_code,
pub_service_plat_code,
system_code,
block_chain_prev,
data,
des_data,
callback_url,
ip,
create_date,
creator,
tender_project_id,
module,
tender_flow_key,
op_type,
table_name,
table_info_id,
datas_type
)
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.id},
#{item.platformCode},
#{item.pubServicePlatCode},
#{item.systemCode},
#{item.blockChainPrev},
#{item.data},
#{item.desData},
#{item.callbackUrl},
#{item.ip},
#{item.createDate},
#{item.creator},
#{item.tenderProjectId},
#{item.module},
#{item.tenderFlowKey},
#{item.opType},
#{item.tableName},
#{item.tableInfoId},
#{item.datasType}
)
</foreach>
</insert>
<insert id="insertAllinonepushresultsEntityBatch">
INSERT INTO allinonepushresults (id,
TenderProjectId,
Module,
TableName,
InfoId,
Success,
SendData,
OpType,
CreateTime,
UpdateTime,
Remark,
TenderFlowKey,
PushInfo,
DesData,
MqKey
)
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.id},
#{item.tenderprojectid},
#{item.module},
#{item.tablename},
#{item.infoid},
#{item.success},
#{item.senddata},
#{item.optype},
#{item.createtime},
#{item.updatetime},
#{item.remark},
#{item.tenderflowkey},
#{item.pushInfo},
#{item.desData},
#{item.mqKey}
)
</foreach>
</insert>
<select id="isExist" resultType="int" parameterType="long" >
select count(1) from ${tableName} where Id=#{infoId}
</select>
</mapper>
\ No newline at end of file
... ...
<html>
<body>
<h1>hello word!!!</h1>
<p>this is a html page</p>
</body>
</html>
\ No newline at end of file
... ...
package org.yrhl.syncdata;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class SyncDataApplicationTests {
@Test
void contextLoads() {
}
}
... ...