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
214b3e98
Commit
214b3e98
authored
Oct 24, 2019
by
liwenbin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支持并行测试
parent
2a1bc926
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
313 additions
and
33 deletions
+313
-33
AssetServiceImpl.java
...set/distribution/service/asset/impl/AssetServiceImpl.java
+48
-33
FinanceProductHitLog.java
...distribution/service/jpa/entity/FinanceProductHitLog.java
+78
-0
FundModuleChannelFundConfig.java
...ution/service/jpa/entity/FundModuleChannelFundConfig.java
+3
-0
IFinanceProductHitLogRepository.java
...rvice/jpa/repository/IFinanceProductHitLogRepository.java
+9
-0
IFinanceProductHitLogService.java
...ibution/service/product/IFinanceProductHitLogService.java
+19
-0
FinanceProductHitLogServiceImpl.java
...service/product/impl/FinanceProductHitLogServiceImpl.java
+156
-0
No files found.
src/main/java/com/quantgroup/asset/distribution/service/asset/impl/AssetServiceImpl.java
View file @
214b3e98
...
...
@@ -34,6 +34,7 @@ import com.quantgroup.asset.distribution.service.funding.IFundModuleChannelFundC
import
com.quantgroup.asset.distribution.service.jpa.entity.Asset
;
import
com.quantgroup.asset.distribution.service.jpa.entity.AssetAttributeExtendConfig
;
import
com.quantgroup.asset.distribution.service.jpa.entity.FundModuleChannelFundConfig
;
import
com.quantgroup.asset.distribution.service.product.IFinanceProductHitLogService
;
import
com.quantgroup.asset.distribution.service.rule.IRuleService
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -61,6 +62,8 @@ public class AssetServiceImpl implements IAssetService{
private
IFundModuleChannelFundConfigService
fundModuleCHannelFundConfigService
;
@Autowired
private
IRuleService
ruleService
;
@Autowired
private
IFinanceProductHitLogService
financeProductHitLogService
;
@Async
...
...
@@ -126,44 +129,40 @@ public class AssetServiceImpl implements IAssetService{
}
public
GlobalResponse
checkNewAssetForm
(
AssetForm
assetForm
)
{
if
(
"true"
.
equals
(
assetForm
.
getAuditResult
()))
{
if
(
StringUtils
.
isEmpty
(
assetForm
.
getAmount
())
||
StringUtils
.
isEmpty
(
assetForm
.
getTerm
()))
{
return
GlobalResponse
.
create
(
AssetResponse
.
AMOUNT_OR_TERM_IS_EMPTY
);
}
if
(
StringUtils
.
isEmpty
(
assetForm
.
getAmount
())
||
StringUtils
.
isEmpty
(
assetForm
.
getTerm
()))
{
return
GlobalResponse
.
create
(
AssetResponse
.
AMOUNT_OR_TERM_IS_EMPTY
);
}
return
GlobalResponse
.
create
(
AssetResponse
.
SUCCESS
);
}
public
GlobalResponse
checkOldAssetForm
(
AssetForm
assetForm
)
{
if
(
"true"
.
equals
(
assetForm
.
getAuditResult
()))
{
if
(
StringUtils
.
isEmpty
(
assetForm
.
getFinanceProducts
())
||
StringUtils
.
isEmpty
(
assetForm
.
getAmount
()))
{
// auditResult为true,金融产品集和amount不能为空
log
.
info
(
"资产入库auditResult为true时, 金融产品集或amount为空, uuid : {}, bizNo : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getBizNo
());
return
GlobalResponse
.
create
(
AssetResponse
.
AMOUNT_OR_FINANCE_PRODUCTS_IS_EMPTY
);
}
BigDecimal
amount
=
new
BigDecimal
(
assetForm
.
getAmount
());
BigDecimal
floor
=
null
;
JSONArray
array
=
JSON
.
parseArray
(
assetForm
.
getFinanceProducts
());
for
(
int
i
=
0
,
len
=
array
.
size
();
i
<
len
;
++
i
)
{
JSONObject
data
=
array
.
getJSONObject
(
i
);
BigDecimal
min
=
new
BigDecimal
(
data
.
getString
(
"min"
));
BigDecimal
max
=
new
BigDecimal
(
data
.
getString
(
"max"
));
BigDecimal
cha
=
max
.
subtract
(
min
);
// 0 <= max - min <= 1
if
(!(
cha
.
compareTo
(
BigDecimal
.
ZERO
)
>
-
1
&&
cha
.
compareTo
(
BigDecimal
.
ONE
)
<
1
))
{
log
.
info
(
"资产入库,金融产品集不符合(0 <= max - min <= 1)规则, uuid : {}, bizNo : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getBizNo
());
return
GlobalResponse
.
create
(
AssetResponse
.
FINANCE_PRODUCTS_IS_ERROR1
);
}
if
(
floor
==
null
||
min
.
compareTo
(
floor
)
<
0
)
{
floor
=
min
;
}
if
(
StringUtils
.
isEmpty
(
assetForm
.
getFinanceProducts
())
||
StringUtils
.
isEmpty
(
assetForm
.
getAmount
()))
{
// auditResult为true,金融产品集和amount不能为空
log
.
info
(
"资产入库auditResult为true时, 金融产品集或amount为空, uuid : {}, bizNo : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getBizNo
());
return
GlobalResponse
.
create
(
AssetResponse
.
AMOUNT_OR_FINANCE_PRODUCTS_IS_EMPTY
);
}
BigDecimal
amount
=
new
BigDecimal
(
assetForm
.
getAmount
());
BigDecimal
floor
=
null
;
JSONArray
array
=
JSON
.
parseArray
(
assetForm
.
getFinanceProducts
());
for
(
int
i
=
0
,
len
=
array
.
size
();
i
<
len
;
++
i
)
{
JSONObject
data
=
array
.
getJSONObject
(
i
);
BigDecimal
min
=
new
BigDecimal
(
data
.
getString
(
"min"
));
BigDecimal
max
=
new
BigDecimal
(
data
.
getString
(
"max"
));
BigDecimal
cha
=
max
.
subtract
(
min
);
// 0 <= max - min <= 1
if
(!(
cha
.
compareTo
(
BigDecimal
.
ZERO
)
>
-
1
&&
cha
.
compareTo
(
BigDecimal
.
ONE
)
<
1
))
{
log
.
info
(
"资产入库,金融产品集不符合(0 <= max - min <= 1)规则, uuid : {}, bizNo : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getBizNo
());
return
GlobalResponse
.
create
(
AssetResponse
.
FINANCE_PRODUCTS_IS_ERROR1
);
}
// amount >= floor
if
(
amount
.
compareTo
(
floor
)
<
0
)
{
log
.
info
(
"资产入库,金融产品及不符合(amount >= floor)规则, uuid : {}, bizNo : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getBizNo
());
return
GlobalResponse
.
create
(
AssetResponse
.
FINANCE_PRODUCTS_IS_ERROR2
);
if
(
floor
==
null
||
min
.
compareTo
(
floor
)
<
0
)
{
floor
=
min
;
}
}
// amount >= floor
if
(
amount
.
compareTo
(
floor
)
<
0
)
{
log
.
info
(
"资产入库,金融产品及不符合(amount >= floor)规则, uuid : {}, bizNo : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getBizNo
());
return
GlobalResponse
.
create
(
AssetResponse
.
FINANCE_PRODUCTS_IS_ERROR2
);
}
return
GlobalResponse
.
create
(
AssetResponse
.
SUCCESS
);
}
...
...
@@ -216,7 +215,8 @@ public class AssetServiceImpl implements IAssetService{
if
(
"false"
.
equals
(
assetForm
.
getAuditResult
()))
{
return
;
}
if
(
"true"
.
equals
(
assetForm
.
getAuditResult
())
&&
StringUtils
.
isNotEmpty
(
assetForm
.
getFinanceProducts
()))
{
// 如果auditResult为true, amount或term有一个为空, 那就不管是否是测试,都不能使用资方模块了
if
(
"true"
.
equals
(
assetForm
.
getAuditResult
())
&&
(
StringUtils
.
isEmpty
(
assetForm
.
getAmount
())
||
StringUtils
.
isEmpty
(
assetForm
.
getTerm
())))
{
return
;
}
// 创建金融产品集,并初始化金额期数
...
...
@@ -273,7 +273,22 @@ public class AssetServiceImpl implements IAssetService{
}
bucket
[
priority
]
=
true
;
}
// 装填金融产品集并返回
assetForm
.
setFinanceProducts
(
JSON
.
toJSONString
(
financeProductArray
));
String
hitFinanceProduct
=
JSON
.
toJSONString
(
financeProductArray
);
log
.
info
(
"资方模块组成金融产品集完成, uuid : {}, assetNo : {}, bizNo : {}, financeProduct : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getAssetNo
(),
assetForm
.
getBizNo
(),
hitFinanceProduct
);
// 如果金融产品集为空, 那就用hit的, 保证流程不会出错,并且没有比较
if
(
StringUtils
.
isEmpty
(
assetForm
.
getFinanceProducts
()))
{
// 装填金融产品集并返回
assetForm
.
setFinanceProducts
(
hitFinanceProduct
);
}
else
{
String
oldFinanceProduct
=
assetForm
.
getFinanceProducts
();
// 原金融产品集不为空,如果不是测试,直接返回
if
(
config
.
getType
()
==
1
)
{
// 线上需要使用
assetForm
.
setFinanceProducts
(
hitFinanceProduct
);
}
financeProductHitLogService
.
saveLog
(
assetForm
,
oldFinanceProduct
,
hitFinanceProduct
);
}
}
}
src/main/java/com/quantgroup/asset/distribution/service/jpa/entity/FinanceProductHitLog.java
0 → 100644
View file @
214b3e98
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
jpa
.
entity
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
import
javax.persistence.PrePersist
;
import
javax.persistence.PreUpdate
;
import
javax.persistence.Table
;
import
lombok.Data
;
/**
*
* @author liwenbin
*
*/
@Table
(
name
=
"finance_product_hit_log"
)
@Entity
@Data
public
class
FinanceProductHitLog
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
@Id
@Column
(
name
=
"id"
)
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Long
id
;
@Column
(
name
=
"biz_channel"
)
private
String
bizChannel
;
@Column
(
name
=
"uuid"
)
private
String
uuid
;
@Column
(
name
=
"asset_no"
)
private
String
assetNo
;
@Column
(
name
=
"biz_no"
)
private
String
bizNo
;
@Column
(
name
=
"old_finance_product"
)
private
String
oldFinanceProduct
;
@Column
(
name
=
"new_finance_product"
)
private
String
newFinanceProduct
;
@Column
(
name
=
"equals"
)
private
Boolean
equals
;
@Column
(
name
=
"enable"
)
private
Boolean
enable
;
@Column
(
name
=
"created_at"
)
private
Timestamp
createdAt
;
@Column
(
name
=
"updated_at"
)
private
Timestamp
updatedAt
;
@PrePersist
public
void
prePersist
()
{
Timestamp
timestamp
=
new
Timestamp
(
System
.
currentTimeMillis
());
createdAt
=
timestamp
;
updatedAt
=
timestamp
;
}
@PreUpdate
public
void
preUpdate
()
{
updatedAt
=
new
Timestamp
(
System
.
currentTimeMillis
());
}
}
src/main/java/com/quantgroup/asset/distribution/service/jpa/entity/FundModuleChannelFundConfig.java
View file @
214b3e98
...
...
@@ -46,6 +46,9 @@ public class FundModuleChannelFundConfig implements Serializable{
@Column
(
name
=
"fund_ids"
)
private
String
fundIds
;
@Column
(
name
=
"type"
)
private
Integer
type
;
@Column
(
name
=
"enable"
)
private
Boolean
enable
;
...
...
src/main/java/com/quantgroup/asset/distribution/service/jpa/repository/IFinanceProductHitLogRepository.java
0 → 100644
View file @
214b3e98
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
jpa
.
repository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
com.quantgroup.asset.distribution.service.jpa.entity.FinanceProductHitLog
;
public
interface
IFinanceProductHitLogRepository
extends
JpaRepository
<
FinanceProductHitLog
,
Long
>{
}
src/main/java/com/quantgroup/asset/distribution/service/product/IFinanceProductHitLogService.java
0 → 100644
View file @
214b3e98
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
product
;
import
com.quantgroup.asset.distribution.model.form.AssetForm
;
/**
* 金融产品集
* @author liwenbin
*
*/
public
interface
IFinanceProductHitLogService
{
/**
* 保存日志
* @param assetForm
* @param oldFinanceProduct
* @param newFinanceProduct
*/
public
void
saveLog
(
AssetForm
assetForm
,
String
oldFinanceProduct
,
String
newFinanceProduct
);
}
src/main/java/com/quantgroup/asset/distribution/service/product/impl/FinanceProductHitLogServiceImpl.java
0 → 100644
View file @
214b3e98
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
product
.
impl
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.quantgroup.asset.distribution.model.form.AssetForm
;
import
com.quantgroup.asset.distribution.service.jpa.entity.FinanceProductHitLog
;
import
com.quantgroup.asset.distribution.service.jpa.repository.IFinanceProductHitLogRepository
;
import
com.quantgroup.asset.distribution.service.product.IFinanceProductHitLogService
;
import
lombok.extern.slf4j.Slf4j
;
/**
*
* @author liwenbin
*
*/
@Slf4j
@Service
public
class
FinanceProductHitLogServiceImpl
implements
IFinanceProductHitLogService
{
@Autowired
private
IFinanceProductHitLogRepository
financeProductHitLogRepository
;
@Async
@Override
public
void
saveLog
(
AssetForm
assetForm
,
String
oldFinanceProduct
,
String
newFinanceProduct
)
{
try
{
FinanceProductHitLog
hitLog
=
new
FinanceProductHitLog
();
hitLog
.
setBizChannel
(
assetForm
.
getBizChannel
());
hitLog
.
setUuid
(
assetForm
.
getUuid
());
hitLog
.
setAssetNo
(
assetForm
.
getAssetNo
());
hitLog
.
setBizNo
(
assetForm
.
getBizNo
());
hitLog
.
setOldFinanceProduct
(
oldFinanceProduct
);
hitLog
.
setNewFinanceProduct
(
newFinanceProduct
);
hitLog
.
setEnable
(
true
);
hitLog
.
setEquals
(
financeProducEquals
(
oldFinanceProduct
,
newFinanceProduct
));
financeProductHitLogRepository
.
save
(
hitLog
);
}
catch
(
Exception
e
)
{
log
.
error
(
"金融产品集命中记录比较保存异常, uuid : {}, bizNo : {}, assetNo : {}, oldFInanceProduct : {}, newFinanceProduct : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getBizNo
(),
assetForm
.
getAssetNo
(),
oldFinanceProduct
,
newFinanceProduct
);
}
}
/**
* 比较是否相等
* @param oldFinanceProduct
* @param newFinanceProduct
* @return
*/
public
boolean
financeProducEquals
(
String
oldFinanceProduct
,
String
newFinanceProduct
)
{
JSONArray
oldArray
=
JSON
.
parseArray
(
oldFinanceProduct
);
JSONArray
newArray
=
JSON
.
parseArray
(
newFinanceProduct
);
if
(
oldArray
==
null
||
newArray
==
null
||
oldArray
.
size
()
!=
newArray
.
size
())
{
return
false
;
}
List
<
Map
<
String
,
String
>>
oldList
=
getAllTransToMap
(
oldArray
);
List
<
Map
<
String
,
String
>>
newList
=
getAllTransToMap
(
newArray
);
if
(
oldList
.
size
()
!=
newList
.
size
())
{
return
false
;
}
int
count
=
0
;
for
(
Map
<
String
,
String
>
oldMap
:
oldList
)
{
for
(
Map
<
String
,
String
>
newMap
:
newList
)
{
if
(!
oldMap
.
get
(
"min"
).
equals
(
newMap
.
get
(
"min"
)))
{
continue
;
}
if
(!
oldMap
.
get
(
"max"
).
equals
(
newMap
.
get
(
"max"
)))
{
continue
;
}
if
(!
oldMap
.
get
(
"term"
).
equals
(
newMap
.
get
(
"term"
)))
{
continue
;
}
if
(!
oldMap
.
get
(
"fundId"
).
equals
(
newMap
.
get
(
"fundId"
)))
{
continue
;
}
if
(!
oldMap
.
get
(
"rate"
).
equals
(
newMap
.
get
(
"rate"
)))
{
continue
;
}
if
(!
oldMap
.
get
(
"rateType"
).
equals
(
newMap
.
get
(
"rateType"
)))
{
continue
;
}
if
(!
oldMap
.
get
(
"priority"
).
equals
(
newMap
.
get
(
"priority"
)))
{
continue
;
}
if
(!
oldMap
.
get
(
"feeType"
).
equals
(
newMap
.
get
(
"feeType"
)))
{
continue
;
}
String
oldFundProductId
=
oldMap
.
get
(
"fundProductId"
);
String
newFundProductId
=
newMap
.
get
(
"fundProductId"
);
if
(
oldFundProductId
==
null
&&
newFundProductId
==
null
)
{
count
++;
}
else
if
(
oldFundProductId
!=
null
&&
newFundProductId
!=
null
)
{
if
(
oldFundProductId
.
equals
(
newFundProductId
))
{
count
++;
}
}
}
}
if
(
count
==
oldList
.
size
())
{
return
true
;
}
return
false
;
}
/**
* 金融产品集组件每一个对象,List
* @return
*/
public
List
<
Map
<
String
,
String
>>
getAllTransToMap
(
JSONArray
array
)
{
List
<
Map
<
String
,
String
>>
list
=
new
ArrayList
<>();
for
(
int
i
=
0
,
len
=
array
.
size
();
i
<
len
;
++
i
)
{
JSONObject
amountJSON
=
array
.
getJSONObject
(
i
);
String
min
=
amountJSON
.
getString
(
"min"
);
String
max
=
amountJSON
.
getString
(
"max"
);
JSONArray
termArray
=
amountJSON
.
getJSONArray
(
"terms"
);
for
(
int
j
=
0
;
j
<
termArray
.
size
();
j
++)
{
JSONObject
termJSON
=
termArray
.
getJSONObject
(
j
);
String
term
=
termJSON
.
getString
(
"term"
);
JSONArray
fundArray
=
termJSON
.
getJSONArray
(
"fundInfo"
);
for
(
int
k
=
0
;
k
<
fundArray
.
size
();
k
++)
{
JSONObject
fundJSON
=
fundArray
.
getJSONObject
(
k
);
String
fundId
=
fundJSON
.
getString
(
"fundId"
);
String
rate
=
fundJSON
.
getString
(
"rate"
);
String
rateType
=
fundJSON
.
getString
(
"rateType"
);
String
priority
=
fundJSON
.
getString
(
"priority"
);
String
feeType
=
fundJSON
.
getString
(
"feeType"
);
String
fundProductId
=
fundJSON
.
getString
(
"fundProductId"
);
Map
<
String
,
String
>
one
=
new
HashMap
<>();
one
.
put
(
"min"
,
min
);
one
.
put
(
"max"
,
max
);
one
.
put
(
"term"
,
term
);
one
.
put
(
"fundId"
,
fundId
);
one
.
put
(
"rate"
,
rate
);
one
.
put
(
"rateType"
,
rateType
);
one
.
put
(
"priority"
,
priority
);
one
.
put
(
"feeType"
,
feeType
);
one
.
put
(
"fundProductId"
,
fundProductId
);
list
.
add
(
one
);
}
}
}
return
list
;
}
}
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