Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
baihang-report
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
data-spider
baihang-report
Commits
738fdd7c
Commit
738fdd7c
authored
Mar 04, 2021
by
郑建
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
暂停定时任务报送
parent
f54043b0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
517 additions
and
520 deletions
+517
-520
XyqbHistoryDataSourceConfig.java
...onfig/datasource/history/XyqbHistoryDataSourceConfig.java
+84
-84
ExZhuDaiBaiHangReSendController.java
.../controller/external/ExZhuDaiBaiHangReSendController.java
+32
-35
QuantGroupZhuDaiReportToBaiHang.java
...uantgroup/report/job/QuantGroupZhuDaiReportToBaiHang.java
+2
-2
SynLoanInfoHistoryTask.java
...java/cn/quantgroup/report/job/SynLoanInfoHistoryTask.java
+399
-399
No files found.
src/main/java/cn/quantgroup/report/config/datasource/history/XyqbHistoryDataSourceConfig.java
View file @
738fdd7c
package
cn
.
quantgroup
.
report
.
config
.
datasource
.
history
;
//
package cn.quantgroup.report.config.datasource.history;
//
//
import
com.zaxxer.hikari.HikariConfig
;
//
import com.zaxxer.hikari.HikariConfig;
import
com.zaxxer.hikari.HikariDataSource
;
//
import com.zaxxer.hikari.HikariDataSource;
import
lombok.extern.slf4j.Slf4j
;
//
import lombok.extern.slf4j.Slf4j;
import
org.mybatis.spring.annotation.MapperScan
;
//
import org.mybatis.spring.annotation.MapperScan;
import
org.springframework.beans.factory.annotation.Autowired
;
//
import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Qualifier
;
//
import org.springframework.beans.factory.annotation.Qualifier;
import
org.springframework.beans.factory.annotation.Value
;
//
import org.springframework.beans.factory.annotation.Value;
import
org.springframework.context.annotation.Bean
;
//
import org.springframework.context.annotation.Bean;
import
org.springframework.context.annotation.Configuration
;
//
import org.springframework.context.annotation.Configuration;
import
org.springframework.context.annotation.Import
;
//
import org.springframework.context.annotation.Import;
import
org.springframework.jdbc.core.JdbcTemplate
;
//
import org.springframework.jdbc.core.JdbcTemplate;
import
org.springframework.jdbc.datasource.DataSourceTransactionManager
;
//
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
//
import
javax.sql.DataSource
;
//
import javax.sql.DataSource;
//
@Import
(
XyqbHistoryDataSourcePreperties
.
class
)
//
@Import(XyqbHistoryDataSourcePreperties.class)
@Configuration
//
@Configuration
@Slf4j
//
@Slf4j
@MapperScan
(
basePackages
=
XyqbHistoryDataSourceConfig
.
PACKAGE
,
sqlSessionFactoryRef
=
"xyqbHistorySqlSessionFactory"
)
//
@MapperScan(basePackages = XyqbHistoryDataSourceConfig.PACKAGE, sqlSessionFactoryRef = "xyqbHistorySqlSessionFactory")
public
class
XyqbHistoryDataSourceConfig
{
//
public class XyqbHistoryDataSourceConfig {
//
//
static
final
String
PACKAGE
=
"cn.quantgroup.report.mapper.history"
;
//
static final String PACKAGE = "cn.quantgroup.report.mapper.history";
//
@Value
(
"${baihang.mapper-locations2}"
)
//
@Value("${baihang.mapper-locations2}")
private
String
mapperLocations
;
//
private String mapperLocations;
//private String mapperLocations = "classpath:cn/quantgroup/report/mapper/history/*.xml";
//
//private String mapperLocations = "classpath:cn/quantgroup/report/mapper/history/*.xml";
//
@Value
(
"${baihang.type-aliases-package2}"
)
//
@Value("${baihang.type-aliases-package2}")
private
String
typeAliasesPackage
;
//
private String typeAliasesPackage;
//private String typeAliasesPackage = "cn.quantgroup.report.mapper.history";
//
//private String typeAliasesPackage = "cn.quantgroup.report.mapper.history";
//
@Value
(
"${config-location}"
)
//
@Value("${config-location}")
private
String
configLocation
;
//
private String configLocation;
//
@Autowired
//
@Autowired
private
XyqbHistoryDataSourcePreperties
xyqbHistoryDataSourcePreperties
;
//
private XyqbHistoryDataSourcePreperties xyqbHistoryDataSourcePreperties;
//
@Bean
(
name
=
"xyqbHistoryDataSource"
)
//
@Bean(name = "xyqbHistoryDataSource")
public
DataSource
xyqbHistoryDataSource
()
{
//
public DataSource xyqbHistoryDataSource() {
HikariConfig
config
=
new
HikariConfig
();
//
HikariConfig config = new HikariConfig();
config
.
setJdbcUrl
(
xyqbHistoryDataSourcePreperties
.
getJdbcUrl
());
//
config.setJdbcUrl(xyqbHistoryDataSourcePreperties.getJdbcUrl());
log
.
info
(
"xyqb历史数据库地址:{}"
,
xyqbHistoryDataSourcePreperties
.
getJdbcUrl
());
//
log.info("xyqb历史数据库地址:{}", xyqbHistoryDataSourcePreperties.getJdbcUrl());
config
.
setPassword
(
xyqbHistoryDataSourcePreperties
.
getPassword
());
//
config.setPassword(xyqbHistoryDataSourcePreperties.getPassword());
config
.
setUsername
(
xyqbHistoryDataSourcePreperties
.
getUsername
());
//
config.setUsername(xyqbHistoryDataSourcePreperties.getUsername());
config
.
setMaximumPoolSize
(
xyqbHistoryDataSourcePreperties
.
getMaxPoolSize
());
//
config.setMaximumPoolSize(xyqbHistoryDataSourcePreperties.getMaxPoolSize());
config
.
setMinimumIdle
(
xyqbHistoryDataSourcePreperties
.
getMinPoolSize
());
//
config.setMinimumIdle(xyqbHistoryDataSourcePreperties.getMinPoolSize());
config
.
addDataSourceProperty
(
"cachePrepStmts"
,
"true"
);
//
config.addDataSourceProperty("cachePrepStmts", "true");
config
.
addDataSourceProperty
(
"prepStmtCacheSize"
,
"250"
);
//
config.addDataSourceProperty("prepStmtCacheSize", "250");
config
.
addDataSourceProperty
(
"prepStmtCacheSqlLimit"
,
"2048"
);
//
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
return
new
HikariDataSource
(
config
);
//
return new HikariDataSource(config);
}
//
}
//
@Bean
(
name
=
"xyqbHistoryTransactionManager"
)
//
@Bean(name = "xyqbHistoryTransactionManager")
public
DataSourceTransactionManager
xyqbHistoryTransactionManager
(
@Qualifier
(
"xyqbHistoryDataSource"
)
DataSource
xyqbHistoryDataSource
)
{
//
public DataSourceTransactionManager xyqbHistoryTransactionManager(@Qualifier("xyqbHistoryDataSource") DataSource xyqbHistoryDataSource) {
return
new
DataSourceTransactionManager
(
xyqbHistoryDataSource
);
//
return new DataSourceTransactionManager(xyqbHistoryDataSource);
}
//
}
//
/* @Bean(name = "xyqbHistorySqlSessionFactory")
//
/* @Bean(name = "xyqbHistorySqlSessionFactory")
public SqlSessionFactory xyqbHistorySqlSessionFactory(@Qualifier("xyqbHistoryDataSource") DataSource xyqbHistoryDataSource) throws Exception {
//
public SqlSessionFactory xyqbHistorySqlSessionFactory(@Qualifier("xyqbHistoryDataSource") DataSource xyqbHistoryDataSource) throws Exception {
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
//
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(xyqbHistoryDataSource);
//
sessionFactory.setDataSource(xyqbHistoryDataSource);
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
//
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
.getResources(mapperLocations));
//
.getResources(mapperLocations));
sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
//
sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
sessionFactory.setConfigLocation(new PathMatchingResourcePatternResolver()
//
sessionFactory.setConfigLocation(new PathMatchingResourcePatternResolver()
.getResource(configLocation));
//
.getResource(configLocation));
return sessionFactory.getObject();
//
return sessionFactory.getObject();
}*/
//
}*/
/*
/
//
*
@Bean(name = "xyqbHistorySqlSessionTemplate")
//
@Bean(name = "xyqbHistorySqlSessionTemplate")
public SqlSessionTemplate xyqbHistorySqlSessionTemplate(@Qualifier("xyqbHistorySqlSessionFactory") SqlSessionFactory xyqbHistorySqlSessionFactory) throws Exception {
//
public SqlSessionTemplate xyqbHistorySqlSessionTemplate(@Qualifier("xyqbHistorySqlSessionFactory") SqlSessionFactory xyqbHistorySqlSessionFactory) throws Exception {
return new SqlSessionTemplate(xyqbHistorySqlSessionFactory);
//
return new SqlSessionTemplate(xyqbHistorySqlSessionFactory);
}*/
//
}*/
//
@Bean
(
name
=
"xyqbHistoryJdbcTemplate"
)
//
@Bean(name = "xyqbHistoryJdbcTemplate")
public
JdbcTemplate
primaryJdbcTemplate
(
@Qualifier
(
"xyqbHistoryDataSource"
)
DataSource
dataSource
)
{
//
public JdbcTemplate primaryJdbcTemplate(@Qualifier("xyqbHistoryDataSource") DataSource dataSource) {
return
new
JdbcTemplate
(
dataSource
);
//
return new JdbcTemplate(dataSource);
}
//
}
//
}
//
}
src/main/java/cn/quantgroup/report/controller/external/ExZhuDaiBaiHangReSendController.java
View file @
738fdd7c
package
cn
.
quantgroup
.
report
.
controller
.
external
;
package
cn
.
quantgroup
.
report
.
controller
.
external
;
import
cn.quantgroup.report.job.SynLoanInfoHistoryTask
;
import
cn.quantgroup.report.response.GlobalResponse
;
import
cn.quantgroup.report.response.GlobalResponse
;
import
cn.quantgroup.report.service.baihang.BaiHangZhuDaiService
;
import
cn.quantgroup.report.service.baihang.BaiHangZhuDaiService
;
import
cn.quantgroup.report.service.manualTool.ManualToolService
;
import
cn.quantgroup.report.service.manualTool.ManualToolService
;
...
@@ -41,22 +41,19 @@ public class ExZhuDaiBaiHangReSendController {
...
@@ -41,22 +41,19 @@ public class ExZhuDaiBaiHangReSendController {
@Autowired
@Autowired
BaiHangZhuDaiService
baiHangZhuDaiService
;
BaiHangZhuDaiService
baiHangZhuDaiService
;
@Autowired
private
SynLoanInfoHistoryTask
synLoanInfoHistoryTask
;
@Autowired
@Autowired
private
ManualToolService
manualToolService
;
private
ManualToolService
manualToolService
;
@RequestMapping
(
"/manual/synTable/historyAndplan"
)
//
@RequestMapping("/manual/synTable/historyAndplan")
public
String
historyAndplan
(
String
p3
,
String
secretKey
){
//
public String historyAndplan(String p3,String secretKey){
if
(
manualToolService
.
checkSecretKey
(
p3
,
secretKey
)){
//
if(manualToolService.checkSecretKey(p3,secretKey)){
//增量同步history和plan表数据
//
//增量同步history和plan表数据
synLoanInfoHistoryTask
.
syn_historyAndplan_by_id
();
//
synLoanInfoHistoryTask.syn_historyAndplan_by_id();
return
"historyAndplan任务调度完成"
;
//
return "historyAndplan任务调度完成";
}
else
{
//
}else{
return
"historyAndplan任务调度失败,参数错误"
;
//
return "historyAndplan任务调度失败,参数错误";
}
//
}
}
//
}
//存量整理公共方法
//存量整理公共方法
...
@@ -284,27 +281,27 @@ public class ExZhuDaiBaiHangReSendController {
...
@@ -284,27 +281,27 @@ public class ExZhuDaiBaiHangReSendController {
}
}
}
}
@RequestMapping
(
"/manual/syn_history_by_CreatedAt"
)
//
@RequestMapping("/manual/syn_history_by_CreatedAt")
public
String
syn_history_by_CreatedAt
(
String
p3
,
String
secretKey
){
//
public String syn_history_by_CreatedAt(String p3,String secretKey){
if
(
manualToolService
.
checkSecretKey
(
p3
,
secretKey
)){
//
if(manualToolService.checkSecretKey(p3,secretKey)){
//增量同步rc_real_time_data_pool_v2.xyqb_i_loan_application_manifest_history
//
//增量同步rc_real_time_data_pool_v2.xyqb_i_loan_application_manifest_history
synLoanInfoHistoryTask
.
syn_history_by_CreatedAt
();
//
synLoanInfoHistoryTask.syn_history_by_CreatedAt();
return
"syn_history_by_CreatedAt任务调度完成"
;
//
return "syn_history_by_CreatedAt任务调度完成";
}
else
{
//
}else{
return
"syn_history_by_CreatedAt任务调度失败,参数错误"
;
//
return "syn_history_by_CreatedAt任务调度失败,参数错误";
}
//
}
}
//
}
//
@RequestMapping
(
"/manual/syn_plan_by_CreatedAt"
)
//
@RequestMapping("/manual/syn_plan_by_CreatedAt")
public
String
syn_plan_by_CreatedAt
(
String
p3
,
String
secretKey
){
//
public String syn_plan_by_CreatedAt(String p3,String secretKey){
if
(
manualToolService
.
checkSecretKey
(
p3
,
secretKey
)){
//
if(manualToolService.checkSecretKey(p3,secretKey)){
//增量同步rc_real_time_data_pool_v2.xyqb_i_repayment_plan
//
//增量同步rc_real_time_data_pool_v2.xyqb_i_repayment_plan
synLoanInfoHistoryTask
.
syn_plan_by_CreatedAt
();
//
synLoanInfoHistoryTask.syn_plan_by_CreatedAt();
return
"syn_plan_by_CreatedAt任务调度完成"
;
//
return "syn_plan_by_CreatedAt任务调度完成";
}
else
{
//
}else{
return
"syn_plan_by_CreatedAt任务调度失败,参数错误"
;
//
return "syn_plan_by_CreatedAt任务调度失败,参数错误";
}
//
}
}
//
}
@RequestMapping
(
"/manual/d3CheckToJson"
)
@RequestMapping
(
"/manual/d3CheckToJson"
)
public
String
d3CheckToJson
(
String
p3
,
String
secretKey
,
String
filePath
){
public
String
d3CheckToJson
(
String
p3
,
String
secretKey
,
String
filePath
){
...
...
src/main/java/cn/quantgroup/report/job/QuantGroupZhuDaiReportToBaiHang.java
View file @
738fdd7c
...
@@ -39,8 +39,8 @@ public class QuantGroupZhuDaiReportToBaiHang {
...
@@ -39,8 +39,8 @@ public class QuantGroupZhuDaiReportToBaiHang {
@Autowired
@Autowired
private
BaiHangZhuDaiService
baiHangZhuDaiService
;
private
BaiHangZhuDaiService
baiHangZhuDaiService
;
@Autowired
//
@Autowired
private
SynLoanInfoHistoryTask
synLoanInfoHistoryTask
;
//
private SynLoanInfoHistoryTask synLoanInfoHistoryTask;
@Autowired
@Autowired
private
DingTalk
dingTalk
;
private
DingTalk
dingTalk
;
...
...
src/main/java/cn/quantgroup/report/job/SynLoanInfoHistoryTask.java
View file @
738fdd7c
package
cn
.
quantgroup
.
report
.
job
;
//
package cn.quantgroup.report.job;
//
import
cn.quantgroup.report.constant.BaiHangHistoryConstant
;
//
import cn.quantgroup.report.constant.BaiHangHistoryConstant;
import
cn.quantgroup.report.service.baihang.constant.Constant
;
//
import cn.quantgroup.report.service.baihang.constant.Constant;
import
cn.quantgroup.report.utils.dingtalk.DingTalk
;
//
import cn.quantgroup.report.utils.dingtalk.DingTalk;
import
com.google.common.base.Stopwatch
;
//
import com.google.common.base.Stopwatch;
import
org.slf4j.Logger
;
//
import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
//
import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
//
import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.data.redis.core.RedisTemplate
;
//
import org.springframework.data.redis.core.RedisTemplate;
import
org.springframework.jdbc.core.JdbcTemplate
;
//
import org.springframework.jdbc.core.JdbcTemplate;
import
org.springframework.scheduling.annotation.Async
;
//
import org.springframework.scheduling.annotation.Async;
import
org.springframework.scheduling.annotation.Scheduled
;
//
import org.springframework.scheduling.annotation.Scheduled;
import
org.springframework.stereotype.Component
;
//
import org.springframework.stereotype.Component;
//
import
java.time.LocalDateTime
;
//
import java.time.LocalDateTime;
import
java.time.format.DateTimeFormatter
;
//
import java.time.format.DateTimeFormatter;
import
java.util.concurrent.TimeUnit
;
//
import java.util.concurrent.TimeUnit;
import
java.util.concurrent.atomic.AtomicBoolean
;
//
import java.util.concurrent.atomic.AtomicBoolean;
//
//
/**
/
//
**
* -----------------------------------------------------------------------------<br>
//
* -----------------------------------------------------------------------------<br>
* 描述: 量化派助贷模式(非循环贷) -
//
* 描述: 量化派助贷模式(非循环贷) -
* (贷款申请/放款/还款(逾期)三类实时批量数据)-To百行报送<br>
//
* (贷款申请/放款/还款(逾期)三类实时批量数据)-To百行报送<br>
* 每日凌晨5点报送 <br>
//
* 每日凌晨5点报送 <br>
* 作者:yanhui.Hao <br>
//
* 作者:yanhui.Hao <br>
* 时间:2019.10.25 <br>
//
* 时间:2019.10.25 <br>
* 授权: (C) Copyright (c) 2017 <br>
//
* 授权: (C) Copyright (c) 2017 <br>
* 公司: 北京众信利民信息技术有限公司 <br>
//
* 公司: 北京众信利民信息技术有限公司 <br>
* -----------------------------------------------------------------------------
//
* -----------------------------------------------------------------------------
*/
//
*/
@Component
//
@Component
public
class
SynLoanInfoHistoryTask
{
//
public class SynLoanInfoHistoryTask {
//
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
SynLoanInfoHistoryTask
.
class
);
//
private static final Logger log = LoggerFactory.getLogger(SynLoanInfoHistoryTask.class);
//
@Autowired
//
@Autowired
private
RedisTemplate
<
String
,
String
>
redisTemplate
;
//
private RedisTemplate<String,String> redisTemplate;
//
//
@Autowired
////
@Autowired
private
JdbcTemplate
xyqbHistoryJdbcTemplate
;
////
private JdbcTemplate xyqbHistoryJdbcTemplate;
//
@Autowired
//
@Autowired
private
DingTalk
dingTalk
;
//
private DingTalk dingTalk;
//
private
static
AtomicBoolean
SYN_Stop
=
new
AtomicBoolean
(
false
);
//
private static AtomicBoolean SYN_Stop = new AtomicBoolean(false);
//
@Async
//
@Async
/*@Scheduled(cron = "0 0 05 * * ?")*/
//2019.11.15 15:25
//
/*@Scheduled(cron = "0 0 05 * * ?")*/ //2019.11.15 15:25
public
void
startHistoryDateCopy
(){
//
public void startHistoryDateCopy(){
if
(
increment
()){
//
if(increment()){
redisTemplate
.
expire
(
Constant
.
XYQB_HISTORY_DAI_REPORT_LOCK_KEY
,
10
,
TimeUnit
.
SECONDS
);
//
redisTemplate.expire(Constant.XYQB_HISTORY_DAI_REPORT_LOCK_KEY, 10, TimeUnit.SECONDS);
//
Stopwatch
stopwatch
=
Stopwatch
.
createStarted
();
//
Stopwatch stopwatch = Stopwatch.createStarted();
//yyyy-MM-dd
//
//yyyy-MM-dd
//String startnyr = LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ISO_DATE);
//
//String startnyr = LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ISO_DATE);
//String endnyr = LocalDateTime.now().format(DateTimeFormatter.ISO_DATE);
//
//String endnyr = LocalDateTime.now().format(DateTimeFormatter.ISO_DATE);
//
log
.
info
(
"量化派-同步表xyqb_i_loan_application_manifest_history数据开始, newTime: {} "
,
LocalDateTime
.
now
());
//
log.info("量化派-同步表xyqb_i_loan_application_manifest_history数据开始, newTime: {} ", LocalDateTime.now());
//
//将xyqb_i_loan_application_manifest_history表的数据,同步到xyqb_i_repayment_plan_bak
//
//将xyqb_i_loan_application_manifest_history表的数据,同步到xyqb_i_repayment_plan_bak
//syn_history_by_CreatedAt();
//
//syn_history_by_CreatedAt();
//
//将xyqb_i_repayment_plan表的数据,同步到xyqb_i_loan_a_m_history_bak
//
//将xyqb_i_repayment_plan表的数据,同步到xyqb_i_loan_a_m_history_bak
//syn_plan_by_CreatedAt();
//
//syn_plan_by_CreatedAt();
//
syn_historyAndplan_by_id
();
//
syn_historyAndplan_by_id();
//
////syn_history_p2p_bak();
//
////syn_history_p2p_bak();
////syn_plan_p2p_bak();
//
////syn_plan_p2p_bak();
//
log
.
info
(
"量化派-同步表xyqb_i_loan_application_manifest_history数据结束, endTime: {}, 耗时: {} "
,
LocalDateTime
.
now
(),
stopwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
));
//
log.info("量化派-同步表xyqb_i_loan_application_manifest_history数据结束, endTime: {}, 耗时: {} ", LocalDateTime.now(), stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
}
//
}
}
//
}
//
//
private
Boolean
increment
(){
//
private Boolean increment(){
Long
increment
=
redisTemplate
.
opsForValue
().
increment
(
Constant
.
XYQB_HISTORY_DAI_REPORT_LOCK_KEY
,
1
);
//
Long increment = redisTemplate.opsForValue().increment(Constant.XYQB_HISTORY_DAI_REPORT_LOCK_KEY, 1);
return
increment
<=
1
;
//
return increment <= 1;
}
//
}
//
//
public
void
syn_history_by_CreatedAt
(){
//
public void syn_history_by_CreatedAt(){
LocalDateTime
erlyDate
=
LocalDateTime
.
parse
(
"2016-08-23T00:00:00"
);
//created_at=2016-08-23T16:29:10 updated_at=2016-08-23 16:34:43
//
LocalDateTime erlyDate = LocalDateTime.parse("2016-08-23T00:00:00");//created_at=2016-08-23T16:29:10 updated_at=2016-08-23 16:34:43
LocalDateTime
endDate
=
LocalDateTime
.
parse
(
"2020-06-02T00:00:00"
);
//
//
LocalDateTime endDate = LocalDateTime.parse("2020-06-02T00:00:00");//
int
counter
=
0
;
//
int counter = 0;
while
(
true
)
{
//
while (true) {
Stopwatch
startwatch
=
Stopwatch
.
createStarted
();
//
Stopwatch startwatch = Stopwatch.createStarted();
//
if
(
SYN_Stop
.
get
())
{
//
if (SYN_Stop.get()) {
log
.
error
(
"同步xyqb_i_loan_application_manifest_history数据查询STOP, D3_Stop: {} , endTime: {} "
,
SYN_Stop
.
get
(),
erlyDate
.
plusDays
(
counter
).
format
(
DateTimeFormatter
.
ISO_DATE
));
//
log.error("同步xyqb_i_loan_application_manifest_history数据查询STOP, D3_Stop: {} , endTime: {} ", SYN_Stop.get(), erlyDate.plusDays(counter).format(DateTimeFormatter.ISO_DATE));
break
;
//
break;
}
//
}
counter
++;
//
counter++;
if
(
erlyDate
.
plusDays
(
counter
).
compareTo
(
endDate
)
>
0
)
{
//
if (erlyDate.plusDays(counter).compareTo(endDate) > 0) {
break
;
//
break;
}
//
}
//
String
starTime
=
erlyDate
.
plusDays
(
counter
-
1
).
format
(
DateTimeFormatter
.
ISO_DATE
);
//
String starTime = erlyDate.plusDays(counter - 1).format(DateTimeFormatter.ISO_DATE);
String
endTime
=
erlyDate
.
plusDays
(
counter
).
format
(
DateTimeFormatter
.
ISO_DATE
);
//
String endTime = erlyDate.plusDays(counter).format(DateTimeFormatter.ISO_DATE);
try
{
//
try {
String
tmp_sql
=
BaiHangHistoryConstant
.
SQL_COMMONE_TEMPLATE_HISTORY
;
//
String tmp_sql = BaiHangHistoryConstant.SQL_COMMONE_TEMPLATE_HISTORY;
tmp_sql
=
tmp_sql
.
replace
(
"##STARTTIME##"
,
starTime
);
//
tmp_sql = tmp_sql.replace("##STARTTIME##",starTime);
tmp_sql
=
tmp_sql
.
replace
(
"##ENDTIME##"
,
endTime
);
//
tmp_sql = tmp_sql.replace("##ENDTIME##",endTime);
//
int
upCount
=
xyqbHistoryJdbcTemplate
.
update
(
tmp_sql
);
//
int upCount = xyqbHistoryJdbcTemplate.update(tmp_sql);
log
.
info
(
"同步xyqb_i_loan_application_manifest_history数据结束,startTime: {} , 耗时:{} , updateCount: {} "
,
starTime
,
startwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
)+
".ms"
,
upCount
);
//
log.info("同步xyqb_i_loan_application_manifest_history数据结束,startTime: {} , 耗时:{} , updateCount: {} ", starTime, startwatch.stop().elapsed(TimeUnit.MILLISECONDS)+".ms", upCount);
//
}
catch
(
Exception
e
){
//
}catch (Exception e){
log
.
error
(
"同步xyqb_i_loan_application_manifest_history数据异常, startTime: {} , endTime: {} , counter: {} "
,
starTime
,
endTime
,
counter
,
e
);
//
log.error("同步xyqb_i_loan_application_manifest_history数据异常, startTime: {} , endTime: {} , counter: {} ", starTime, endTime,counter, e);
}
//
}
}
//
}
}
//
}
//
//
public
void
syn_plan_by_CreatedAt
(){
//
public void syn_plan_by_CreatedAt(){
LocalDateTime
erlyDate
=
LocalDateTime
.
parse
(
"2016-08-23T00:00:00"
);
//created_at=2016-08-23T16:29:10 updated_at=2016-08-23 16:34:43
//
LocalDateTime erlyDate = LocalDateTime.parse("2016-08-23T00:00:00");//created_at=2016-08-23T16:29:10 updated_at=2016-08-23 16:34:43
LocalDateTime
endDate
=
LocalDateTime
.
parse
(
"2020-06-02T00:00:00"
);
//
//
LocalDateTime endDate = LocalDateTime.parse("2020-06-02T00:00:00");//
int
counter
=
0
;
//
int counter = 0;
while
(
true
)
{
//
while (true) {
Stopwatch
startwatch
=
Stopwatch
.
createStarted
();
//
Stopwatch startwatch = Stopwatch.createStarted();
//
if
(
SYN_Stop
.
get
())
{
//
if (SYN_Stop.get()) {
log
.
error
(
"同步xyqb_i_repayment_plan数据查询STOP, D3_Stop: {} , endTime: {} "
,
SYN_Stop
.
get
(),
erlyDate
.
plusDays
(
counter
).
format
(
DateTimeFormatter
.
ISO_DATE
));
//
log.error("同步xyqb_i_repayment_plan数据查询STOP, D3_Stop: {} , endTime: {} ", SYN_Stop.get(), erlyDate.plusDays(counter).format(DateTimeFormatter.ISO_DATE));
break
;
//
break;
}
//
}
counter
++;
//
counter++;
if
(
erlyDate
.
plusDays
(
counter
).
compareTo
(
endDate
)
>
0
)
{
//
if (erlyDate.plusDays(counter).compareTo(endDate) > 0) {
break
;
//
break;
}
//
}
//
String
starTime
=
erlyDate
.
plusDays
(
counter
-
1
).
format
(
DateTimeFormatter
.
ISO_DATE
);
//
String starTime = erlyDate.plusDays(counter - 1).format(DateTimeFormatter.ISO_DATE);
String
endTime
=
erlyDate
.
plusDays
(
counter
).
format
(
DateTimeFormatter
.
ISO_DATE
);
//
String endTime = erlyDate.plusDays(counter).format(DateTimeFormatter.ISO_DATE);
try
{
//
try {
String
tmp_sql
=
BaiHangHistoryConstant
.
SQL_COMMONE_TEMPLATE_PLAN
;
//
String tmp_sql = BaiHangHistoryConstant.SQL_COMMONE_TEMPLATE_PLAN;
tmp_sql
=
tmp_sql
.
replace
(
"##STARTTIME##"
,
starTime
);
//
tmp_sql = tmp_sql.replace("##STARTTIME##",starTime);
tmp_sql
=
tmp_sql
.
replace
(
"##ENDTIME##"
,
endTime
);
//
tmp_sql = tmp_sql.replace("##ENDTIME##",endTime);
//
int
upCount
=
xyqbHistoryJdbcTemplate
.
update
(
tmp_sql
);
//
int upCount = xyqbHistoryJdbcTemplate.update(tmp_sql);
log
.
info
(
"同步xyqb_i_repayment_plan数据结束,startTime: {} , 耗时:{} , updateCount: {} "
,
starTime
,
startwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
)+
".ms"
,
upCount
);
//
log.info("同步xyqb_i_repayment_plan数据结束,startTime: {} , 耗时:{} , updateCount: {} ", starTime, startwatch.stop().elapsed(TimeUnit.MILLISECONDS)+".ms", upCount);
//
}
catch
(
Exception
e
){
//
}catch (Exception e){
log
.
error
(
"同步xyqb_i_repayment_plan数据异常, startTime: {} , endTime: {} , counter: {} "
,
starTime
,
endTime
,
counter
,
e
);
//
log.error("同步xyqb_i_repayment_plan数据异常, startTime: {} , endTime: {} , counter: {} ", starTime, endTime,counter, e);
}
//
}
}
//
}
}
//
}
//
//
private
boolean
syn_history_by_id
(
long
bakMaxId
,
long
newMaxId
){
//
private boolean syn_history_by_id(long bakMaxId,long newMaxId){
String
count_sql
=
BaiHangHistoryConstant
.
SQL_COMMONE_TEMPLATE_HISTORY_SYN_COUNT
;
//
String count_sql = BaiHangHistoryConstant.SQL_COMMONE_TEMPLATE_HISTORY_SYN_COUNT;
count_sql
=
count_sql
.
replace
(
"##BAKMAXID##"
,
""
+
bakMaxId
);
//
count_sql = count_sql.replace("##BAKMAXID##",""+bakMaxId);
count_sql
=
count_sql
.
replace
(
"##NEWMAXID##"
,
""
+
newMaxId
);
//防止查询的过程中再增长
//
count_sql = count_sql.replace("##NEWMAXID##",""+newMaxId);//防止查询的过程中再增长
Integer
count
=
xyqbHistoryJdbcTemplate
.
queryForObject
(
count_sql
,
Integer
.
class
);
//
Integer count = xyqbHistoryJdbcTemplate.queryForObject(count_sql,Integer.class);
if
(
count
==
null
){
//
if(count==null){
log
.
error
(
"表xyqb_i_loan_application_manifest_history查询增量count为Null."
);
//
log.error("表xyqb_i_loan_application_manifest_history查询增量count为Null.");
dingTalk
.
talk
(
"Warn"
,
"同步[借款清单]数据失败"
,
"查询增量count为Null,请尽快处理!"
+
" bakMaxId: "
+
bakMaxId
+
", newMaxId: "
+
newMaxId
);
//
dingTalk.talk("Warn","同步[借款清单]数据失败","查询增量count为Null,请尽快处理!"+" bakMaxId: "+bakMaxId+", newMaxId: "+newMaxId);
dingTalk
.
talk_ToUser
(
"借款清单同步失败"
,
"同步[借款清单]表查询增量count为Null,停止T+1报送!发现问题,请及时处理!"
);
//
dingTalk.talk_ToUser("借款清单同步失败", "同步[借款清单]表查询增量count为Null,停止T+1报送!发现问题,请及时处理!");
return
false
;
//
return false;
}
//
}
//
//小于2万条,可以commit
//
//小于2万条,可以commit
if
(
count
.
intValue
()
<=
BaiHangHistoryConstant
.
MAX_COMMIT_COUT
){
//
if(count.intValue() <= BaiHangHistoryConstant.MAX_COMMIT_COUT){
Stopwatch
startwatch
=
Stopwatch
.
createStarted
();
//
Stopwatch startwatch = Stopwatch.createStarted();
String
inset_sql
=
BaiHangHistoryConstant
.
SQL_COMMONE_TEMPLATE_HISTORY_SYN_DATA
;
//
String inset_sql = BaiHangHistoryConstant.SQL_COMMONE_TEMPLATE_HISTORY_SYN_DATA;
inset_sql
=
inset_sql
.
replace
(
"##STARTID##"
,
""
+
bakMaxId
);
//
inset_sql = inset_sql.replace("##STARTID##",""+bakMaxId);
//
int
update
=
xyqbHistoryJdbcTemplate
.
update
(
inset_sql
);
//
int update = xyqbHistoryJdbcTemplate.update(inset_sql);
log
.
info
(
"增量同步xyqb_i_loan_application_manifest_history表结束, bakMaxId: {} , count: {} , 插入条数: {} , 耗时: {} "
,
bakMaxId
,
count
,
update
,
startwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
)+
".ms"
);
//
log.info("增量同步xyqb_i_loan_application_manifest_history表结束, bakMaxId: {} , count: {} , 插入条数: {} , 耗时: {} ", bakMaxId, count, update, startwatch.stop().elapsed(TimeUnit.MILLISECONDS)+".ms");
dingTalk
.
talk
(
"Info"
,
"同步[借款清单]数据成功"
,
"实际条数: "
+
update
+
", bakMaxId: "
+
bakMaxId
+
", newMaxId: "
+
newMaxId
);
//
dingTalk.talk("Info","同步[借款清单]数据成功","实际条数: "+update +", bakMaxId: "+bakMaxId+", newMaxId: "+newMaxId);
return
true
;
//
return true;
}
else
{
//
}else{
//大于2万条会报事务太长,需要分页插入
//
//大于2万条会报事务太长,需要分页插入
int
id_limit_count
=
(
int
)
(
newMaxId
-
bakMaxId
);
//
int id_limit_count = (int) (newMaxId - bakMaxId);
int
page
=
id_limit_count
/
BaiHangHistoryConstant
.
MAX_COMMIT_COUT
;
//
int page = id_limit_count / BaiHangHistoryConstant.MAX_COMMIT_COUT;
int
mode
=
id_limit_count
%
BaiHangHistoryConstant
.
MAX_COMMIT_COUT
;
//
int mode = id_limit_count % BaiHangHistoryConstant.MAX_COMMIT_COUT;
if
(
mode
!=
0
){
//
if(mode!=0){
page
=
page
+
1
;
//
page = page+1;
}
//
}
//
int
totalUpdate
=
0
;
//
int totalUpdate = 0;
for
(
int
p
=
0
;
p
<
page
;
p
++){
//
for (int p=0 ; p < page; p++){
Stopwatch
startwatch
=
Stopwatch
.
createStarted
();
//
Stopwatch startwatch = Stopwatch.createStarted();
long
startId
=
bakMaxId
+
p
*
BaiHangHistoryConstant
.
MAX_COMMIT_COUT
;
//
long startId = bakMaxId + p * BaiHangHistoryConstant.MAX_COMMIT_COUT;
long
endId
=
bakMaxId
+
(
p
+
1
)
*
BaiHangHistoryConstant
.
MAX_COMMIT_COUT
;
//
long endId = bakMaxId + (p+1) * BaiHangHistoryConstant.MAX_COMMIT_COUT;
if
(
endId
>
newMaxId
){
//
if( endId > newMaxId){
endId
=
newMaxId
;
//
endId = newMaxId;
}
//
}
String
tmpInsertSql
=
BaiHangHistoryConstant
.
SQL_COMMONE_TEMPLATE_HISTORY_SYN_DATA
;
//
String tmpInsertSql = BaiHangHistoryConstant.SQL_COMMONE_TEMPLATE_HISTORY_SYN_DATA;
tmpInsertSql
=
tmpInsertSql
.
replace
(
"##STARTID##"
,
""
+
startId
);
//
tmpInsertSql = tmpInsertSql.replace("##STARTID##",""+startId);
tmpInsertSql
=
tmpInsertSql
+
(
" AND b.id <="
+
endId
+
" ;"
);
//
tmpInsertSql = tmpInsertSql + (" AND b.id <="+endId+" ;");
//
int
update
=
xyqbHistoryJdbcTemplate
.
update
(
tmpInsertSql
);
//
int update = xyqbHistoryJdbcTemplate.update(tmpInsertSql);
//
totalUpdate
+=
update
;
//
totalUpdate+=update;
log
.
info
(
"增量同步xyqb_i_loan_application_manifest_history表页数page["
+
p
+
"], startId: {} , endId: {} , 插入条数: {} , 耗时: {} "
,
startId
,
endId
,
update
,
startwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
)+
".ms"
);
//
log.info("增量同步xyqb_i_loan_application_manifest_history表页数page["+p+"], startId: {} , endId: {} , 插入条数: {} , 耗时: {} ", startId, endId, update, startwatch.stop().elapsed(TimeUnit.MILLISECONDS)+".ms");
}
//
}
log
.
info
(
"增量同步xyqb_i_loan_application_manifest_history表结束, bakMaxId: {} , newMaxId: {} , ID差: {} , count: {} , totalUpdate: {} , page: {} , mode: {} "
,
bakMaxId
,
newMaxId
,
(
newMaxId
-
bakMaxId
),
count
,
totalUpdate
,
page
,
mode
);
//
log.info("增量同步xyqb_i_loan_application_manifest_history表结束, bakMaxId: {} , newMaxId: {} , ID差: {} , count: {} , totalUpdate: {} , page: {} , mode: {} ", bakMaxId, newMaxId, (newMaxId-bakMaxId), count, totalUpdate, page, mode);
//
if
(
totalUpdate
==
count
){
//
if(totalUpdate==count){
dingTalk
.
talk
(
"Info"
,
"同步[借款清单]数据成功"
,
"实际条数(分页): "
+
totalUpdate
+
", bakMaxId: "
+
bakMaxId
+
", newMaxId: "
+
newMaxId
);
//
dingTalk.talk("Info","同步[借款清单]数据成功","实际条数(分页): "+totalUpdate+", bakMaxId: "+bakMaxId+", newMaxId: "+newMaxId);
return
true
;
//
return true;
}
else
{
//
}else{
dingTalk
.
talk
(
"Warn"
,
"同步[借款清单]数据失败"
,
"查询条数: "
+
count
+
",实际条数="
+
totalUpdate
+
", bakMaxId: "
+
bakMaxId
+
", newMaxId: "
+
newMaxId
);
//
dingTalk.talk("Warn","同步[借款清单]数据失败","查询条数: "+count+",实际条数="+totalUpdate+", bakMaxId: "+bakMaxId+", newMaxId: "+newMaxId);
dingTalk
.
talk_ToUser
(
"借款清单同步异常"
,
"同步[借款清单]数据失败,停止T+1报送!发现问题,请及时处理!"
);
//
dingTalk.talk_ToUser("借款清单同步异常", "同步[借款清单]数据失败,停止T+1报送!发现问题,请及时处理!");
return
false
;
//
return false;
}
//
}
}
//
}
}
//
}
//
//
private
boolean
syn_plan_by_id
(
long
bakMaxId
,
long
newMaxId
){
//
private boolean syn_plan_by_id(long bakMaxId,long newMaxId){
String
count_sql
=
BaiHangHistoryConstant
.
SQL_COMMONE_TEMPLATE_PLAN_SYN_COUNT
;
//
String count_sql = BaiHangHistoryConstant.SQL_COMMONE_TEMPLATE_PLAN_SYN_COUNT;
count_sql
=
count_sql
.
replace
(
"##BAKMAXID##"
,
""
+
bakMaxId
);
//
count_sql = count_sql.replace("##BAKMAXID##",""+bakMaxId);
count_sql
=
count_sql
.
replace
(
"##NEWMAXID##"
,
""
+
newMaxId
);
//防止查询的过程中再增长
//
count_sql = count_sql.replace("##NEWMAXID##",""+newMaxId);//防止查询的过程中再增长
Integer
count
=
xyqbHistoryJdbcTemplate
.
queryForObject
(
count_sql
,
Integer
.
class
);
//
Integer count = xyqbHistoryJdbcTemplate.queryForObject(count_sql,Integer.class);
if
(
count
==
null
){
//
if(count==null){
log
.
error
(
"表xyqb_i_repayment_plan查询增量count为Null."
);
//
log.error("表xyqb_i_repayment_plan查询增量count为Null.");
dingTalk
.
talk
(
"Warn"
,
"同步[还款计划]数据失败"
,
"查询增量count为Null,请尽快处理!"
+
", bakMaxId: "
+
bakMaxId
+
", newMaxId: "
+
newMaxId
);
//
dingTalk.talk("Warn","同步[还款计划]数据失败","查询增量count为Null,请尽快处理!" + ", bakMaxId: "+bakMaxId+", newMaxId: "+newMaxId);
dingTalk
.
talk_ToUser
(
"还款计划同步失败"
,
"同步[还款计划]表查询增量count为Null,停止T+1报送!发现问题,请及时处理!"
);
//
dingTalk.talk_ToUser("还款计划同步失败", "同步[还款计划]表查询增量count为Null,停止T+1报送!发现问题,请及时处理!");
return
false
;
//
return false;
}
//
}
//
//小于2万条,可以commit
//
//小于2万条,可以commit
if
(
count
.
intValue
()
<=
BaiHangHistoryConstant
.
MAX_COMMIT_COUT
){
//
if(count.intValue() <= BaiHangHistoryConstant.MAX_COMMIT_COUT){
Stopwatch
startwatch
=
Stopwatch
.
createStarted
();
//
Stopwatch startwatch = Stopwatch.createStarted();
String
inset_sql
=
BaiHangHistoryConstant
.
SQL_COMMONE_TEMPLATE_PLAN_SYN_DATA
;
//
String inset_sql = BaiHangHistoryConstant.SQL_COMMONE_TEMPLATE_PLAN_SYN_DATA;
inset_sql
=
inset_sql
.
replace
(
"##STARTID##"
,
""
+
bakMaxId
);
//
inset_sql = inset_sql.replace("##STARTID##",""+bakMaxId);
//
int
update
=
xyqbHistoryJdbcTemplate
.
update
(
inset_sql
);
//
int update = xyqbHistoryJdbcTemplate.update(inset_sql);
log
.
info
(
"增量同步xyqb_i_repayment_plan表结束, bakMaxId: {} , count: {} , 插入条数: {} , 耗时: {} "
,
bakMaxId
,
count
,
update
,
startwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
)+
".ms"
);
//
log.info("增量同步xyqb_i_repayment_plan表结束, bakMaxId: {} , count: {} , 插入条数: {} , 耗时: {} ", bakMaxId, count, update, startwatch.stop().elapsed(TimeUnit.MILLISECONDS)+".ms");
dingTalk
.
talk
(
"Info"
,
"同步[还款计划]数据成功"
,
"实际条数: "
+
update
+
", bakMaxId: "
+
bakMaxId
+
", newMaxId: "
+
newMaxId
);
//
dingTalk.talk("Info","同步[还款计划]数据成功","实际条数: "+update +", bakMaxId: "+bakMaxId+", newMaxId: "+newMaxId);
return
true
;
//
return true;
}
else
{
//
}else{
//大于2万条会报事务太长,需要分页插入
//
//大于2万条会报事务太长,需要分页插入
//xyqb_i_repayment_plan表目前发现有24期的,也就是说xyqb_i_loan_a_m_history_bak关联最大会出现24条
//
//xyqb_i_repayment_plan表目前发现有24期的,也就是说xyqb_i_loan_a_m_history_bak关联最大会出现24条
int
PLAN_MAX_COMMIT_COUT
=
BaiHangHistoryConstant
.
MAX_COMMIT_COUT
/
24
;
//
int PLAN_MAX_COMMIT_COUT = BaiHangHistoryConstant.MAX_COMMIT_COUT / 24;
//
int
id_limit_count
=
(
int
)
(
newMaxId
-
bakMaxId
);
//
int id_limit_count = (int) (newMaxId - bakMaxId);
int
page
=
id_limit_count
/
PLAN_MAX_COMMIT_COUT
;
//
int page = id_limit_count / PLAN_MAX_COMMIT_COUT;
int
mode
=
id_limit_count
%
PLAN_MAX_COMMIT_COUT
;
//
int mode = id_limit_count % PLAN_MAX_COMMIT_COUT;
if
(
mode
!=
0
){
//
if(mode!=0){
page
=
page
+
1
;
//
page = page+1;
}
//
}
//
int
totalUpdate
=
0
;
//
int totalUpdate = 0;
for
(
int
p
=
0
;
p
<
page
;
p
++){
//
for (int p=0 ; p < page; p++){
Stopwatch
startwatch
=
Stopwatch
.
createStarted
();
//
Stopwatch startwatch = Stopwatch.createStarted();
long
startId
=
bakMaxId
+
p
*
PLAN_MAX_COMMIT_COUT
;
//
long startId = bakMaxId + p * PLAN_MAX_COMMIT_COUT;
long
endId
=
bakMaxId
+
(
p
+
1
)
*
PLAN_MAX_COMMIT_COUT
;
//
long endId = bakMaxId + (p+1) * PLAN_MAX_COMMIT_COUT;
if
(
endId
>
newMaxId
){
//
if( endId > newMaxId){
endId
=
newMaxId
;
//
endId = newMaxId;
}
//
}
String
tmpInsertSql
=
BaiHangHistoryConstant
.
SQL_COMMONE_TEMPLATE_PLAN_SYN_DATA
;
//
String tmpInsertSql = BaiHangHistoryConstant.SQL_COMMONE_TEMPLATE_PLAN_SYN_DATA;
tmpInsertSql
=
tmpInsertSql
.
replace
(
"##STARTID##"
,
""
+
startId
);
//
tmpInsertSql = tmpInsertSql.replace("##STARTID##",""+startId);
tmpInsertSql
=
tmpInsertSql
+
(
" AND b.id <="
+
endId
+
" ;"
);
//
tmpInsertSql = tmpInsertSql + (" AND b.id <="+endId+" ;");
//
int
update
=
xyqbHistoryJdbcTemplate
.
update
(
tmpInsertSql
);
//
int update = xyqbHistoryJdbcTemplate.update(tmpInsertSql);
//
totalUpdate
+=
update
;
//
totalUpdate+=update;
log
.
info
(
"增量同步xyqb_i_repayment_plan表页数page["
+
p
+
"], startId: {} , endId: {} , 插入条数: {} , 耗时: {} "
,
startId
,
endId
,
update
,
startwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
)+
".ms"
);
//
log.info("增量同步xyqb_i_repayment_plan表页数page["+p+"], startId: {} , endId: {} , 插入条数: {} , 耗时: {} ", startId, endId, update, startwatch.stop().elapsed(TimeUnit.MILLISECONDS)+".ms");
}
//
}
log
.
info
(
"增量同步xyqb_i_repayment_plan表结束, bakMaxId: {} , newMaxId: {} , ID差: {} , count: {} , totalUpdate: {} , page: {} , mode: {} "
,
bakMaxId
,
newMaxId
,
(
newMaxId
-
bakMaxId
),
count
,
totalUpdate
,
page
,
mode
);
//
log.info("增量同步xyqb_i_repayment_plan表结束, bakMaxId: {} , newMaxId: {} , ID差: {} , count: {} , totalUpdate: {} , page: {} , mode: {} ", bakMaxId, newMaxId, (newMaxId-bakMaxId), count, totalUpdate, page, mode);
//
if
(
totalUpdate
==
count
){
//
if(totalUpdate==count){
dingTalk
.
talk
(
"Info"
,
"同步[还款计划]数据成功"
,
"实际条数(分页): "
+
totalUpdate
+
", bakMaxId: "
+
bakMaxId
+
", newMaxId: "
+
newMaxId
);
//
dingTalk.talk("Info","同步[还款计划]数据成功","实际条数(分页): "+totalUpdate + ", bakMaxId: "+bakMaxId+", newMaxId: "+newMaxId);
return
true
;
//
return true;
}
else
{
//
}else{
dingTalk
.
talk
(
"Warn"
,
"同步[还款计划]数据失败"
,
"查询条数: "
+
count
+
",实际条数="
+
totalUpdate
+
", bakMaxId: "
+
bakMaxId
+
", newMaxId: "
+
newMaxId
);
//
dingTalk.talk("Warn","同步[还款计划]数据失败","查询条数: "+count+",实际条数="+totalUpdate + ", bakMaxId: "+bakMaxId+", newMaxId: "+newMaxId);
dingTalk
.
talk_ToUser
(
"还款计划同步异常"
,
"同步[还款计划]数据失败,停止T+1报送!发现问题,请及时处理!"
);
//
dingTalk.talk_ToUser("还款计划同步异常", "同步[还款计划]数据失败,停止T+1报送!发现问题,请及时处理!");
return
false
;
//
return false;
}
//
}
//
//
}
//
}
}
//
}
//
public
boolean
syn_historyAndplan_by_id
(){
//
public boolean syn_historyAndplan_by_id(){
Stopwatch
startwatch
=
Stopwatch
.
createStarted
();
//
Stopwatch startwatch = Stopwatch.createStarted();
try
{
//
try {
String
tmp_sql1
=
BaiHangHistoryConstant
.
SQL_COMMONE_TEMPLATE_HISTORY_BAK_MAX_ID
;
//
String tmp_sql1 = BaiHangHistoryConstant.SQL_COMMONE_TEMPLATE_HISTORY_BAK_MAX_ID;
Long
bakMaxId
=
xyqbHistoryJdbcTemplate
.
queryForObject
(
tmp_sql1
,
Long
.
class
);
//
Long bakMaxId = xyqbHistoryJdbcTemplate.queryForObject(tmp_sql1,Long.class);
//
String
tmp_sql2
=
BaiHangHistoryConstant
.
SQL_COMMONE_TEMPLATE_HISTORY_MAX_ID
;
//
String tmp_sql2 = BaiHangHistoryConstant.SQL_COMMONE_TEMPLATE_HISTORY_MAX_ID;
Long
newMaxId
=
xyqbHistoryJdbcTemplate
.
queryForObject
(
tmp_sql2
,
Long
.
class
);
//
Long newMaxId = xyqbHistoryJdbcTemplate.queryForObject(tmp_sql2,Long.class);
//
//2019.11.15 13:37 bakMaxId: 1857710 , newMaxId: 13732716 , count: 1062175 , 差:11875006 , 总插入条数: 1062174 , page: 594
//
//2019.11.15 13:37 bakMaxId: 1857710 , newMaxId: 13732716 , count: 1062175 , 差:11875006 , 总插入条数: 1062174 , page: 594
//bakMaxId = 1857710L;
//
//bakMaxId = 1857710L;
//newMaxId = 13732716L;
//
//newMaxId = 13732716L;
//
if
(
bakMaxId
!=
null
&&
bakMaxId
.
longValue
()
>=
0L
&&
newMaxId
!=
null
&&
newMaxId
.
longValue
()
>=
0L
){
//
if(bakMaxId!=null && bakMaxId.longValue() >= 0L && newMaxId!=null && newMaxId.longValue() >= 0L){
//
//同步到xyqb_i_loan_a_m_history_bak表-------------------------------
//
//同步到xyqb_i_loan_a_m_history_bak表-------------------------------
boolean
table_history
=
syn_history_by_id
(
bakMaxId
.
longValue
(),
newMaxId
.
longValue
());
//
boolean table_history = syn_history_by_id(bakMaxId.longValue(), newMaxId.longValue());
if
(
table_history
){
//
if(table_history){
//同步到xyqb_i_repayment_plan_bak表
//
//同步到xyqb_i_repayment_plan_bak表
boolean
table_plan
=
syn_plan_by_id
(
bakMaxId
.
longValue
(),
newMaxId
.
longValue
());
//
boolean table_plan = syn_plan_by_id(bakMaxId.longValue(), newMaxId.longValue());
if
(
table_plan
){
//
if(table_plan){
log
.
info
(
"ALL增量同步history&plan表数据结束, nowTime: {} "
,
LocalDateTime
.
now
(),
startwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
)+
".ms"
);
//
log.info("ALL增量同步history&plan表数据结束, nowTime: {} ", LocalDateTime.now(), startwatch.stop().elapsed(TimeUnit.MILLISECONDS)+".ms");
return
true
;
//
return true;
}
else
{
//
}else{
log
.
error
(
"All增量同步[xyqb_i_repayment_plan_bak]表数据失败,请尽快处理! nowTime: {} , bakMaxId: {} , newMaxId: {} "
,
LocalDateTime
.
now
(),
bakMaxId
,
newMaxId
);
//
log.error("All增量同步[xyqb_i_repayment_plan_bak]表数据失败,请尽快处理! nowTime: {} , bakMaxId: {} , newMaxId: {} ",LocalDateTime.now(), bakMaxId, newMaxId);
////dingTalk.talk("Warn","同步[还款计划]数据失败","同步xyqb_i_repayment_plan_bak表数据失败,请尽快处理! newMaxId:"+newMaxId+",newMaxId="+newMaxId);
//
////dingTalk.talk("Warn","同步[还款计划]数据失败","同步xyqb_i_repayment_plan_bak表数据失败,请尽快处理! newMaxId:"+newMaxId+",newMaxId="+newMaxId);
}
//
}
//
}
else
{
//
}else{
log
.
error
(
"增量同步[xyqb_i_loan_a_m_history_bak]表数据失败,请尽快处理! nowTime: {} , bakMaxId: {} , newMaxId: {} "
,
LocalDateTime
.
now
(),
bakMaxId
,
newMaxId
);
//
log.error("增量同步[xyqb_i_loan_a_m_history_bak]表数据失败,请尽快处理! nowTime: {} , bakMaxId: {} , newMaxId: {} ",LocalDateTime.now(), bakMaxId, newMaxId);
////dingTalk.talk("Warn","同步[借款清单]数据失败","同步xyqb_i_loan_a_m_history_bak表数据失败,请尽快处理! newMaxId:"+newMaxId+",newMaxId="+newMaxId);
//
////dingTalk.talk("Warn","同步[借款清单]数据失败","同步xyqb_i_loan_a_m_history_bak表数据失败,请尽快处理! newMaxId:"+newMaxId+",newMaxId="+newMaxId);
}
//
}
//-------------------------------
//
//-------------------------------
//
}
else
{
//
}else {
log
.
error
(
"增量同步xyqb_i_repayment_plan数据-历史id为空,停止同步! nowTime: {} , bakMaxId: {} , newMaxId: {} "
,
LocalDateTime
.
now
(),
bakMaxId
,
newMaxId
);
//
log.error("增量同步xyqb_i_repayment_plan数据-历史id为空,停止同步! nowTime: {} , bakMaxId: {} , newMaxId: {} ",LocalDateTime.now(), bakMaxId, newMaxId);
dingTalk
.
talk
(
"Warn"
,
"同步临时表数据失败"
,
"查询数据历史bakMaxId或newMaxId为空."
);
//
dingTalk.talk("Warn","同步临时表数据失败","查询数据历史bakMaxId或newMaxId为空.");
dingTalk
.
talk_ToUser
(
"数据同步异常2"
,
"查询数据历史bakMaxId或newMaxId为空,停止T+1报送!发现问题,请及时处理!"
);
//
dingTalk.talk_ToUser("数据同步异常2", "查询数据历史bakMaxId或newMaxId为空,停止T+1报送!发现问题,请及时处理!");
}
//
}
}
catch
(
Exception
e
){
//
}catch (Exception e){
log
.
error
(
"增量同步history和plan表数据异常, nowTime: {} "
,
LocalDateTime
.
now
(),
e
);
//
log.error("增量同步history和plan表数据异常, nowTime: {} ", LocalDateTime.now(), e);
dingTalk
.
talk
(
"Error"
,
"同步history和plan表数据异常"
,
e
);
//
dingTalk.talk("Error","同步history和plan表数据异常",e);
dingTalk
.
talk_ToUser
(
"数据同步异常1"
,
"同步history和plan表数据异常,停止T+1报送!发现问题,请及时处理!"
);
//
dingTalk.talk_ToUser("数据同步异常1", "同步history和plan表数据异常,停止T+1报送!发现问题,请及时处理!");
}
//
}
//
return
false
;
//
return false;
}
//
}
//
//
/**
//
/**
* 描述: 将xyqb_i_loan_application_manifest_history表的数据
//
* 描述: 将xyqb_i_loan_application_manifest_history表的数据
* 同步到xyqb_i_loan_a_m_history_p2p_bak表<br/>
//
* 同步到xyqb_i_loan_a_m_history_p2p_bak表<br/>
* 参数: [] <br/>
//
* 参数: [] <br/>
* 返回值: boolean <br/>
//
* 返回值: boolean <br/>
* 创建人: yanhui.Hao <br/>
//
* 创建人: yanhui.Hao <br/>
* 创建时间: 2019.12.17 <br/>
//
* 创建时间: 2019.12.17 <br/>
*/
//
*/
private
void
syn_history_p2p_bak
(){
//
private void syn_history_p2p_bak(){
LocalDateTime
erlyDate
=
LocalDateTime
.
parse
(
"2016-11-01T00:00:00"
);
//
LocalDateTime erlyDate = LocalDateTime.parse("2016-11-01T00:00:00");
LocalDateTime
endDate
=
LocalDateTime
.
parse
(
"2019-01-01T00:00:00"
);
//
LocalDateTime endDate = LocalDateTime.parse("2019-01-01T00:00:00");
int
counter
=
0
;
//
int counter = 0;
while
(
true
)
{
//
while (true) {
Stopwatch
startwatch
=
Stopwatch
.
createStarted
();
//
Stopwatch startwatch = Stopwatch.createStarted();
counter
++;
//
counter++;
if
(
erlyDate
.
plusDays
(
counter
).
compareTo
(
endDate
)
>
0
)
{
//
if (erlyDate.plusDays(counter).compareTo(endDate) > 0) {
break
;
//
break;
}
//
}
//
String
starTime
=
erlyDate
.
plusDays
(
counter
-
1
).
format
(
DateTimeFormatter
.
ISO_DATE
);
//
String starTime = erlyDate.plusDays(counter - 1).format(DateTimeFormatter.ISO_DATE);
String
endTime
=
erlyDate
.
plusDays
(
counter
).
format
(
DateTimeFormatter
.
ISO_DATE
);
//
String endTime = erlyDate.plusDays(counter).format(DateTimeFormatter.ISO_DATE);
try
{
//
try {
String
tmp_sql
=
BaiHangHistoryConstant
.
SQL_TEMPLATE_HISTORY_P2P
;
//
String tmp_sql = BaiHangHistoryConstant.SQL_TEMPLATE_HISTORY_P2P;
tmp_sql
=
tmp_sql
.
replace
(
"##STARTTIME##"
,
starTime
);
//
tmp_sql = tmp_sql.replace("##STARTTIME##",starTime);
tmp_sql
=
tmp_sql
.
replace
(
"##ENDTIME##"
,
endTime
);
//
tmp_sql = tmp_sql.replace("##ENDTIME##",endTime);
//
int
upCount
=
xyqbHistoryJdbcTemplate
.
update
(
tmp_sql
);
//
int upCount = xyqbHistoryJdbcTemplate.update(tmp_sql);
log
.
info
(
"同步xyqb_i_loan_a_m_history_p2p_bak数据结束, startTime: {} , 耗时: {} , updateCount: {} "
,
starTime
,
startwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
)+
".ms"
,
upCount
);
//
log.info("同步xyqb_i_loan_a_m_history_p2p_bak数据结束, startTime: {} , 耗时: {} , updateCount: {} ", starTime, startwatch.stop().elapsed(TimeUnit.MILLISECONDS)+".ms", upCount);
//
}
catch
(
Exception
e
){
//
}catch (Exception e){
log
.
error
(
"同步xyqb_i_loan_a_m_history_p2p_bak数据异常, startTime: {} , endTime: {} , counter: {} "
,
starTime
,
endTime
,
counter
,
e
);
//
log.error("同步xyqb_i_loan_a_m_history_p2p_bak数据异常, startTime: {} , endTime: {} , counter: {} ", starTime, endTime,counter, e);
}
//
}
}
//
}
}
//
}
//
/**
//
/**
* 描述: 将xyqb_i_repayment_plan表的数据同步到xyqb_i_repayment_plan_p2p_bak表 <br/>
//
* 描述: 将xyqb_i_repayment_plan表的数据同步到xyqb_i_repayment_plan_p2p_bak表 <br/>
* 参数: [] <br/>
//
* 参数: [] <br/>
* 返回值: void <br/>
//
* 返回值: void <br/>
* 创建人: yanhui.Hao <br/>
//
* 创建人: yanhui.Hao <br/>
* 创建时间: 2019.12.17 <br/>
//
* 创建时间: 2019.12.17 <br/>
*/
//
*/
private
void
syn_plan_p2p_bak
(){
//
private void syn_plan_p2p_bak(){
LocalDateTime
erlyDate
=
LocalDateTime
.
parse
(
"2016-11-01T00:00:00"
);
//
LocalDateTime erlyDate = LocalDateTime.parse("2016-11-01T00:00:00");
LocalDateTime
endDate
=
LocalDateTime
.
parse
(
"2019-10-25T00:00:00"
);
//
LocalDateTime endDate = LocalDateTime.parse("2019-10-25T00:00:00");
int
counter
=
0
;
//
int counter = 0;
while
(
true
)
{
//
while (true) {
Stopwatch
startwatch
=
Stopwatch
.
createStarted
();
//
Stopwatch startwatch = Stopwatch.createStarted();
counter
++;
//
counter++;
if
(
erlyDate
.
plusDays
(
counter
).
compareTo
(
endDate
)
>
0
)
{
//
if (erlyDate.plusDays(counter).compareTo(endDate) > 0) {
break
;
//
break;
}
//
}
//
String
starTime
=
erlyDate
.
plusDays
(
counter
-
1
).
format
(
DateTimeFormatter
.
ISO_DATE
);
//
String starTime = erlyDate.plusDays(counter - 1).format(DateTimeFormatter.ISO_DATE);
String
endTime
=
erlyDate
.
plusDays
(
counter
).
format
(
DateTimeFormatter
.
ISO_DATE
);
//
String endTime = erlyDate.plusDays(counter).format(DateTimeFormatter.ISO_DATE);
try
{
//
try {
String
tmp_sql
=
BaiHangHistoryConstant
.
SQL_TEMPLATE_PLAN_P2P
;
//
String tmp_sql = BaiHangHistoryConstant.SQL_TEMPLATE_PLAN_P2P;
tmp_sql
=
tmp_sql
.
replace
(
"##STARTTIME##"
,
starTime
);
//
tmp_sql = tmp_sql.replace("##STARTTIME##",starTime);
tmp_sql
=
tmp_sql
.
replace
(
"##ENDTIME##"
,
endTime
);
//
tmp_sql = tmp_sql.replace("##ENDTIME##",endTime);
//
int
upCount
=
xyqbHistoryJdbcTemplate
.
update
(
tmp_sql
);
//
int upCount = xyqbHistoryJdbcTemplate.update(tmp_sql);
log
.
info
(
"同步xyqb_i_repayment_plan_p2p_bak数据结束, startTime: {} , 耗时: {} , updateCount: {} "
,
starTime
,
startwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
)+
".ms"
,
upCount
);
//
log.info("同步xyqb_i_repayment_plan_p2p_bak数据结束, startTime: {} , 耗时: {} , updateCount: {} ", starTime, startwatch.stop().elapsed(TimeUnit.MILLISECONDS)+".ms", upCount);
//
}
catch
(
Exception
e
){
//
}catch (Exception e){
log
.
error
(
"同步xyqb_i_repayment_plan_p2p_bak数据异常, startTime: {} , endTime: {} , counter: {} "
,
starTime
,
endTime
,
counter
,
e
);
//
log.error("同步xyqb_i_repayment_plan_p2p_bak数据异常, startTime: {} , endTime: {} , counter: {} ", starTime, endTime,counter, e);
}
//
}
}
//
}
}
//
}
//
//
//
}
//
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment