Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
financial-tools
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QG
financial-tools
Commits
aaca331f
Commit
aaca331f
authored
Sep 22, 2016
by
Java-范 志勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加存入本地数据库操作
parent
b1e1d624
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
85 additions
and
33 deletions
+85
-33
RepayFinancialAPP.java
src/main/java/cn/gq/financial/app/RepayFinancialAPP.java
+35
-24
RepayHandler.java
src/main/java/cn/gq/financial/app/handler/RepayHandler.java
+7
-3
RepayHandlerAsync.java
...n/java/cn/gq/financial/app/handler/RepayHandlerAsync.java
+11
-4
applicationContext.properties
src/main/resources/applicationContext.properties
+6
-1
applicationContext.xml
src/main/resources/applicationContext.xml
+26
-1
No files found.
src/main/java/cn/gq/financial/app/RepayFinancialAPP.java
View file @
aaca331f
package
cn
.
gq
.
financial
.
app
;
import
cn.gq.financial.model.db.RepayDetailFinancial
;
import
cn.gq.financial.service.FinancialRepayDetailService
;
import
cn.gq.financial.utils.Constants
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.context.support.ClassPathXmlApplicationContext
;
...
...
@@ -10,51 +13,59 @@ import cn.gq.financial.model.bill.UMPayBill;
import
cn.gq.financial.model.bill.WXBill
;
import
cn.gq.financial.model.bill.YeepayBill
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.concurrent.CountDownLatch
;
public
class
RepayFinancialAPP
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
RepayFinancialAPP
.
class
);
static
final
String
CONFIG_LOCAL
=
"applicationContext.xml"
;
static
final
String
CONFIG_LOCAL
=
"applicationContext.xml"
;
static
Integer
month
=
9
;
static
String
SRC_BILL_PATH
=
"E:\\WX_BILL\\UTF-8
"
;
static
String
payAprroach
=
"微信"
;
static
String
SRC_BILL_PATH
=
"E:\\wx_bill_baitiao
"
;
static
String
payAprroach
=
"微信"
;
static
String
payAccount
=
"微信-现金贷账户"
;
private
static
ClassPathXmlApplicationContext
context
=
null
;
static
Class
<?
extends
Bill
>
clazz
=
null
;
static
{
switch
(
payAprroach
){
case
"微信"
:
clazz
=
WXBill
.
class
;
break
;
case
"易宝"
:
clazz
=
YeepayBill
.
class
;
break
;
case
"联动"
:
clazz
=
UMPayBill
.
class
;
break
;
switch
(
payAprroach
)
{
case
"微信"
:
clazz
=
WXBill
.
class
;
break
;
case
"易宝"
:
clazz
=
YeepayBill
.
class
;
break
;
case
"联动"
:
clazz
=
UMPayBill
.
class
;
break
;
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
LOGGER
.
info
(
"======开始处理还款账单======"
);
long
begin
=
System
.
currentTimeMillis
();
RepayHandler
handler
=
getSpringContext
().
getBean
(
RepayHandler
.
class
);
//按照参数,对账
handler
.
repayBillDetailHandler
(
SRC_BILL_PATH
,
clazz
,
payAccount
,
month
);
handler
.
repayBillDetailHandler
(
SRC_BILL_PATH
,
clazz
,
payAccount
,
month
);
FinancialRepayDetailService
repayDetailService
=
getSpringContext
().
getBean
(
FinancialRepayDetailService
.
class
);
if
(
Constants
.
result
.
size
()
!=
0
)
{
repayDetailService
.
saveDetails
(
Constants
.
result
);
}
context
.
close
();
LOGGER
.
info
(
"======结束处理还款账单======"
);
LOGGER
.
info
(
"总计耗时--->{}mm"
,
(
System
.
currentTimeMillis
()-
begin
));
LOGGER
.
info
(
"总计耗时--->{}mm"
,
(
System
.
currentTimeMillis
()
-
begin
));
}
public
static
ClassPathXmlApplicationContext
getSpringContext
(){
if
(
null
==
context
){
public
static
ClassPathXmlApplicationContext
getSpringContext
()
{
if
(
null
==
context
)
{
context
=
new
ClassPathXmlApplicationContext
(
CONFIG_LOCAL
);
}
return
context
;
}
}
src/main/java/cn/gq/financial/app/handler/RepayHandler.java
View file @
aaca331f
...
...
@@ -5,6 +5,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.concurrent.CountDownLatch
;
import
cn.gq.financial.db.local.dao.FinancialRepayDetailMapper
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
...
...
@@ -26,6 +27,9 @@ public class RepayHandler {
private
PaycenterService
paycenterService
;
@Autowired
private
BizRepayDetailService
bizRepayDetailService
;
@Autowired
private
FinancialRepayDetailMapper
repayDetailMapper
;
private
CountDownLatch
count
=
null
;
...
...
@@ -44,7 +48,7 @@ public class RepayHandler {
List
<
Bill
>
bills
)
{
if
(
bills
.
size
()<
ITEM_SIZE
)
{
count
=
new
CountDownLatch
(
1
);
threadPoolTaskExecutor
.
execute
(
new
RepayHandlerAsync
(
bills
,
clazz
,
paycenterService
,
bizRepayDetailService
,
count
));
threadPoolTaskExecutor
.
execute
(
new
RepayHandlerAsync
(
bills
,
clazz
,
paycenterService
,
bizRepayDetailService
,
count
,
repayDetailMapper
));
}
else
{
int
group
=
bills
.
size
()/
ITEM_SIZE
;
int
cnt
=
group
;
...
...
@@ -55,11 +59,11 @@ public class RepayHandler {
int
i
=
0
;
for
(
i
=
0
;
i
<
group
;
i
++)
{
List
<
Bill
>
subList
=
bills
.
subList
(
i
*
ITEM_SIZE
,
(
i
+
1
)*
ITEM_SIZE
);
threadPoolTaskExecutor
.
execute
(
new
RepayHandlerAsync
(
subList
,
clazz
,
paycenterService
,
bizRepayDetailService
,
count
));
threadPoolTaskExecutor
.
execute
(
new
RepayHandlerAsync
(
subList
,
clazz
,
paycenterService
,
bizRepayDetailService
,
count
,
repayDetailMapper
));
}
if
(
bills
.
size
()%
ITEM_SIZE
!=
0
){
List
<
Bill
>
subList
=
bills
.
subList
(
i
*
ITEM_SIZE
,
bills
.
size
());
threadPoolTaskExecutor
.
execute
(
new
RepayHandlerAsync
(
subList
,
clazz
,
paycenterService
,
bizRepayDetailService
,
count
));
threadPoolTaskExecutor
.
execute
(
new
RepayHandlerAsync
(
subList
,
clazz
,
paycenterService
,
bizRepayDetailService
,
count
,
repayDetailMapper
));
}
}
}
...
...
src/main/java/cn/gq/financial/app/handler/RepayHandlerAsync.java
View file @
aaca331f
...
...
@@ -8,6 +8,7 @@ import java.util.Map;
import
java.util.Set
;
import
java.util.concurrent.CountDownLatch
;
import
cn.gq.financial.db.local.dao.FinancialRepayDetailMapper
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -21,6 +22,7 @@ import cn.gq.financial.model.db.RepayDetailFinancial;
import
cn.gq.financial.service.BizRepayDetailService
;
import
cn.gq.financial.service.PaycenterService
;
import
cn.gq.financial.utils.Constants
;
import
org.springframework.beans.factory.annotation.Autowired
;
public
class
RepayHandlerAsync
implements
Runnable
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
RepayHandlerAsync
.
class
);
...
...
@@ -32,16 +34,20 @@ public class RepayHandlerAsync implements Runnable {
private
BizRepayDetailService
bizRepayDetailService
;
private
CountDownLatch
count
;
private
FinancialRepayDetailMapper
repayDetailMapper
;
static
BigDecimal
MINUS_ONE
=
new
BigDecimal
(
"-1"
);
public
RepayHandlerAsync
(
List
<
Bill
>
bills
,
Class
<?
extends
Bill
>
clazz
,
PaycenterService
paycenterService
,
BizRepayDetailService
bizRepayDetailService
,
CountDownLatch
count
)
{
public
RepayHandlerAsync
(
List
<
Bill
>
bills
,
Class
<?
extends
Bill
>
clazz
,
PaycenterService
paycenterService
,
BizRepayDetailService
bizRepayDetailService
,
CountDownLatch
count
,
FinancialRepayDetailMapper
repayDetailMapper
)
{
super
();
this
.
bills
=
bills
;
this
.
clazz
=
clazz
;
this
.
paycenterService
=
paycenterService
;
this
.
bizRepayDetailService
=
bizRepayDetailService
;
this
.
count
=
count
;
this
.
repayDetailMapper
=
repayDetailMapper
;
}
...
...
@@ -52,7 +58,7 @@ public class RepayHandlerAsync implements Runnable {
List
<
RepayOrderEntity
>
payCenterRepayOrderList
=
paycenterService
.
queryRepayOrdersByOrderIds
(
payCenterOrderIds
);
//支付中心的还款记录
List
<
RepayDetailFinancial
>
all
=
bizRepayDetailService
.
getDetailByPayCenterRepayOrder
(
payCenterRepayOrderList
);
balanceBillAndDetail
(
bills
,
all
);
saveDetails
(
all
);
//
saveDetails(all);
addToResult
(
all
);
LOGGER
.
info
(
"##Thread-->{}结束处理账单##"
,
Thread
.
currentThread
().
getName
());
}
catch
(
Exception
e
){
...
...
@@ -70,7 +76,8 @@ public class RepayHandlerAsync implements Runnable {
private
void
saveDetails
(
List
<
RepayDetailFinancial
>
all
)
{
int
count
=
repayDetailMapper
.
insert
(
all
);
LOGGER
.
info
(
"待插入记录数为{}条, 成功插入{}条"
,
all
.
size
(),
count
);
}
private
void
balanceBillAndDetail
(
List
<
Bill
>
bills
,
List
<
RepayDetailFinancial
>
all
)
{
...
...
src/main/resources/applicationContext.properties
View file @
aaca331f
...
...
@@ -32,4 +32,9 @@ financial.jdbc.password=quantgroup.com
#lkbadmin
lkbadmin.jdbc.url
=
jdbc:mysql://10.0.44.12:3306/lkbadmin?useUnicode=true&characterEncoding=utf8
lkbadmin.jdbc.username
=
lkbadmin_w
lkbadmin.jdbc.password
=
wj0msj8J8/v2Ee6Xl75ZDizrJBdEDOAQGlxTGKbRFng=
\ No newline at end of file
lkbadmin.jdbc.password
=
wj0msj8J8/v2Ee6Xl75ZDizrJBdEDOAQGlxTGKbRFng=
#localDB
local.repayment.jdbc.url
=
jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf8
local.repayment.jdbc.username
=
root
local.repayment.jdbc.password
=
root
\ No newline at end of file
src/main/resources/applicationContext.xml
View file @
aaca331f
...
...
@@ -193,7 +193,7 @@
minIdle: 最小空闲连接
<property name="minIdle" value="5"/>
</bean> -->
<!-- 支付中心数据源SqlSessionFactory -->
<bean
id=
"paymentCenterSqlSessionFactory"
class=
"org.mybatis.spring.SqlSessionFactoryBean"
>
<property
name=
"configLocation"
value=
"classpath:mybatis-paymentcenter-config.xml"
></property>
...
...
@@ -266,4 +266,29 @@
<property name="basePackage" value="cn.lyy.lkbadmin.dao" />
<property name="sqlSessionFactoryBeanName" value="lkbAdminSqlSessionFactory" />
</bean> -->
<!-- 帐单本地数据库操作相关配置信息 begin -->
<bean
id=
"localRepaymentDS"
class=
"org.apache.commons.dbcp.BasicDataSource"
destroy-method=
"close"
>
<property
name=
"driverClassName"
value=
"${jdbc.driver.name}"
/>
<property
name=
"url"
value=
"${local.repayment.jdbc.url}"
/>
<property
name=
"username"
value=
"${local.repayment.jdbc.username}"
/>
<property
name=
"password"
value=
"${local.repayment.jdbc.password}"
/>
<!--maxActive: 最大连接数量-->
<property
name=
"maxActive"
value=
"50"
/>
<!--minIdle: 最小空闲连接-->
<property
name=
"minIdle"
value=
"5"
/>
</bean>
<bean
id=
"localRepaymentSqlSessionFactory"
class=
"org.mybatis.spring.SqlSessionFactoryBean"
>
<property
name=
"configLocation"
value=
"classpath:mybatis-local-repayment-config.xml"
></property>
<property
name=
"dataSource"
ref=
"localRepaymentDS"
/>
</bean>
<bean
class=
"org.mybatis.spring.mapper.MapperScannerConfigurer"
>
<property
name=
"basePackage"
value=
"cn.gq.financial.db.local.dao"
/>
<property
name=
"sqlSessionFactoryBeanName"
value=
"localRepaymentSqlSessionFactory"
/>
</bean>
<!-- 帐单本地数据库操作相关配置信息 end -->
</beans>
\ No newline at end of file
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