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
623c09e6
Commit
623c09e6
authored
Apr 10, 2020
by
zhengjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
6.6-2
parent
21cbc6f0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
27 deletions
+62
-27
FundModuleController.java
...p/asset/distribution/controller/FundModuleController.java
+2
-2
FundModuleServiceImpl.java
...tribution/service/funding/impl/FundModuleServiceImpl.java
+60
-25
No files found.
src/main/java/com/quantgroup/asset/distribution/controller/FundModuleController.java
View file @
623c09e6
...
...
@@ -218,13 +218,13 @@ public class FundModuleController {
}
private
GlobalResponse
simulation
(
List
<
FundConfigCondition
>
configConditions
,
Long
configId
){
log
.
info
(
"资方模块接口,根据案例进行空跑, configConditions : {}
"
,
configConditions
);
log
.
info
(
"资方模块接口,根据案例进行空跑, configConditions : {}
, configId:{}"
,
configConditions
,
configId
);
if
(
CollectionUtils
.
isEmpty
(
configConditions
))
{
return
GlobalResponse
.
create
(
FundModuleResponse
.
ID_IS_EMPTY
);
}
Stopwatch
stopwatch
=
Stopwatch
.
createStarted
();
GlobalResponse
response
=
fundModuleService
.
simulationCases
(
configConditions
,
configId
);
log
.
info
(
"资方模块接口,根据id获取所有案例, configConditions : {}
耗时 : {}, response : {}"
,
configConditions
,
stopwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
),
JSON
.
toJSONString
(
response
));
log
.
info
(
"资方模块接口,根据id获取所有案例, configConditions : {}
, configId:{}, 耗时 : {}, response : {}"
,
configConditions
,
configId
,
stopwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
),
JSON
.
toJSONString
(
response
));
return
response
;
}
}
src/main/java/com/quantgroup/asset/distribution/service/funding/impl/FundModuleServiceImpl.java
View file @
623c09e6
...
...
@@ -20,6 +20,7 @@ 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.IRuleVO
;
import
com.quantgroup.asset.distribution.service.rule.vo.UnionRuleVO
;
import
com.sun.org.apache.bcel.internal.generic.NEW
;
import
org.apache.commons.collections.Bag
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.bag.HashBag
;
...
...
@@ -390,21 +391,40 @@ public class FundModuleServiceImpl implements IFundModuleService{
}
}
/**
* 根据操作符和值生成新值 exp. > 3000 生成 3001 not in {9,10} 生成 8
* @param operator 操作符 参照 {@link RuleOperator}
* @param value 参与对比的值 若返回结果为x 则 x满足 x operator value
* @return 参照上述x
* @auth jian.zheng
* @update 2020-4-10 11:35:38
* @updatedBy jian.zheng
*/
private
static
String
getValue
(
String
operator
,
String
value
){
Class
<?>
clazz
=
getType
(
value
);
switch
(
RuleOperator
.
fromCode
(
operator
))
{
case
Equal:
case
LessThanOrEqual:
case
GreaterThanOrEqual:
return
value
;
case
NotEqual:
if
(
clazz
.
isAssignableFrom
(
BigDecimal
.
class
))
{
return
new
BigDecimal
(
value
).
add
(
new
BigDecimal
(
1
)).
toString
();
}
else
if
(
clazz
.
isAssignableFrom
(
Boolean
.
class
)){
return
Boolean
.
toString
(!
Boolean
.
valueOf
(
value
));
return
Boolean
.
toString
(!
Boolean
.
parseBoolean
(
value
));
}
else
{
if
(
value
.
length
()
==
1
){
return
String
.
valueOf
((
char
)
(
value
.
charAt
(
0
)
+
1
));
if
(
RandomUtils
.
nextInt
(
0
,
10
)
<
5
){
if
(
"a"
.
equals
(
value
)
||
"A"
.
equals
(
value
)){
return
getValue
(
">"
,
value
);
}
else
{
return
getValue
(
"<"
,
value
);
}
}
else
{
return
value
.
substring
(
0
,
value
.
length
()
-
1
)
+
String
.
valueOf
((
char
)
(
value
.
charAt
(
value
.
length
()
-
1
)
+
1
));
if
(
"z"
.
equals
(
value
)
||
"Z"
.
equals
(
value
)){
return
getValue
(
"<"
,
value
);
}
else
{
return
getValue
(
">"
,
value
);
}
}
}
case
In:
...
...
@@ -417,21 +437,13 @@ public class FundModuleServiceImpl implements IFundModuleService{
case
NotIn:
if
(
value
.
contains
(
","
)){
List
<
String
>
list
=
Arrays
.
asList
(
value
.
split
(
","
));
if
(
BigDecimal
.
class
.
isAssignableFrom
(
list
.
get
(
0
).
getClass
())){
Integer
num
=
1
;
while
(
list
.
contains
(
String
.
valueOf
(
num
))){
num
++;
}
return
num
.
toString
();
}
else
{
String
start
=
getValue
(
operator
,
list
.
get
(
0
));
while
(
list
.
contains
(
start
)){
start
=
getValue
(
"<"
,
start
);
}
return
start
;
String
start
=
getValue
(
operator
,
list
.
get
(
0
));
while
(
list
.
contains
(
start
)){
start
=
getValue
(
"!="
,
start
);
}
return
start
;
}
else
{
return
value
;
return
getValue
(
"!="
,
value
)
;
}
case
LessThan:
if
(
BigDecimal
.
class
.
isAssignableFrom
(
clazz
)){
...
...
@@ -440,24 +452,47 @@ public class FundModuleServiceImpl implements IFundModuleService{
}
else
{
return
new
BigDecimal
(
value
).
subtract
(
new
BigDecimal
(
1
)).
toString
();
}
}
else
{
throw
new
QGException
(
QGExceptionType
.
CRATE_RULE_VO_ERROR
);
}
else
if
(
String
.
class
.
isAssignableFrom
(
clazz
)){
if
(
value
.
length
()
==
1
){
if
(
"a"
.
equals
(
value
)
||
"A"
.
equals
(
value
)){
return
value
+
"-1"
;
}
else
{
return
String
.
valueOf
((
char
)
(
value
.
charAt
(
0
)
-
1
));
}
}
else
{
String
front
=
value
.
substring
(
0
,
value
.
length
()
-
1
);
String
last
=
String
.
valueOf
(
value
.
charAt
(
value
.
length
()
-
1
));
String
newLast
=
getValue
(
"<"
,
last
);
return
front
+
newLast
;
}
}
case
GreaterThan:
if
(
BigDecimal
.
class
.
isAssignableFrom
(
clazz
)){
return
new
BigDecimal
(
value
).
add
(
new
BigDecimal
(
1
)).
toString
();
}
else
{
throw
new
QGException
(
QGExceptionType
.
CRATE_RULE_VO_ERROR
);
}
else
if
(
String
.
class
.
isAssignableFrom
(
clazz
)){
if
(
value
.
length
()
==
1
){
if
(
"z"
.
equals
(
value
)
||
"Z"
.
equals
(
value
)){
return
value
+
"+1"
;
}
else
{
return
String
.
valueOf
((
char
)
(
value
.
charAt
(
0
)
+
1
));
}
}
else
{
String
front
=
value
.
substring
(
0
,
value
.
length
()
-
1
);
String
last
=
String
.
valueOf
(
value
.
charAt
(
value
.
length
()
+
1
));
String
newLast
=
getValue
(
">"
,
last
);
return
front
+
newLast
;
}
}
case
LessThanOrEqual:
return
getValue
(
"<"
,
value
);
case
GreaterThanOrEqual:
return
getValue
(
">"
,
value
);
default
:
throw
new
QGException
(
QGExceptionType
.
RULE_OPERATOR_NOT_EXIST
);
}
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
getValue
(
">="
,
"3000"
));
System
.
out
.
println
(
getValue
(
"<="
,
"3000"
));
}
private
static
Class
<?>
getType
(
String
value
){
if
(
StringUtils
.
isNumeric
(
value
)){
return
BigDecimal
.
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