Commit a3929ab4 authored by 郝彦辉's avatar 郝彦辉

手动跑存数据bak1

parent f2a36a7a
...@@ -21,17 +21,17 @@ public class BaiHangHistoryConstant { ...@@ -21,17 +21,17 @@ public class BaiHangHistoryConstant {
public static final int MAX_COMMIT_COUT = 24000;//大于2万条会出现事务提交过长报错 public static final int MAX_COMMIT_COUT = 24000;//大于2万条会出现事务提交过长报错
public static final String SQL_COMMONE_TEMPLATE_HISTORY = "INSERT xyqb_i_loan_a_m_history_bak " + public static final String SQL_COMMONE_TEMPLATE_HISTORY = "REPLACE INTO rc_syn_to_baihang_report.xyqb_i_loan_a_m_history_bak " +
" select * from xyqb_i_loan_application_manifest_history b " + " select * from rc_real_time_data_pool_v2.xyqb_i_loan_application_manifest_history b " +
" where b.funding_corp_id in (420,520,580,650,670,810,240,640,700) " + " where b.funding_corp_id in (420,520,580,650,670,810,240,640,700) " +
" and b.created_at >= '##STARTTIME##' and b.created_at < '##ENDTIME##'; "; " and b.updated_at >= '##STARTTIME##' and b.updated_at < '##ENDTIME##'; ";
//报送查询 b.loan_paid_at<@t2 公司打款时间 //报送查询 b.loan_paid_at<@t2 公司打款时间
public static final String SQL_COMMONE_TEMPLATE_PLAN = "INSERT xyqb_i_repayment_plan_bak " + public static final String SQL_COMMONE_TEMPLATE_PLAN = "REPLACE INTO rc_syn_to_baihang_report.xyqb_i_repayment_plan_bak " +
"select a.* from xyqb_i_repayment_plan a " + "select a.* from rc_real_time_data_pool_v2.xyqb_i_repayment_plan a " +
" join xyqb_i_loan_a_m_history_bak b " + " join rc_syn_to_baihang_report.xyqb_i_loan_a_m_history_bak b " +
" on a.loan_application_history_id = b.loan_application_history_id " + " on a.loan_application_history_id = b.loan_application_history_id " +
"where b.created_at >= '##STARTTIME##' and b.created_at < '##ENDTIME##'; "; "where b.updated_at >= '##STARTTIME##' and b.updated_at < '##ENDTIME##'; ";
//报送查询 a.repaid_at>=@t2 还款时间 //报送查询 a.repaid_at>=@t2 还款时间
......
...@@ -284,4 +284,25 @@ public class ExZhuDaiBaiHangReSendController { ...@@ -284,4 +284,25 @@ public class ExZhuDaiBaiHangReSendController {
} }
} }
@RequestMapping("/manual/syn_history_by_CreatedAt")
public String syn_history_by_CreatedAt(String p3,String secretKey){
if(manualToolService.checkSecretKey(p3,secretKey)){
//增量同步rc_real_time_data_pool_v2.xyqb_i_loan_application_manifest_history
synLoanInfoHistoryTask.syn_history_by_CreatedAt();
return "syn_history_by_CreatedAt任务调度完成";
}else{
return "syn_history_by_CreatedAt任务调度失败,参数错误";
}
}
@RequestMapping("/manual/syn_plan_by_CreatedAt")
public String syn_plan_by_CreatedAt(String p3,String secretKey){
if(manualToolService.checkSecretKey(p3,secretKey)){
//增量同步rc_real_time_data_pool_v2.xyqb_i_repayment_plan
synLoanInfoHistoryTask.syn_plan_by_CreatedAt();
return "syn_plan_by_CreatedAt任务调度完成";
}else{
return "syn_plan_by_CreatedAt任务调度失败,参数错误";
}
}
} }
...@@ -81,10 +81,10 @@ public class SynLoanInfoHistoryTask { ...@@ -81,10 +81,10 @@ public class SynLoanInfoHistoryTask {
return increment <= 1; return increment <= 1;
} }
@Deprecated
private void syn_history_by_CreatedAt(){ public void syn_history_by_CreatedAt(){
LocalDateTime erlyDate = LocalDateTime.parse("2016-08-23T00:00:00");//2016-08-23T16:29:10 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("2019-11-01T00:00:00");//2019-11-11 12:32:08 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();
...@@ -114,10 +114,10 @@ public class SynLoanInfoHistoryTask { ...@@ -114,10 +114,10 @@ public class SynLoanInfoHistoryTask {
} }
} }
@Deprecated
private void syn_plan_by_CreatedAt(){ public void syn_plan_by_CreatedAt(){
LocalDateTime erlyDate = LocalDateTime.parse("2016-08-23T00:00:00");//2016-08-23T16:29:10 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("2019-11-01T00:00:00");//2019-11-11 12:32:08 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();
......
...@@ -437,6 +437,7 @@ ...@@ -437,6 +437,7 @@
if(DATEDIFF(a.next_deadline,a.repaid_at)>1,a.term_no,h.max_term); if(DATEDIFF(a.next_deadline,a.repaid_at)>1,a.term_no,h.max_term);
--> -->
<!-- 2020.06.02 百行助贷-非联合贷-实时还款,查询原始表,不用bak临时表 --> <!-- 2020.06.02 百行助贷-非联合贷-实时还款,查询原始表,不用bak临时表 -->
<!-- 查询bak表,并且使用v2库 -->
select select
a.id reqID a.id reqID
,'A' opCode ,'A' opCode
...@@ -468,21 +469,13 @@ ...@@ -468,21 +469,13 @@
if(c.term_no is null,a.term_no,c.term_no) next_term if(c.term_no is null,a.term_no,c.term_no) next_term
,if(c.deadline is null,a.deadline,c.deadline) next_deadline ,if(c.deadline is null,a.deadline,c.deadline) next_deadline
,b.loan_paid_at ,b.loan_paid_at
-- from xyqb_i_repayment_plan_bak a from rc_syn_to_baihang_report.xyqb_i_repayment_plan_bak a
-- left join xyqb_i_loan_a_m_history_bak b left join rc_syn_to_baihang_report.xyqb_i_loan_a_m_history_bak b
from xyqb_i_repayment_plan a
left join xyqb_i_loan_application_manifest_history b
on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at &lt; #{endTime,jdbcType=VARCHAR} on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at &lt; #{endTime,jdbcType=VARCHAR}
-- left join xyqb_i_repayment_plan_bak c on a.loan_application_history_id=c.loan_application_history_id left join rc_syn_to_baihang_report.xyqb_i_repayment_plan_bak c on a.loan_application_history_id=c.loan_application_history_id
left join xyqb_i_repayment_plan c on a.loan_application_history_id=c.loan_application_history_id
and a.term_no=c.term_no-1 and a.term_no=c.term_no-1
where a.repaid_at>= #{startTime,jdbcType=VARCHAR} and a.repaid_at &lt; #{endTime,jdbcType=VARCHAR} and a.repayment_status=3 where a.repaid_at>= #{startTime,jdbcType=VARCHAR} and a.repaid_at &lt; #{endTime,jdbcType=VARCHAR} and a.repayment_status=3
/*and b.funding_corp_id in (420,520,580,650,670,810,240,640,700)*/
-- funding_corp_id 放开
and b.funding_corp_id in (420,520,580,650,670,810,240,640,700)
and b.contract_term not in (2,3) and b.contract_term not in (2,3)
) a ) a
left join xyqb_user_i_user_detail b on a.user_id=b.user_id left join xyqb_user_i_user_detail b on a.user_id=b.user_id
...@@ -494,16 +487,11 @@ ...@@ -494,16 +487,11 @@
,sum(if(a.repayment_status !=3 or (a.repayment_status =3 and a.repaid_at>= #{endTime,jdbcType=VARCHAR}),if(b.loan_paid_at>='2018-01-01',g.principal,h.principle),0)) dkye ,sum(if(a.repayment_status !=3 or (a.repayment_status =3 and a.repaid_at>= #{endTime,jdbcType=VARCHAR}),if(b.loan_paid_at>='2018-01-01',g.principal,h.principle),0)) dkye
,min(if((a.repayment_status !=3 or (a.repayment_status =3 and a.repaid_at>= #{endTime,jdbcType=VARCHAR})) and a.deadline &lt;= #{endTime,jdbcType=VARCHAR},a.deadline,null)) min_deadline ,min(if((a.repayment_status !=3 or (a.repayment_status =3 and a.repaid_at>= #{endTime,jdbcType=VARCHAR})) and a.deadline &lt;= #{endTime,jdbcType=VARCHAR},a.deadline,null)) min_deadline
,max(a.term_no) max_term_no ,max(a.term_no) max_term_no
-- from xyqb_i_repayment_plan_bak a from rc_syn_to_baihang_report.xyqb_i_repayment_plan_bak a
-- left join xyqb_i_loan_a_m_history_bak b on a.loan_application_history_id=b.loan_application_history_id left join rc_syn_to_baihang_report.xyqb_i_loan_a_m_history_bak b on a.loan_application_history_id=b.loan_application_history_id
from xyqb_i_repayment_plan a
left join xyqb_i_loan_application_manifest_history b on a.loan_application_history_id=b.loan_application_history_id
left join xyqb_i_repayment_record g on a.id=g.repayment_plan_id left join xyqb_i_repayment_record g on a.id=g.repayment_plan_id
left join xyqb_i_plan_amount_detail h on a.id=h.plan_id left join xyqb_i_plan_amount_detail h on a.id=h.plan_id
-- funding_corp_id 放开 /*where b.funding_corp_id in (420,520,580,650,670,810,240,640,700)*/
where b.funding_corp_id in (420,520,580,650,670,810,240,640,700)
group by a.loan_application_history_id group by a.loan_application_history_id
) f on a.loan_application_history_id=f.loan_application_history_id ) f on a.loan_application_history_id=f.loan_application_history_id
left join xyqb_i_repayment_record g on a.id=g.repayment_plan_id left join xyqb_i_repayment_record g on a.id=g.repayment_plan_id
...@@ -511,19 +499,12 @@ ...@@ -511,19 +499,12 @@
select a.loan_application_history_id,a.repaid_at,a.deadline,a.term_no select a.loan_application_history_id,a.repaid_at,a.deadline,a.term_no
,max(c.term_no) max_term ,max(c.term_no) max_term
,max(c.deadline) max_deadline ,max(c.deadline) max_deadline
-- from xyqb_i_repayment_plan_bak a from rc_syn_to_baihang_report.xyqb_i_repayment_plan_bak a
-- left join xyqb_i_loan_a_m_history_bak b left join rc_syn_to_baihang_report.xyqb_i_loan_a_m_history_bak b
from xyqb_i_repayment_plan a
left join xyqb_i_loan_application_manifest_history b
on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at &lt; #{endTime,jdbcType=VARCHAR} on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at &lt; #{endTime,jdbcType=VARCHAR}
-- left join xyqb_i_repayment_plan_bak c on a.loan_application_history_id=c.loan_application_history_id left join rc_syn_to_baihang_report.xyqb_i_repayment_plan_bak c on a.loan_application_history_id=c.loan_application_history_id
left join xyqb_i_repayment_plan c on a.loan_application_history_id=c.loan_application_history_id
where DATEDIFF(a.repaid_at,c.deadline)>=-1 where DATEDIFF(a.repaid_at,c.deadline)>=-1
-- funding_corp_id 放开 /*and b.funding_corp_id in (420,520,580,650,670,810,240,640,700)*/
and b.funding_corp_id in (420,520,580,650,670,810,240,640,700)
group by a.loan_application_history_id,a.term_no group by a.loan_application_history_id,a.term_no
) h ) h
on a.loan_application_history_id=h.loan_application_history_id and a.term_no=h.term_no on a.loan_application_history_id=h.loan_application_history_id and a.term_no=h.term_no
...@@ -531,16 +512,11 @@ ...@@ -531,16 +512,11 @@
select a.loan_application_history_id select a.loan_application_history_id
,a.term_no ,a.term_no
,sum(if(d.term_no>a.term_no,d.principal,0)) dkye ,sum(if(d.term_no>a.term_no,d.principal,0)) dkye
-- from xyqb_i_repayment_plan_bak a from rc_syn_to_baihang_report.xyqb_i_repayment_plan_bak a
-- left join xyqb_i_loan_a_m_history_bak b left join rc_syn_to_baihang_report.xyqb_i_loan_a_m_history_bak b
from xyqb_i_repayment_plan a
left join xyqb_i_loan_application_manifest_history b
on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at &lt; #{endTime,jdbcType=VARCHAR} on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at &lt; #{endTime,jdbcType=VARCHAR}
left join xyqb_i_repayment_record d on a.loan_application_history_id=d.loan_application_history_id left join xyqb_i_repayment_record d on a.loan_application_history_id=d.loan_application_history_id
-- funding_corp_id 放开 /*where b.funding_corp_id in (420,520,580,650,670,810,240,640,700)*/
where b.funding_corp_id in (420,520,580,650,670,810,240,640,700)
group by a.loan_application_history_id,a.term_no group by a.loan_application_history_id,a.term_no
) i ) i
on a.loan_application_history_id=i.loan_application_history_id and a.term_no=i.term_no on a.loan_application_history_id=i.loan_application_history_id and a.term_no=i.term_no
...@@ -548,24 +524,16 @@ ...@@ -548,24 +524,16 @@
select a.loan_application_history_id select a.loan_application_history_id
,a.term_no ,a.term_no
,sum(if(e.term_no>a.term_no,h.principle,0)) dkye ,sum(if(e.term_no>a.term_no,h.principle,0)) dkye
-- from xyqb_i_repayment_plan_bak a from rc_syn_to_baihang_report.xyqb_i_repayment_plan_bak a
-- left join xyqb_i_loan_a_m_history_bak b left join rc_syn_to_baihang_report.xyqb_i_loan_a_m_history_bak b
from xyqb_i_repayment_plan a
left join xyqb_i_loan_application_manifest_history b
on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at &lt; #{endTime,jdbcType=VARCHAR} on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at &lt; #{endTime,jdbcType=VARCHAR}
-- left join xyqb_i_repayment_plan_bak e on a.loan_application_history_id=e.loan_application_history_id left join rc_syn_to_baihang_report.xyqb_i_repayment_plan_bak e on a.loan_application_history_id=e.loan_application_history_id
left join xyqb_i_repayment_plan e on a.loan_application_history_id=e.loan_application_history_id
left join xyqb_i_plan_amount_detail h on e.id=h.plan_id left join xyqb_i_plan_amount_detail h on e.id=h.plan_id
-- funding_corp_id 放开 /*where b.funding_corp_id in (420,520,580,650,670,810,240,640,700)*/
where b.funding_corp_id in (420,520,580,650,670,810,240,640,700)
group by a.loan_application_history_id,a.term_no group by a.loan_application_history_id,a.term_no
) i2 ) i2
on a.loan_application_history_id=i2.loan_application_history_id and a.term_no=i2.term_no on a.loan_application_history_id=i2.loan_application_history_id and a.term_no=i2.term_no
-- left join xyqb_i_repayment_plan_bak j on a.loan_application_history_id=j.loan_application_history_id left join rc_syn_to_baihang_report.xyqb_i_repayment_plan_bak j on a.loan_application_history_id=j.loan_application_history_id
left join xyqb_i_repayment_plan j on a.loan_application_history_id=j.loan_application_history_id
and if(DATEDIFF(a.next_deadline,a.repaid_at)>1,a.term_no,h.max_term)=j.term_no and if(DATEDIFF(a.next_deadline,a.repaid_at)>1,a.term_no,h.max_term)=j.term_no
group by if(d.order_no is null,a.loan_application_history_id,d.order_no), group by if(d.order_no is null,a.loan_application_history_id,d.order_no),
if(DATEDIFF(a.next_deadline,a.repaid_at)>1,a.term_no,h.max_term); if(DATEDIFF(a.next_deadline,a.repaid_at)>1,a.term_no,h.max_term);
...@@ -831,7 +799,8 @@ ...@@ -831,7 +799,8 @@
left join xyqb_i_repayment_record g on a.id=g.repayment_plan_id; left join xyqb_i_repayment_record g on a.id=g.repayment_plan_id;
--> -->
<!-- 2020.06.02 助贷-非联合贷实时逾期,查询原始表,不用bak临时表 --> <!-- 2020.06.02 4.1助贷-非联合贷实时逾期,查询原始表,不用bak临时表 -->
<!-- 查询bak表,并且使用v2库 -->
select select
a.id reqID a.id reqID
,'A' opCode ,'A' opCode
...@@ -859,18 +828,13 @@ ...@@ -859,18 +828,13 @@
from ( from (
select select
a.id,a.user_id,a.loan_application_history_id,a.term_no,a.deadline,a.required_repayment,a.repayment_status,a.repaid_at,a.repayment_received_at a.id,a.user_id,a.loan_application_history_id,a.term_no,a.deadline,a.required_repayment,a.repayment_status,a.repaid_at,a.repayment_received_at
-- from xyqb_i_repayment_plan_bak a from rc_syn_to_baihang_report.xyqb_i_repayment_plan_bak a
-- left join xyqb_i_loan_a_m_history_bak b /**xyqb_i_loan_application_manifest_history*/ left join rc_syn_to_baihang_report.xyqb_i_loan_a_m_history_bak b
from xyqb_i_repayment_plan a
left join xyqb_i_loan_application_manifest_history b
on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at &lt; #{endTime,jdbcType=VARCHAR} on a.loan_application_history_id=b.loan_application_history_id and b.loan_paid_at &lt; #{endTime,jdbcType=VARCHAR}
where (a.repayment_status !=3 or (a.repayment_status =3 and a.repaid_at>= #{endTime,jdbcType=VARCHAR})) and where (a.repayment_status !=3 or (a.repayment_status =3 and a.repaid_at>= #{endTime,jdbcType=VARCHAR})) and
if(b.contract_term>a.term_no,DATEDIFF( #{endTime,jdbcType=VARCHAR},a.deadline)=0,DATEDIFF( #{endTime,jdbcType=VARCHAR},a.deadline)>=0) if(b.contract_term>a.term_no,DATEDIFF( #{endTime,jdbcType=VARCHAR},a.deadline)=0,DATEDIFF( #{endTime,jdbcType=VARCHAR},a.deadline)>=0)
and floor(DATEDIFF( #{endTime,jdbcType=VARCHAR},a.deadline)/30)=DATEDIFF( #{endTime,jdbcType=VARCHAR},a.deadline)/30 and floor(DATEDIFF( #{endTime,jdbcType=VARCHAR},a.deadline)/30)=DATEDIFF( #{endTime,jdbcType=VARCHAR},a.deadline)/30
-- funding_corp_id 放开 /**and b.funding_corp_id in (420,520,580,650,670,810,240,640,700)*/
and b.funding_corp_id in (420,520,580,650,670,810,240,640,700)
and b.transaction_status in (2,5) and b.transaction_status in (2,5)
and b.contract_term not in (2,3) and b.contract_term not in (2,3)
) a ) a
...@@ -882,16 +846,11 @@ ...@@ -882,16 +846,11 @@
,sum(if((a.repayment_status !=3 or (a.repayment_status =3 and a.repaid_at>= #{endTime,jdbcType=VARCHAR})) and a.deadline &lt;= #{endTime,jdbcType=VARCHAR},if(b.loan_paid_at>='2018-01-01',g.principal+g.interest+g.service_fee,h.principle+h.interest+h.service_fee_per_term),0)) yqze ,sum(if((a.repayment_status !=3 or (a.repayment_status =3 and a.repaid_at>= #{endTime,jdbcType=VARCHAR})) and a.deadline &lt;= #{endTime,jdbcType=VARCHAR},if(b.loan_paid_at>='2018-01-01',g.principal+g.interest+g.service_fee,h.principle+h.interest+h.service_fee_per_term),0)) yqze
,sum(if(a.repayment_status !=3 or (a.repayment_status =3 and a.repaid_at>= #{endTime,jdbcType=VARCHAR}),if(b.loan_paid_at>='2018-01-01',g.principal,h.principle),0)) dkye ,sum(if(a.repayment_status !=3 or (a.repayment_status =3 and a.repaid_at>= #{endTime,jdbcType=VARCHAR}),if(b.loan_paid_at>='2018-01-01',g.principal,h.principle),0)) dkye
,min(if((a.repayment_status !=3 or (a.repayment_status =3 and a.repaid_at>= #{endTime,jdbcType=VARCHAR})) and a.deadline &lt;= #{endTime,jdbcType=VARCHAR},a.deadline,null)) min_deadline ,min(if((a.repayment_status !=3 or (a.repayment_status =3 and a.repaid_at>= #{endTime,jdbcType=VARCHAR})) and a.deadline &lt;= #{endTime,jdbcType=VARCHAR},a.deadline,null)) min_deadline
-- from xyqb_i_repayment_plan_bak a from rc_syn_to_baihang_report.xyqb_i_repayment_plan_bak a
-- left join xyqb_i_loan_a_m_history_bak b on a.loan_application_history_id=b.loan_application_history_id left join rc_syn_to_baihang_report.xyqb_i_loan_a_m_history_bak b on a.loan_application_history_id=b.loan_application_history_id
from xyqb_i_repayment_plan a
left join xyqb_i_loan_application_manifest_history b on a.loan_application_history_id=b.loan_application_history_id
left join xyqb_i_repayment_record g on a.id=g.repayment_plan_id left join xyqb_i_repayment_record g on a.id=g.repayment_plan_id
left join xyqb_i_plan_amount_detail h on a.id=h.plan_id left join xyqb_i_plan_amount_detail h on a.id=h.plan_id
-- funding_corp_id 放开 /** where b.funding_corp_id in (420,520,580,650,670,810,240,640,700)*/
where b.funding_corp_id in (420,520,580,650,670,810,240,640,700)
group by a.loan_application_history_id group by a.loan_application_history_id
) f on a.loan_application_history_id=f.loan_application_history_id ) f on a.loan_application_history_id=f.loan_application_history_id
left join xyqb_i_repayment_record g on a.id=g.repayment_plan_id; left join xyqb_i_repayment_record g on a.id=g.repayment_plan_id;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment