Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
asset-distribution
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
data-spider
asset-distribution
Commits
57754bd8
Commit
57754bd8
authored
Apr 03, 2020
by
zhengjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
6.6-2
parent
7bd81b90
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
2 deletions
+47
-2
FundConfigCondition.java
...t/distribution/model/entity/fund/FundConfigCondition.java
+1
-0
FundModuleServiceImpl.java
...tribution/service/funding/impl/FundModuleServiceImpl.java
+46
-2
No files found.
src/main/java/com/quantgroup/asset/distribution/model/entity/fund/FundConfigCondition.java
View file @
57754bd8
...
@@ -25,5 +25,6 @@ public class FundConfigCondition implements Serializable {
...
@@ -25,5 +25,6 @@ public class FundConfigCondition implements Serializable {
public
static
class
Result
{
public
static
class
Result
{
private
Boolean
success
;
private
Boolean
success
;
private
String
fundInfo
;
private
String
fundInfo
;
private
String
message
;
}
}
}
}
src/main/java/com/quantgroup/asset/distribution/service/funding/impl/FundModuleServiceImpl.java
View file @
57754bd8
...
@@ -18,7 +18,9 @@ import com.quantgroup.asset.distribution.service.rule.IRuleService;
...
@@ -18,7 +18,9 @@ import com.quantgroup.asset.distribution.service.rule.IRuleService;
import
com.quantgroup.asset.distribution.service.rule.vo.BaseRuleVO
;
import
com.quantgroup.asset.distribution.service.rule.vo.BaseRuleVO
;
import
com.quantgroup.asset.distribution.service.rule.vo.IRuleVO
;
import
com.quantgroup.asset.distribution.service.rule.vo.IRuleVO
;
import
com.quantgroup.asset.distribution.service.rule.vo.UnionRuleVO
;
import
com.quantgroup.asset.distribution.service.rule.vo.UnionRuleVO
;
import
org.apache.commons.collections.Bag
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.bag.HashBag
;
import
org.apache.commons.lang3.RandomUtils
;
import
org.apache.commons.lang3.RandomUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -251,6 +253,8 @@ public class FundModuleServiceImpl implements IFundModuleService{
...
@@ -251,6 +253,8 @@ public class FundModuleServiceImpl implements IFundModuleService{
// 资方去重, 可能存在多条件同一个资方
// 资方去重, 可能存在多条件同一个资方
Set
<
String
>
fundSet
=
new
HashSet
<>();
Set
<
String
>
fundSet
=
new
HashSet
<>();
JSONArray
fundArray
=
new
JSONArray
();
JSONArray
fundArray
=
new
JSONArray
();
List
<
String
>
fundIds
=
new
ArrayList
<>();
Map
<
String
,
String
>
fundIdToTranslateMap
=
new
HashMap
<>();
A:
for
(
ChannelFundConfigNew
channelFundConfig
:
fundConfigList
)
{
A:
for
(
ChannelFundConfigNew
channelFundConfig
:
fundConfigList
)
{
IRuleVO
ruleVO
=
ruleService
.
getIRuleVo
(
channelFundConfig
.
getLimits
());
IRuleVO
ruleVO
=
ruleService
.
getIRuleVo
(
channelFundConfig
.
getLimits
());
if
(
ruleVO
==
null
)
{
throw
new
QGException
(
QGExceptionType
.
CRATE_RULE_VO_ERROR
);
}
if
(
ruleVO
==
null
)
{
throw
new
QGException
(
QGExceptionType
.
CRATE_RULE_VO_ERROR
);
}
...
@@ -272,11 +276,13 @@ public class FundModuleServiceImpl implements IFundModuleService{
...
@@ -272,11 +276,13 @@ public class FundModuleServiceImpl implements IFundModuleService{
fundInfoJSON
.
put
(
"priority"
,
channelFundConfig
.
getPriority
());
fundInfoJSON
.
put
(
"priority"
,
channelFundConfig
.
getPriority
());
fundArray
.
add
(
fundInfoJSON
);
fundArray
.
add
(
fundInfoJSON
);
fundSet
.
add
(
key
);
fundSet
.
add
(
key
);
fundIds
.
add
(
channelFundConfig
.
getFundId
().
toString
());
}
}
}
}
FundConfigCondition
.
Result
result
=
new
FundConfigCondition
.
Result
();
FundConfigCondition
.
Result
result
=
new
FundConfigCondition
.
Result
();
if
(
CollectionUtils
.
isEmpty
(
fundArray
)){
if
(
CollectionUtils
.
isEmpty
(
fundArray
)){
result
.
setSuccess
(
false
);
result
.
setSuccess
(
false
);
result
.
setMessage
(
"不存在输出结果"
);
configCondition
.
setResult
(
result
);
configCondition
.
setResult
(
result
);
continue
;
continue
;
}
}
...
@@ -286,14 +292,38 @@ public class FundModuleServiceImpl implements IFundModuleService{
...
@@ -286,14 +292,38 @@ public class FundModuleServiceImpl implements IFundModuleService{
for
(
int
i
=
0
,
len
=
fundArray
.
size
();
i
<
len
;
i
++)
{
for
(
int
i
=
0
,
len
=
fundArray
.
size
();
i
<
len
;
i
++)
{
int
priority
=
fundArray
.
getJSONObject
(
i
).
getIntValue
(
"priority"
);
int
priority
=
fundArray
.
getJSONObject
(
i
).
getIntValue
(
"priority"
);
if
(!(
priority
>
0
&&
priority
<=
len
))
{
if
(!(
priority
>
0
&&
priority
<=
len
))
{
throw
new
QGException
(
QGExceptionType
.
FUND_PRIORITY_IS_ERROR
);
result
.
setSuccess
(
false
);
result
.
setMessage
(
"多个资方配置存在交集"
);
configCondition
.
setResult
(
result
);
continue
;
}
}
if
(
bucket
[
priority
])
{
if
(
bucket
[
priority
])
{
// 多个相同的优先级
// 多个相同的优先级
throw
new
QGException
(
QGExceptionType
.
FUND_PRIORITY_IS_ERROR
);
result
.
setSuccess
(
false
);
result
.
setMessage
(
"多个资方配置存在交集"
);
configCondition
.
setResult
(
result
);
continue
;
}
}
bucket
[
priority
]
=
true
;
bucket
[
priority
]
=
true
;
}
}
// 查看是否两个资方ID相同且条件存在交集
Bag
bag
=
new
HashBag
(
fundIds
);
boolean
hasSameResultTotal
=
false
;
for
(
String
id
:
fundIds
){
if
(
bag
.
getCount
(
id
)
>
1
){
boolean
hasSameResult
=
hasSameResult
(
configId
,
id
);
if
(
hasSameResult
){
hasSameResultTotal
=
true
;
break
;
}
}
}
if
(
hasSameResultTotal
){
result
.
setSuccess
(
false
);
result
.
setMessage
(
"同资方存在配置交集"
);
configCondition
.
setResult
(
result
);
continue
;
}
result
.
setSuccess
(
true
);
result
.
setSuccess
(
true
);
fundArray
=
JSONArray
.
parseArray
(
JSON
.
toJSONString
(
fundArray
.
stream
().
sorted
(
Comparator
.
comparingInt
(
o
->
((
JSONObject
)
o
).
getInteger
(
"priority"
))).
collect
(
Collectors
.
toList
())));
fundArray
=
JSONArray
.
parseArray
(
JSON
.
toJSONString
(
fundArray
.
stream
().
sorted
(
Comparator
.
comparingInt
(
o
->
((
JSONObject
)
o
).
getInteger
(
"priority"
))).
collect
(
Collectors
.
toList
())));
String
fundProductId
=
fundArray
.
getJSONObject
(
0
).
getString
(
"fundProductId"
);
String
fundProductId
=
fundArray
.
getJSONObject
(
0
).
getString
(
"fundProductId"
);
...
@@ -306,6 +336,20 @@ public class FundModuleServiceImpl implements IFundModuleService{
...
@@ -306,6 +336,20 @@ public class FundModuleServiceImpl implements IFundModuleService{
return
GlobalResponse
.
success
(
vo
);
return
GlobalResponse
.
success
(
vo
);
}
}
private
boolean
hasSameResult
(
Long
configId
,
String
fundId
){
List
<
BaseRuleVO
>
ruleVOS
=
new
ArrayList
<>();
FundModuleChannelFundConfigNew
config
=
fundModuleChannelFundConfigNewService
.
findById
(
configId
);
List
<
ChannelFundConfigNew
>
fundConfigList
=
JSONArray
.
parseArray
(
config
.
getFunds
(),
ChannelFundConfigNew
.
class
);
for
(
ChannelFundConfigNew
channelFundConfig
:
fundConfigList
){
if
(
fundId
.
equals
(
channelFundConfig
.
getFundId
().
toString
())){
IRuleVO
ruleVO
=
ruleService
.
getIRuleVo
(
channelFundConfig
.
getLimits
());
ruleVOS
.
addAll
(
getAllBaseRule
(
ruleVO
));
}
}
//对多个rule求交集
return
false
;
}
private
static
List
<
BaseRuleVO
>
getAllBaseRule
(
IRuleVO
ruleVO
){
private
static
List
<
BaseRuleVO
>
getAllBaseRule
(
IRuleVO
ruleVO
){
List
<
BaseRuleVO
>
baseRuleList
=
new
ArrayList
<>();
List
<
BaseRuleVO
>
baseRuleList
=
new
ArrayList
<>();
if
(
ruleVO
.
getClass
().
isAssignableFrom
(
UnionRuleVO
.
class
)){
if
(
ruleVO
.
getClass
().
isAssignableFrom
(
UnionRuleVO
.
class
)){
...
...
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