Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-mvp
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
fangxinjiang
yifu-mvp
Commits
defed433
Commit
defed433
authored
Mar 02, 2023
by
hongguangwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MVP1.5.1-收入证明等
parent
d2d0db33
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
112 deletions
+70
-112
TCheckBankNoController.java
...loud/plus/v1/check/controller/TCheckBankNoController.java
+2
-1
TCheckBankNoService.java
...yifu/cloud/plus/v1/check/service/TCheckBankNoService.java
+2
-1
TCheckBankNoServiceImpl.java
...d/plus/v1/check/service/impl/TCheckBankNoServiceImpl.java
+66
-110
No files found.
yifu-check/yifu-check-biz/src/main/java/com/yifu/cloud/plus/v1/check/controller/TCheckBankNoController.java
View file @
defed433
...
...
@@ -33,6 +33,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
import
java.util.concurrent.ExecutionException
;
/**
...
...
@@ -135,7 +136,7 @@ public class TCheckBankNoController {
@SysLog
(
"批量银行卡号校验"
)
@Inner
@PostMapping
(
"/inner/checkBankNoBatch"
)
public
CheckBatchVo
checkBankNoBatch
(
@RequestBody
List
<
TCheckBankNo
>
list
)
{
public
CheckBatchVo
checkBankNoBatch
(
@RequestBody
List
<
TCheckBankNo
>
list
)
throws
ExecutionException
,
InterruptedException
{
return
tCheckBankNoService
.
checkBankNoBatch
(
list
);
}
...
...
yifu-check/yifu-check-biz/src/main/java/com/yifu/cloud/plus/v1/check/service/TCheckBankNoService.java
View file @
defed433
...
...
@@ -24,6 +24,7 @@ import com.yifu.cloud.plus.v1.check.vo.CheckBatchVo;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
java.util.List
;
import
java.util.concurrent.ExecutionException
;
/**
* 银行卡卡号 校验
...
...
@@ -50,6 +51,6 @@ public interface TCheckBankNoService extends IService<TCheckBankNo> {
* @Date: 2023/2/9 11:19
* @return: com.yifu.cloud.plus.v1.check.vo.CheckBatchVo
**/
CheckBatchVo
checkBankNoBatch
(
List
<
TCheckBankNo
>
list
);
CheckBatchVo
checkBankNoBatch
(
List
<
TCheckBankNo
>
list
)
throws
ExecutionException
,
InterruptedException
;
}
yifu-check/yifu-check-biz/src/main/java/com/yifu/cloud/plus/v1/check/service/impl/TCheckBankNoServiceImpl.java
View file @
defed433
...
...
@@ -31,16 +31,14 @@ import com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.Common
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.MsgUtils
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.RedisUtil
;
import
com.yifu.cloud.plus.v1.yifu.social.vo.TPaymentInfoVo
;
import
lombok.Data
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
import
static
java
.
lang
.
Thread
.
sleep
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.*
;
/**
* 银行卡卡号 校验
...
...
@@ -52,8 +50,6 @@ import static java.lang.Thread.sleep;
@Service
public
class
TCheckBankNoServiceImpl
extends
ServiceImpl
<
TCheckBankNoMapper
,
TCheckBankNo
>
implements
TCheckBankNoService
{
private
final
RedisUtil
redisUtil
;
private
final
TCanCheckService
canCheckService
;
@Override
...
...
@@ -104,10 +100,7 @@ public class TCheckBankNoServiceImpl extends ServiceImpl<TCheckBankNoMapper, TCh
}
@Override
public
CheckBatchVo
checkBankNoBatch
(
List
<
TCheckBankNo
>
list
)
{
Date
dateS
=
new
Date
();
final
String
startS
=
String
.
valueOf
(
dateS
.
getTime
());
public
CheckBatchVo
checkBankNoBatch
(
List
<
TCheckBankNo
>
list
)
throws
ExecutionException
,
InterruptedException
{
CheckBatchVo
vo
=
new
CheckBatchVo
();
List
<
String
>
noList
=
new
ArrayList
<>();
for
(
TCheckBankNo
no
:
list
)
{
...
...
@@ -126,7 +119,7 @@ public class TCheckBankNoServiceImpl extends ServiceImpl<TCheckBankNoMapper, TCh
}
List
<
TCheckBankNo
>
noCurlist
=
new
ArrayList
<>();
TCheckBankNo
cur
;
final
Map
<
String
,
Boolean
>
bankMap
=
new
HashMap
<>();
Map
<
String
,
Boolean
>
bankMap
=
new
HashMap
<>();
for
(
TCheckBankNo
check
:
list
)
{
cur
=
noMap
.
get
(
check
.
getBankNo
());
if
(
cur
!=
null
)
{
...
...
@@ -143,23 +136,35 @@ public class TCheckBankNoServiceImpl extends ServiceImpl<TCheckBankNoMapper, TCh
noCurlist
.
add
(
check
);
}
}
final
List
<
TCheckBankNo
>
saveList
=
new
ArrayList
<>();
List
<
TCheckBankNo
>
saveList
=
new
ArrayList
<>();
if
(!
noCurlist
.
isEmpty
())
{
boolean
canCheck
=
canCheckService
.
getCanCheck
();
int
taskSize
=
4
;
// 创建一个线程池
ExecutorService
pool
=
Executors
.
newFixedThreadPool
(
taskSize
);
List
<
Future
>
listF
=
new
ArrayList
<>();
if
(
noCurlist
.
size
()>=
50
)
{
int
l
=
4
;
Callable
c
;
Future
f
;
for
(
int
k
=
0
;
k
<
l
;
k
++)
{
if
((
k
+
1
)==
l
)
{
final
List
<
TCheckBankNo
>
finalList
=
noCurlist
.
subList
(
k
*
(
noCurlist
.
size
()
/
l
),
noCurlist
.
size
());
List
<
TCheckBankNo
>
finalList
=
noCurlist
.
subList
(
k
*
(
noCurlist
.
size
()
/
l
),
noCurlist
.
size
());
if
(
canCheck
)
{
doThread
(
bankMap
,
startS
,
finalList
);
c
=
new
MyCallable
(
bankMap
,
finalList
,
saveList
);
// 执行任务并获取Future对象
f
=
pool
.
submit
(
c
);
listF
.
add
(
f
);
}
else
{
doNomal
(
bankMap
,
saveList
,
finalList
);
}
}
else
{
final
List
<
TCheckBankNo
>
finalList
=
noCurlist
.
subList
(
k
*
(
noCurlist
.
size
()
/
l
),
(
k
+
1
)
*
(
noCurlist
.
size
()
/
l
));
List
<
TCheckBankNo
>
finalList
=
noCurlist
.
subList
(
k
*
(
noCurlist
.
size
()
/
l
),
(
k
+
1
)
*
(
noCurlist
.
size
()
/
l
));
if
(
canCheck
)
{
doThread
(
bankMap
,
startS
,
finalList
);
c
=
new
MyCallable
(
bankMap
,
finalList
,
saveList
);
// 执行任务并获取Future对象
f
=
pool
.
submit
(
c
);
listF
.
add
(
f
);
}
else
{
doNomal
(
bankMap
,
saveList
,
finalList
);
}
...
...
@@ -167,20 +172,20 @@ public class TCheckBankNoServiceImpl extends ServiceImpl<TCheckBankNoMapper, TCh
}
}
else
{
if
(
canCheck
)
{
doThread
(
bankMap
,
startS
,
noCurlist
);
Callable
c
=
new
MyCallable
(
bankMap
,
noCurlist
,
saveList
);
// 执行任务并获取Future对象
Future
f
=
pool
.
submit
(
c
);
listF
.
add
(
f
);
}
else
{
doNomal
(
bankMap
,
saveList
,
noCurlist
);
}
}
if
(
canCheck
)
{
Date
date
=
new
Date
();
long
start
=
date
.
getTime
();
int
maxTime
=
(
noCurlist
.
size
()*
200
);
long
start2
=
date
.
getTime
();
while
(
Thread
.
activeCount
()
>
2
&&
(
start2
-
start
)
<
maxTime
)
{
Thread
.
yield
();
date
=
new
Date
();
start2
=
date
.
getTime
();
// 关闭线程池
pool
.
shutdown
();
for
(
Future
fs
:
listF
)
{
// 从Future对象上获取任务的返回值,并输出到控制台
fs
.
get
();
}
}
//fo (TCheckBankNo no : noCurlist)
...
...
@@ -198,100 +203,51 @@ public class TCheckBankNoServiceImpl extends ServiceImpl<TCheckBankNoMapper, TCh
this
.
saveBatch
(
saveList
);
}
}
Map
<
String
,
Boolean
>
bankMapS
=
(
Map
<
String
,
Boolean
>)
redisUtil
.
get
(
startS
);
if
(
bankMapS
!=
null
&&
!
bankMapS
.
isEmpty
())
{
bankMap
.
putAll
(
bankMapS
);
}
vo
.
setCheckMap
(
bankMap
);
return
vo
;
}
private
void
doThread
(
Map
<
String
,
Boolean
>
bankMap
,
String
startS
,
List
<
TCheckBankNo
>
finalList
)
{
new
Thread
(()
->
{
List
<
TCheckBankNo
>
saveList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
finalList
.
size
();
i
++)
{
final
TCheckBankNo
no
=
finalList
.
get
(
i
);
setBankMap
(
bankMap
,
startS
,
no
,
saveList
);
}
if
(!
saveList
.
isEmpty
())
{
this
.
saveBatch
(
saveList
);
}
}).
start
();
}
private
void
doNomal
(
Map
<
String
,
Boolean
>
bankMap
,
List
<
TCheckBankNo
>
saveList
,
List
<
TCheckBankNo
>
finalList
)
{
TCheckBankNo
no
;
for
(
int
i
=
0
;
i
<
finalList
.
size
();
i
++)
{
no
=
finalList
.
get
(
i
);
final
TCheckBankNo
newNo
=
new
TCheckBankNo
();
newNo
.
setBankNo
(
no
.
getBankNo
());
newNo
.
setName
(
no
.
getName
());
newNo
.
setMessage
(
ChecksConstants
.
CHECK_CONFIG_ACCESS
);
newNo
.
setResult
(
"01"
);
newNo
.
setType
(
CommonConstants
.
ONE_STRING
);
newNo
.
setRemark
(
ChecksConstants
.
CHECK_CONFIG_ACCESS
);
saveList
.
add
(
newNo
);
bankMap
.
put
(
no
.
getBankNo
(),
true
);
}
}
public
void
setBankMap
(
Map
<
String
,
Boolean
>
bankMap
,
String
startS
,
TCheckBankNo
no
,
List
<
TCheckBankNo
>
saveList
)
{
// 1.调用银行卡信息校验api
R
<
TCheckBankNo
>
resR
=
ChecksUtil
.
checkBankNoTwoMethod
(
no
.
getName
(),
no
.
getBankNo
());
if
(
Common
.
isNotNull
(
resR
)
&&
resR
.
getCode
()
==
CommonConstants
.
SUCCESS
&&
Common
.
isNotNull
(
resR
.
getData
()))
{
TCheckBankNo
newNo
=
resR
.
getData
();
bankMap
.
put
(
no
.
getBankNo
(),
CommonConstants
.
ZERO_ONE
.
equals
(
newNo
.
getResult
()));
TCheckBankNo
newNo
;
for
(
TCheckBankNo
no
:
finalList
)
{
newNo
=
new
TCheckBankNo
();
newNo
.
setBankNo
(
no
.
getBankNo
());
newNo
.
setName
(
no
.
getName
());
newNo
.
setMessage
(
ChecksConstants
.
CHECK_CONFIG_ACCESS
);
newNo
.
setResult
(
"01"
);
newNo
.
setType
(
CommonConstants
.
ONE_STRING
);
newNo
.
setRemark
(
ChecksConstants
.
CHECK_CONFIG_ACCESS
);
saveList
.
add
(
newNo
);
}
else
{
bankMap
.
put
(
no
.
getBankNo
(),
false
);
bankMap
.
put
(
no
.
getBankNo
(),
true
);
}
Map
<
String
,
Boolean
>
bankMapS
=
(
Map
<
String
,
Boolean
>)
redisUtil
.
get
(
startS
);
if
(
bankMapS
==
null
)
{
bankMapS
=
new
HashMap
<>(
bankMap
);
}
redisUtil
.
set
(
startS
,
bankMapS
,
600L
);
}
/*public static void setBankMapByi(Map<Integer, Boolean> bankMap,int i){
bankMap.put(i,true);
}
public static void main(String[] args) {
Map<Integer, Boolean> bankMap = new HashMap<>();
int j=100;
static
class
MyCallable
implements
Callable
<
Object
>
{
private
final
List
<
TCheckBankNo
>
saveList
;
private
final
List
<
TCheckBankNo
>
noList
;
private
final
Map
<
String
,
Boolean
>
bankMap
;
List<Integer> aList = new ArrayList<>();
for (int k=0;k<50;k++) {
aList.add(k);
}
int l = 4;
for (int k=0;k<l;k++) {
if ((k+1)==l) {
final List<Integer> finalList = aList.subList(k * (aList.size() / l), aList.size());
new Thread(() -> {
for (int i=0;i<finalList.size();i++) {
final Integer finalI = finalList.get(i);
setBankMapByi(bankMap, finalI);
}
}).start();
} else {
final List<Integer> finalList = aList.subList(k * (aList.size() / l), (k + 1) * (aList.size() / l));
new Thread(() -> {
for (int i=0;i<finalList.size();i++) {
final Integer finalI = finalList.get(i);
setBankMapByi(bankMap, finalI);
}
}).start();
}
MyCallable
(
Map
<
String
,
Boolean
>
bankMap
,
List
<
TCheckBankNo
>
no
,
List
<
TCheckBankNo
>
saveList
)
{
this
.
noList
=
no
;
this
.
bankMap
=
bankMap
;
this
.
saveList
=
saveList
;
}
while (Thread.activeCount() > 2) {
Thread.yield();
}
for (int i : bankMap.keySet()) {
System.out.println(i);
public
Map
<
String
,
Boolean
>
call
()
{
for
(
TCheckBankNo
no
:
noList
)
{
// 1.调用银行卡信息校验api
R
<
TCheckBankNo
>
resR
=
ChecksUtil
.
checkBankNoTwoMethod
(
no
.
getName
(),
no
.
getBankNo
());
if
(
Common
.
isNotNull
(
resR
)
&&
resR
.
getCode
()
==
CommonConstants
.
SUCCESS
&&
Common
.
isNotNull
(
resR
.
getData
()))
{
TCheckBankNo
newNo
=
resR
.
getData
();
bankMap
.
put
(
no
.
getBankNo
(),
CommonConstants
.
ZERO_ONE
.
equals
(
newNo
.
getResult
()));
saveList
.
add
(
newNo
);
}
else
{
bankMap
.
put
(
no
.
getBankNo
(),
false
);
}
}
return
bankMap
;
}
}
*/
}
}
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