提交 74f5839f authored 作者: 孙于凯's avatar 孙于凯

Initial commit

上级
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/
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
差异被折叠。
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Apache Maven Wrapper startup batch script, version 3.2.0
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %WRAPPER_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file
SET WRAPPER_SHA_256_SUM=""
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B
)
IF NOT %WRAPPER_SHA_256_SUM%=="" (
powershell -Command "&{"^
"$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^
"If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^
" Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^
" Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^
" Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^
" exit 1;"^
"}"^
"}"
if ERRORLEVEL 1 goto error
)
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%MAVEN_JAVA_EXE% ^
%JVM_CONFIG_MAVEN_PROPS% ^
%MAVEN_OPTS% ^
%MAVEN_DEBUG_OPTS% ^
-classpath %WRAPPER_JAR% ^
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%"=="on" pause
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
cmd /C exit /B %ERROR_CODE%
<?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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.tykj</groupId>
<artifactId>transfer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>yl-transfer</name>
<description>yl-transfer</description>
<properties>
<java.version>8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.10</version>
</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-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.github.wenhao</groupId>
<artifactId>jpa-spec</artifactId>
<version>3.1.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
package com.tykj.transfer.SlaveDao;
import com.tykj.transfer.pojo.Biz088DcActivityStatistics;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
public interface Biz088DcActivityStatisticsDao extends JpaRepository<Biz088DcActivityStatistics, Long> {
}
package com.tykj.transfer.SlaveDao;
import com.tykj.transfer.pojo.Biz088DcNetworkStatistics;
import org.springframework.data.jpa.repository.JpaRepository;
public interface Biz088DcNetworkStatisticsDao extends JpaRepository<Biz088DcNetworkStatistics, Long> {
}
package com.tykj.transfer.SlaveService;
public interface Biz088DcActivityStatisticsService {
void transferActivity();
}
package com.tykj.transfer.SlaveService;
public interface Biz088DcNetworkStatisticsService {
void transferBranch();
}
package com.tykj.transfer.SlaveService.impl;
import com.alibaba.druid.util.StringUtils;
import com.tykj.transfer.SlaveDao.Biz088DcActivityStatisticsDao;
import com.tykj.transfer.SlaveService.Biz088DcActivityStatisticsService;
import com.tykj.transfer.dao.ActivitiesDao;
import com.tykj.transfer.entity.Activity;
import com.tykj.transfer.entity.Branches;
import com.tykj.transfer.pojo.Biz088DcActivityStatistics;
import com.tykj.transfer.pojo.Biz088DcNetworkStatistics;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;
@Service
@Slf4j
public class Biz088DcActivityStatisticsServiceImpl implements Biz088DcActivityStatisticsService {
@Resource
private ActivitiesDao activitiesDao;
@Resource
private Biz088DcActivityStatisticsDao biz088DcActivityStatisticsDao;
@Override
public void transferActivity() {
List<Activity> all = activitiesDao.findAll();
Date date = new Date();
List<Biz088DcActivityStatistics> rs=new ArrayList<>();
for (Activity activity : all) {
// 检查数据库是否已存在的对象
Optional<Biz088DcActivityStatistics> byId = biz088DcActivityStatisticsDao.findById(activity.getId());
if (byId.isPresent()) {
// 如果已存在,进行更新操作
Biz088DcActivityStatistics biz088DcActivityStatistics = byId.get();
BeanUtils.copyProperties(activity, biz088DcActivityStatistics);
biz088DcActivityStatisticsDao.save(biz088DcActivityStatistics);
} else {
// 否则,进行保存操作
Biz088DcActivityStatistics newObj = new Biz088DcActivityStatistics();
BeanUtils.copyProperties(activity, newObj);
newObj.setBizTime(date);
newObj.setLoadTime(date);
if(!StringUtils.equals(activity.getDataActiveStatus(), "1")) {
newObj.setOp("delete");
}
newObj.setTongTime(date);
newObj.setTongId(0L);
rs.add(newObj);
}
}
if (!rs.isEmpty()) {
biz088DcActivityStatisticsDao.saveAll(rs);
}
log.info("活动转移完成");
}
}
package com.tykj.transfer.SlaveService.impl;
import com.alibaba.druid.util.StringUtils;
import com.tykj.transfer.SlaveDao.Biz088DcNetworkStatisticsDao;
import com.tykj.transfer.SlaveService.Biz088DcNetworkStatisticsService;
import com.tykj.transfer.dao.BranchesDao;
import com.tykj.transfer.entity.Branches;
import com.tykj.transfer.pojo.Biz088DcNetworkStatistics;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;
@Service
@Slf4j
public class Biz088DcBranchTrainStatisticsImpl implements Biz088DcNetworkStatisticsService {
@Resource
private BranchesDao branchesDao;
@Resource
private Biz088DcNetworkStatisticsDao biz088DcNetworkStatisticsDao;
@Override
public void transferBranch() {
List<Branches> all = branchesDao.findAll();
Date date = new Date();
List<Biz088DcNetworkStatistics> rs=new ArrayList<>();
for (Branches branches : all) {
// 检查数据库是否已存在的对象
Optional<Biz088DcNetworkStatistics> byId = biz088DcNetworkStatisticsDao.findById(branches.getId());
if (byId.isPresent()) {
// 如果已存在,进行更新操作
Biz088DcNetworkStatistics biz088DcBranchTrainStatistics = byId.get();
BeanUtils.copyProperties(branches, biz088DcBranchTrainStatistics);
biz088DcNetworkStatisticsDao.save(biz088DcBranchTrainStatistics);
} else {
// 否则,进行保存操作
Biz088DcNetworkStatistics newObj = new Biz088DcNetworkStatistics();
BeanUtils.copyProperties(branches, newObj);
newObj.setBizTime(date);
newObj.setLoadTime(date);
if(!StringUtils.equals(branches.getDataActiveStatus(), "1")) {
newObj.setOp("delete");
}
newObj.setTongTime(date);
newObj.setTongId(0L);
rs.add(newObj);
}
}
if (!rs.isEmpty()) {
biz088DcNetworkStatisticsDao.saveAll(rs);
}
log.info("网点转移完成");
}
}
package com.tykj.transfer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@SpringBootApplication
@EnableJpaAuditing
@EnableSwagger2
@EnableTransactionManagement
@EnableScheduling
@EnableCaching
@ComponentScan(basePackages = {"com.tykj.transfer.*"})
public class YlTransferApplication {
public static void main(String[] args) {
SpringApplication.run(YlTransferApplication.class, args);
}
}
package com.tykj.transfer.config;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import javax.sql.DataSource;
@ComponentScan
@Configuration
@Slf4j
public class DataSourceConfig {
/**
* pre_dc
*/
@Primary
@Bean(name = "locationDataSource")
@Qualifier("locationDataSource")
@ConfigurationProperties(prefix = "spring.datasource.local")
public DataSource primaryDataSource() {
log.info("本地数据源创建中————");
return DruidDataSourceBuilder.create()
.build();
}
/**
* bus_internal_activity
*/
@Bean(name = "remoteDataSource1")
@Qualifier("remoteDataSource1")
@ConfigurationProperties(prefix="spring.datasource.remote1")
public DataSource secondaryDataSource1() {
log.info("远程数据源创建中————");
return DruidDataSourceBuilder.create()
.build();
}
}
package com.tykj.transfer.config;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateProperties;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateSettings;
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManager;
import javax.sql.DataSource;
import java.util.Map;
@SuppressWarnings({"SpringAutowiredFieldsWarningInspection", "SpringComponentScan"})
@Slf4j
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
entityManagerFactoryRef = "entityManagerFactoryLocation",
transactionManagerRef = "transactionManagerLocation",
basePackages = {"com.tykj.transfer.Slavedao"}
)
@EnableConfigurationProperties(JpaProperties.class)
public class LocationConfig {
@Autowired
@Qualifier("locationDataSource")
private DataSource locationDataSource;
@Autowired
private JpaProperties jpaProperties;
@Autowired
private HibernateProperties properties;
@Primary
@Bean(name = "entityManagerLocation")
public EntityManager entityManager(EntityManagerFactoryBuilder builder) {
return entityManagerFactoryLocation(builder).getObject().createEntityManager();
}
@Primary
@Bean(name = "entityManagerFactoryLocation")
public LocalContainerEntityManagerFactoryBean entityManagerFactoryLocation(EntityManagerFactoryBuilder builder) {
log.info("本地数据源:" + locationDataSource);
return builder
.dataSource(locationDataSource)
.properties(properties.determineHibernateProperties(jpaProperties.getProperties(), new
HibernateSettings()))
.packages("com.tykj.transfer.pojo")
.persistenceUnit("locationPersistenceUnit")
.build();
}
private Map<String, String> getVendorProperties() {
return jpaProperties.getProperties();
}
@Primary
@Bean(name = "transactionManagerLocation")
public PlatformTransactionManager transactionManagerLocation(EntityManagerFactoryBuilder builder) {
return new JpaTransactionManager(entityManagerFactoryLocation(builder).getObject());
}
}
package com.tykj.transfer.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateProperties;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateSettings;
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManager;
import javax.sql.DataSource;
import java.util.Map;
@SuppressWarnings("ALL")
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
entityManagerFactoryRef = "entityManagerFactoryRemote1",
transactionManagerRef = "transactionManagerRemote1",
basePackages = {"com.tykj.transfer.dao"}
)
@EnableConfigurationProperties(JpaProperties.class)
public class RemoteConfig1 {
@Autowired
@Qualifier("remoteDataSource1")
private DataSource remoteDataSource;
@Autowired
private HibernateProperties properties;
@Bean(name = "entityManagerRemote1")
public EntityManager entityManager(EntityManagerFactoryBuilder builder) {
return entityManagerFactoryRemote1(builder).getObject().createEntityManager();
}
@Bean(name = "entityManagerFactoryRemote1")
public LocalContainerEntityManagerFactoryBean entityManagerFactoryRemote1(EntityManagerFactoryBuilder builder) {
return builder
.dataSource(remoteDataSource)
.properties(properties.determineHibernateProperties(jpaProperties.getProperties(), new
HibernateSettings()))
.packages("com.tykj.transfer.entity")
.persistenceUnit("remotePersistenceUnit1")
.build();
}
@Autowired
private JpaProperties jpaProperties;
private Map<String, String> getVendorProperties() {
return jpaProperties.getProperties();
}
@Bean(name = "transactionManagerRemote1")
public PlatformTransactionManager transactionManagerRemote(EntityManagerFactoryBuilder builder) {
return new JpaTransactionManager(entityManagerFactoryRemote1(builder).getObject());
}
}
package com.tykj.transfer.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.ArrayList;
/**
* @author syk
*/
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket docket(Environment environment)
{
Profiles profiles= Profiles.of("dev","test");
boolean flag = environment.acceptsProfiles(profiles);
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.enable(flag)
.select()
.apis(RequestHandlerSelectors.basePackage("com.tykj.transfer.controller"))
.build();
}
private ApiInfo apiInfo()
{
Contact contact = new Contact("syk", "https://www.cnblogs.com/sykswagger", "1172648124@qq.com");
return new ApiInfo(
"这里对应 Api Documentation",
"这里对应 Api Documentation",
"这里对应 v1.0",
"https://www.cnblogs.com/sykswagger",
contact,
"Apache 2.0",
"http://www.apache.org/licenses/LICENSE-2.0",
new ArrayList());
}
}
package com.tykj.transfer.controller;
import com.tykj.transfer.SlaveService.Biz088DcActivityStatisticsService;
import com.tykj.transfer.SlaveService.Biz088DcNetworkStatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* @author syk
*/
@Api(tags = "银铃活动 网点数据转移")
@RestController
@RequestMapping("/yl")
public class transferController {
@Resource
private Biz088DcNetworkStatisticsService biz088DcBranchTrainStatisticsService;
@Resource
private Biz088DcActivityStatisticsService biz088DcActivityStatisticsService;
@GetMapping("/tranBranch")
@ApiOperation("网点数据转移")
public void tranBranch() {
biz088DcBranchTrainStatisticsService.transferBranch();
}
@GetMapping("/tranActivity")
@ApiOperation("活动数据转移")
public void tranActivity() {
biz088DcActivityStatisticsService.transferActivity();
}
}
package com.tykj.transfer.dao;
import com.tykj.transfer.entity.Activity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Set;
/**
* <h4>Description : </h4>
*
* @Author czq
* @Date 5/30/21 10:17 AM
* @Version 1.0
*/
public interface ActivitiesDao extends JpaRepository<Activity, Long> {
}
package com.tykj.transfer.dao;
import com.tykj.transfer.entity.Branches;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* <h4>Description : </h4>
*
* @Author czq
* @Date 5/30/21 10:19 AM
* @Version 1.0
*/
public interface BranchesDao extends JpaRepository<Branches, Long> {
}
package com.tykj.transfer.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
/**
* entity class for activities
*/
@Data
@Entity
@ApiModel("活动")
@Table(name = "share_yl_activities", schema = "activities")
//@Where(clause = "DATA_ACTIVE_STATUS = '1'")
public class Activity {
/**
* id
*/
@Id
@Column(name = "id")
@ApiModelProperty(name = "id")
private Long id;
/**
* 活动标题
*/
@Column(name = "title")
@ApiModelProperty(name = "活动标题")
private String title;
/**
* 封面
*/
@Column(name = "cover")
@ApiModelProperty(name = "封面")
private String cover;
/**
* 活动编码
*/
@Column(name = "code")
@ApiModelProperty(name = "活动编码")
private String code;
/**
* 活动类型 1线上2线下
*/
@Column(name = "type")
@ApiModelProperty(name = "活动类型 1线上2线下")
private String type;
/**
* 活动区域
*/
@Column(name = "area")
@ApiModelProperty(name = "活动区域")
private String area;
/**
* 详细地点
*/
@Column(name = "address")
@ApiModelProperty(name = "详细地点")
private String address;
/**
* 服务类别...
*/
@Column(name = "service_type")
@ApiModelProperty(name = "服务类别...")
private String serviceType;
/**
* 服务对象
*/
@Column(name = "service_obj")
@ApiModelProperty(name = "服务对象")
private String serviceObj;
/**
* 关联项目
*/
@Column(name = "project")
@ApiModelProperty(name = "关联项目")
private String project;
/**
* 主办单位
*/
@Column(name = "organizer")
@ApiModelProperty(name = "主办单位")
private String organizer;
/**
* 承办单位
*/
@Column(name = "contractor")
@ApiModelProperty(name = "承办单位")
private String contractor;
/**
* 协办单位
*/
@Column(name = "sponsor")
@ApiModelProperty(name = "协办单位")
private String sponsor;
/**
* 发布时间
*/
@Column(name = "release_time")
@ApiModelProperty(name = "发布时间")
private Date releaseTime;
/**
* 招募时间
*/
@Column(name = "recruit_time")
@ApiModelProperty(name = "招募时间")
private Date recruitTime;
/**
* 招募人数
*/
@Column(name = "recruit_number")
@ApiModelProperty(name = "招募人数")
private Integer recruitNumber;
/**
* 活动时间
*/
@Column(name = "activity_time")
@ApiModelProperty(name = "活动时间")
private Date activityTime;
/**
* 活动结束时间
*/
@Column(name = "activity_time_end")
@ApiModelProperty(name = "活动结束时间")
private Date activityTimeEnd;
/**
* 活动简介
*/
@Column(name = "introduction")
@ApiModelProperty(name = "活动简介")
private String introduction;
/**
* 活动要求
*/
@Column(name = "claim")
@ApiModelProperty(name = "活动要求")
private String claim;
/**
* 所属组织
*/
@Column(name = "adscription_org")
@ApiModelProperty(name = "所属组织")
private String adscriptionOrg;
/**
* 联系人
*/
@Column(name = "contact_person")
@ApiModelProperty(name = "联系人")
private String contactPerson;
/**
* 联系电话
*/
@Column(name = "contact_phone")
@ApiModelProperty(name = "联系电话")
private String contactPhone;
/**
* 联系邮箱
*/
@Column(name = "contact_email")
@ApiModelProperty(name = "联系邮箱")
private String contactEmail;
/**
* 网点id
*/
@Column(name = "branch_id")
@ApiModelProperty(name = "网点id")
private Long branchId;
/**
* 是否签到
*/
@Column(name = "is_sign")
@ApiModelProperty(name = "是否签到")
private Boolean isSign;
/**
* 签到精度/单位米
*/
@Column(name = "sign_precision")
@ApiModelProperty(name = "签到精度/单位米")
private Integer signPrecision;
/**
* 活动状态
*/
@Column(name = "status")
@ApiModelProperty(name = "活动状态")
private Integer status;
/**
* 纬度
*/
@Column(name = "latitude")
@ApiModelProperty(name = "纬度")
private String latitude;
/**
* 经度
*/
@Column(name = "longitude")
@ApiModelProperty(name = "经度")
private String longitude;
/**
* 人数限制0不限制
*/
@Column(name = "people_number")
@ApiModelProperty(name = "人数限制0不限制")
private Integer peopleNumber;
/**
* createdAt
*/
@Column(name = "created_at")
@ApiModelProperty(name = "null")
private Date createdAt;
/**
* updatedAt
*/
@Column(name = "updated_at")
@ApiModelProperty(name = "null")
private Date updatedAt;
/**
* 发布管理员
*/
@Column(name = "admin_id")
@ApiModelProperty(name = "发布管理员")
private Integer adminId;
/**
* 状态 1:正常 0:已删除
*/
@Column(name = "DATA_ACTIVE_STATUS")
@ApiModelProperty(name = "状态 1:正常 0:已删除")
private String dataActiveStatus;
@Column(name = "DATA_EXCEPTION")
private String dataException;
@Column(name = "DATA_STATE")
private String dataState;
@Column(name = "DATA_UPDATE_TIME")
private String dataUpdateTime;
}
package com.tykj.transfer.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.*;
import java.util.Date;
/**
* entity class for branches
*/
@Data
@Entity
@ApiModel("网点")
@Table(name = "share_yl_branches",schema = "branches")
//@Where(clause = "DATA_ACTIVE_STATUS = '1'")
public class Branches {
/**
* id
*/
@Id
@Column(name = "id")
@ApiModelProperty(name = "id")
private Long id;
/**
* 关联的平台用户
*/
@Column(name = "uid")
@ApiModelProperty(name = "关联的平台用户")
private Integer uid;
/**
* 申请的网点名
*/
@Column(name = "name")
@ApiModelProperty(name = "申请的网点名")
private String name;
/**
* 网点地址
*/
@Column(name = "address")
@ApiModelProperty(name = "网点地址")
private String address;
/**
* 联系人
*/
@Column(name = "contact_person")
@ApiModelProperty(name = "联系人")
private String contactPerson;
/**
* 联系电话
*/
@Column(name = "contact_phone")
@ApiModelProperty(name = "联系电话")
private String contactPhone;
// /**
// * 单位类型1中国科协2全国学会3地方科协
// */
// @Column(name = "unit_type")
// @ApiModelProperty(name = "单位类型1中国科协2全国学会3地方科协")
// private Boolean unitType;
/**
* 单位类型1中国科协2全国学会3地方科协
*/
@Column(name = "unit_type")
@ApiModelProperty(name = "单位类型1中国科协2全国学会3地方科协")
private Integer unitType;
/**
* 单位名称
*/
@Column(name = "unit_name")
@ApiModelProperty(name = "单位名称")
private String unitName;
/**
* 容量
*/
@Column(name = "capacity")
@ApiModelProperty(name = "容量")
private String capacity;
/**
* createdAt
*/
@Column(name = "created_at")
@ApiModelProperty(name = "null")
private Date createdAt;
/**
* updatedAt
*/
@Column(name = "updated_at")
@ApiModelProperty(name = "null")
private Date updatedAt;
/**
* 封面
*/
@Column(name = "cover")
@ApiModelProperty(name = "封面")
private String cover;
/**
* 纬度
*/
@Column(name = "latitude")
@ApiModelProperty(name = "纬度")
private String latitude;
/**
* 经度
*/
@Column(name = "longitude")
@ApiModelProperty(name = "经度")
private String longitude;
/**
* 街道
*/
@Column(name = "street")
@ApiModelProperty(name = "街道")
private String street;
/**
* 所在区330101
*/
@Column(name = "area")
@ApiModelProperty(name = "所在区330101")
private String area;
/**
* 队长姓名
*/
@Column(name = "leader_name")
@ApiModelProperty(name = "队长姓名")
private String leaderName;
/**
* 队长电话
*/
@Column(name = "leader_phone")
@ApiModelProperty(name = "队长电话")
private String leaderPhone;
/**
* 成立日期
*/
@Column(name = "found_date")
@ApiModelProperty(name = "成立日期")
private Date foundDate;
/**
* 网点详细地址
*/
@Column(name = "full_address")
@ApiModelProperty(name = "网点详细地址")
private String fullAddress;
@Transient
@Column(name = "activityApplyNum")
@ApiModelProperty(name = "培训人数")
private Long activityApplyNum;
/**
* 状态 1:正常 0:已删除
*/
@Column(name = "DATA_ACTIVE_STATUS")
@ApiModelProperty(name = "状态 1:正常 0:已删除")
private String dataActiveStatus;
public void view(){
this.contactPerson = null;
this.contactPhone = null;
this.leaderName = null;
this.leaderPhone = null;
}
}
package com.tykj.transfer.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
* @author
* entity class for biz_088_dc_activity_statistics
* 银龄活动统计数据信息
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
//@IdClass(YlPrimaryKeyLong.class)
@Table(name = "biz_088_dc_activity_statistics")
public class Biz088DcActivityStatistics {
/**
* 主键
*/
@Id
@Column(name = "id")
private Long id;
/**
* 活动标题
*/
@Column(name = "title")
private String title;
/**
* 封面
*/
@Column(name = "cover")
private String cover;
/**
* 活动编码
*/
@Column(name = "code")
private String code;
/**
* 活动类型
*/
@Column(name = "type")
private String type;
/**
* 活动区域
*/
@Column(name = "area")
private String area;
/**
* 详细地点
*/
@Column(name = "address")
private String address;
/**
* 服务类别
*/
@Column(name = "service_type")
private String serviceType;
/**
* 服务对象
*/
@Column(name = "service_obj")
private String serviceObj;
/**
* 关联项目
*/
@Column(name = "project")
private String project;
/**
* 主办单位
*/
@Column(name = "organizer")
private String organizer;
/**
* 承办单位
*/
@Column(name = "contractor")
private String contractor;
/**
* 协办单位
*/
@Column(name = "sponsor")
private String sponsor;
/**
* 发布时间
*/
@Column(name = "release_time")
private Date releaseTime;
/**
* 招募时间
*/
@Column(name = "recruit_time")
private Date recruitTime;
/**
* 招募人数
*/
@Column(name = "recruit_number")
private Integer recruitNumber;
/**
* 活动时间
*/
@Column(name = "activity_time")
private Date activityTime;
/**
* 活动结束时间
*/
@Column(name = "activity_time_end")
private Date activityTimeEnd;
/**
* 活动简介
*/
@Column(name = "introduction", columnDefinition = "TEXT")
private String introduction;
/**
* 活动要求
*/
@Column(name = "claim")
private String claim;
/**
* 所属组织
*/
@Column(name = "adscription_org")
private String adscriptionOrg;
/**
* 联系人
*/
@Column(name = "contact_person")
private String contactPerson;
/**
* 联系电话
*/
@Column(name = "contact_phone")
private String contactPhone;
/**
* 联系邮箱
*/
@Column(name = "contact_email")
private String contactEmail;
/**
* 网点编号
*/
@Column(name = "branch_id")
private Integer branchId;
/**
* 是否签到
*/
@Column(name = "is_sign")
private Boolean isSign;
/**
* 签到精度
*/
@Column(name = "sign_precision")
private Integer signPrecision;
/**
* 活动状态
*/
@Column(name = "status")
private Integer status;
/**
* 纬度
*/
@Column(name = "latitude")
private String latitude;
/**
* 经度
*/
@Column(name = "longitude")
private String longitude;
/**
* 人数限制
*/
@Column(name = "people_number")
private Integer peopleNumber;
/**
* 数据创建时间
*/
@Column(name = "created_at")
private Date createdAt;
/**
* 数据更新时间
*/
@Column(name = "updated_at")
private Date updatedAt;
/**
* 发布管理员
*/
@Column(name = "admin_id")
private Integer adminId;
/**
* 业务库数据产生时间
*/
@Column(name = "Biz_time")
private Date bizTime;
/**
* 数据仓数据记录时间
*/
@Column(name = "load_time")
private Date loadTime;
/**
* op
*/
@Column(name = "op")
private String op;
/**
* tongTime
*/
@Column(name = "tong_time")
private Date tongTime;
/**
* tongId
*/
// @Id
@Column(name = "tongID")
private Long tongId;
}
package com.tykj.transfer.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
* @author
* entity class for biz_088_dc_network_statistics
* 银龄网点统计数据信息
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "biz_088_dc_network_statistics")
public class Biz088DcNetworkStatistics {
/**
* 主键
*/
@Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
/**
* 关联的平台用户
*/
@Column(name = "uid")
private Integer uid;
/**
* 申请的网点名
*/
@Column(name = "name")
private String name;
/**
* 网点地址
*/
@Column(name = "address")
private String address;
/**
* 联系人
*/
@Column(name = "contact_person")
private String contactPerson;
/**
* 联系电话
*/
@Column(name = "contact_phone")
private String contactPhone;
/**
* 单位类型
*/
@Column(name = "unit_type")
private Boolean unitType;
/**
* 单位名称
*/
@Column(name = "unit_name")
private String unitName;
/**
* 容量
*/
@Column(name = "capacity")
private String capacity;
/**
* 创建时间
*/
@Column(name = "created_at")
private Date createdAt;
/**
* 更新时间
*/
@Column(name = "updated_at")
private Date updatedAt;
/**
* 封面
*/
@Column(name = "cover")
private String cover;
/**
* 纬度
*/
@Column(name = "latitude")
private String latitude;
/**
* 经度
*/
@Column(name = "longitude")
private String longitude;
/**
* 街道
*/
@Column(name = "street")
private String street;
/**
* 所在区
*/
@Column(name = "area")
private String area;
/**
* 队长姓名
*/
@Column(name = "leader_name")
private String leaderName;
/**
* 队长电话
*/
@Column(name = "leader_phone")
private String leaderPhone;
/**
* 成立日期
*/
@Column(name = "found_date")
private Date foundDate;
/**
* 网点详细地址
*/
@Column(name = "full_address")
private String fullAddress;
/**
* 业务库数据产生时间
*/
@Column(name = "Biz_time")
private Date bizTime;
/**
* 数据仓数据记录时间
*/
@Column(name = "load_time")
private Date loadTime;
/**
* op
*/
@Column(name = "op")
private String op;
/**
* tongTime
*/
@Column(name = "tong_time")
private Date tongTime;
/**
* tongId
*/
@Column(name = "tongID")
private Long tongId;
}
package com.tykj.transfer.pojo;
import lombok.Data;
import java.io.Serializable;
@Data
public class YlPrimaryKeyLong implements Serializable {
private Long id;
private Long tongId;
}
package com.tykj.transfer.pojo;
import lombok.Data;
import java.io.Serializable;
@Data
public class YlPrimaryKeyString implements Serializable {
private String id;
private Long tongId;
}
server.port=8888
spring.datasource.local.username=root
spring.datasource.local.password=root
spring.datasource.local.url=jdbc:mysql://127.0.0.1:3306/test?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
spring.datasource.local.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.remote1.url = jdbc:mysql://192.168.100.232:3307/hp_kjgzzqz?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
spring.datasource.remote1.username = root
#spring.datasource.remote1.password = root
spring.datasource.remote1.password = tykj@2022
spring.datasource.remote1.driverClassName = com.mysql.cj.jdbc.Driver
spring.aop.proxy-target-class= true
spring.jpa.properties.hibernate.format_sql=true
spring.main.allow-bean-definition-overriding=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=false
\ No newline at end of file
package com.tykj.transfer;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class YlTransferApplicationTests {
@Test
void contextLoads() {
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论