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
cd590d6a
Commit
cd590d6a
authored
Jul 29, 2019
by
liwenbin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
c0348554
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
137 additions
and
25 deletions
+137
-25
Attribute.java
...group/asset/distribution/config/annotation/Attribute.java
+20
-0
QGExceptionType.java
...ntgroup/asset/distribution/exception/QGExceptionType.java
+1
-0
AssetAttributeServiceImpl.java
...ibution/service/asset/impl/AssetAttributeServiceImpl.java
+7
-5
AssetServiceImpl.java
...set/distribution/service/asset/impl/AssetServiceImpl.java
+42
-20
Asset.java
...antgroup/asset/distribution/service/jpa/entity/Asset.java
+10
-0
AssetTest.java
...om/quantgroup/asset/distribution/attribute/AssetTest.java
+57
-0
No files found.
src/main/java/com/quantgroup/asset/distribution/config/annotation/Attribute.java
0 → 100644
View file @
cd590d6a
package
com
.
quantgroup
.
asset
.
distribution
.
config
.
annotation
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
/**
* 属性注解
* @author liwenbin
*
*/
@Documented
@Target
(
ElementType
.
FIELD
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
Attribute
{
boolean
value
()
default
true
;
}
src/main/java/com/quantgroup/asset/distribution/exception/QGExceptionType.java
View file @
cd590d6a
...
@@ -24,6 +24,7 @@ public enum QGExceptionType {
...
@@ -24,6 +24,7 @@ public enum QGExceptionType {
ASSET_IN_CODE_ERROR
(
2001
,
"资产入库code异常! uuid : %s, bizNo : %s, code : %s"
),
ASSET_IN_CODE_ERROR
(
2001
,
"资产入库code异常! uuid : %s, bizNo : %s, code : %s"
),
GET_DEC_ATTRIBUTE_VALUE_ERROR
(
2002
,
"获取决策资产属性值异常, uuid : %s, keys : %s"
),
GET_DEC_ATTRIBUTE_VALUE_ERROR
(
2002
,
"获取决策资产属性值异常, uuid : %s, keys : %s"
),
ASSET_ATTRIBUTE_IS_EMPTY
(
2003
,
"%s资产属性值为空"
),
ASSET_ATTRIBUTE_IS_EMPTY
(
2003
,
"%s资产属性值为空"
),
TRANSFORM_ASSET_ATTRIBUTE_ERROR
(
2004
,
"资产属性值转换成Map异常!"
),
DISTRIBUTE_RULE_CONFIG_PRIORITY_IS_NOT_UNIQUE
(
2021
,
"资产分发规则优先级不唯一"
),
DISTRIBUTE_RULE_CONFIG_PRIORITY_IS_NOT_UNIQUE
(
2021
,
"资产分发规则优先级不唯一"
),
RULE_CALC_ERROR
(
2022
,
"规则计算出现错误, expression : %s"
),
RULE_CALC_ERROR
(
2022
,
"规则计算出现错误, expression : %s"
),
...
...
src/main/java/com/quantgroup/asset/distribution/service/asset/impl/AssetAttributeServiceImpl.java
View file @
cd590d6a
...
@@ -5,6 +5,7 @@ import java.util.HashSet;
...
@@ -5,6 +5,7 @@ import java.util.HashSet;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.MapUtils
;
import
org.apache.commons.collections.MapUtils
;
...
@@ -16,7 +17,9 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -16,7 +17,9 @@ import org.springframework.transaction.annotation.Transactional;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.base.Stopwatch
;
import
com.quantgroup.asset.distribution.constant.AssetAttributeConstants
;
import
com.quantgroup.asset.distribution.constant.AssetAttributeConstants
;
import
com.quantgroup.asset.distribution.exception.QGException
;
import
com.quantgroup.asset.distribution.exception.QGExceptionType
;
import
com.quantgroup.asset.distribution.exception.QGExceptionType
;
import
com.quantgroup.asset.distribution.exception.QGPreconditions
;
import
com.quantgroup.asset.distribution.exception.QGPreconditions
;
import
com.quantgroup.asset.distribution.model.form.AssetForm
;
import
com.quantgroup.asset.distribution.model.form.AssetForm
;
...
@@ -55,8 +58,8 @@ public class AssetAttributeServiceImpl implements IAssetAttributeService {
...
@@ -55,8 +58,8 @@ public class AssetAttributeServiceImpl implements IAssetAttributeService {
*/
*/
@Override
@Override
public
Map
<
String
,
Object
>
getAllAssetAttributeValue
(
List
<
AssetAttributeExtendConfig
>
assetAttributeExtendConfigList
,
AssetForm
assetForm
)
{
public
Map
<
String
,
Object
>
getAllAssetAttributeValue
(
List
<
AssetAttributeExtendConfig
>
assetAttributeExtendConfigList
,
AssetForm
assetForm
)
{
Stopwatch
stopwatch
=
Stopwatch
.
createStarted
();
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
AssetAttributeConstants
.
AUDIT_RESULT
,
assetForm
.
getAuditResult
());
// 决策特征Key
// 决策特征Key
Set
<
String
>
decKeys
=
new
HashSet
<>();
Set
<
String
>
decKeys
=
new
HashSet
<>();
decKeys
.
add
(
AssetAttributeConstants
.
USER_LOAN_TYPE
);
decKeys
.
add
(
AssetAttributeConstants
.
USER_LOAN_TYPE
);
...
@@ -68,6 +71,7 @@ public class AssetAttributeServiceImpl implements IAssetAttributeService {
...
@@ -68,6 +71,7 @@ public class AssetAttributeServiceImpl implements IAssetAttributeService {
// 请求决策特征
// 请求决策特征
Map
<
String
,
Object
>
decAttributeValue
=
getDecAttributeValue
(
decKeys
,
assetForm
);
Map
<
String
,
Object
>
decAttributeValue
=
getDecAttributeValue
(
decKeys
,
assetForm
);
data
.
putAll
(
decAttributeValue
);
data
.
putAll
(
decAttributeValue
);
log
.
info
(
"用户所有资产扩展属性获取完成, uuid : {}, assetNo : {}, bizNo : {}, bizType : {}, 耗时 : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getAssetNo
(),
assetForm
.
getBizNo
(),
assetForm
.
getBizType
(),
stopwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
));
return
data
;
return
data
;
}
}
...
@@ -78,6 +82,7 @@ public class AssetAttributeServiceImpl implements IAssetAttributeService {
...
@@ -78,6 +82,7 @@ public class AssetAttributeServiceImpl implements IAssetAttributeService {
*/
*/
public
Map
<
String
,
Object
>
getDecAttributeValue
(
Set
<
String
>
decKeys
,
AssetForm
assetForm
)
{
public
Map
<
String
,
Object
>
getDecAttributeValue
(
Set
<
String
>
decKeys
,
AssetForm
assetForm
)
{
if
(
CollectionUtils
.
isEmpty
(
decKeys
))
{
return
MapUtils
.
EMPTY_MAP
;
}
if
(
CollectionUtils
.
isEmpty
(
decKeys
))
{
return
MapUtils
.
EMPTY_MAP
;
}
Stopwatch
stopwatch
=
Stopwatch
.
createStarted
();
String
result
=
httpService
.
post
(
ruleEngineURL
+
"/feature/get"
,
new
HashMap
<
String
,
String
>(){{
String
result
=
httpService
.
post
(
ruleEngineURL
+
"/feature/get"
,
new
HashMap
<
String
,
String
>(){{
put
(
"uuid"
,
assetForm
.
getUuid
());
put
(
"uuid"
,
assetForm
.
getUuid
());
put
(
"bizChannel"
,
assetForm
.
getBizChannel
());
put
(
"bizChannel"
,
assetForm
.
getBizChannel
());
...
@@ -88,9 +93,7 @@ public class AssetAttributeServiceImpl implements IAssetAttributeService {
...
@@ -88,9 +93,7 @@ public class AssetAttributeServiceImpl implements IAssetAttributeService {
JSONObject
resultJSON
=
null
;
JSONObject
resultJSON
=
null
;
QGPreconditions
.
checkArgument
(
StringUtils
.
isNotEmpty
(
result
)
&&
(
resultJSON
=
JSON
.
parseObject
(
result
)).
getInteger
(
"code"
)
==
0
,
QGExceptionType
.
GET_DEC_ATTRIBUTE_VALUE_ERROR
,
assetForm
.
getUuid
(),
JSON
.
toJSONString
(
decKeys
));
QGPreconditions
.
checkArgument
(
StringUtils
.
isNotEmpty
(
result
)
&&
(
resultJSON
=
JSON
.
parseObject
(
result
)).
getInteger
(
"code"
)
==
0
,
QGExceptionType
.
GET_DEC_ATTRIBUTE_VALUE_ERROR
,
assetForm
.
getUuid
(),
JSON
.
toJSONString
(
decKeys
));
Map
<
String
,
Object
>
data
=
resultJSON
.
getJSONObject
(
"body"
);
Map
<
String
,
Object
>
data
=
resultJSON
.
getJSONObject
(
"body"
);
log
.
info
(
"决策特征属性获取完成, uuid : {}, bizChannel : {}, bizNo : {}, bizType : {}, data : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getBizChannel
(),
assetForm
.
getBizNo
(),
assetForm
.
getBizType
(),
JSON
.
toJSONString
(
data
));
log
.
info
(
"决策特征属性获取完成, uuid : {}, assetNo : {}, bizChannel : {}, bizNo : {}, bizType : {}, data : {}, 耗时 : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getAssetNo
(),
assetForm
.
getBizChannel
(),
assetForm
.
getBizNo
(),
assetForm
.
getBizType
(),
JSON
.
toJSONString
(
data
),
stopwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
));
// Map<String, Object> data = new HashMap<>();
// data.put(AssetAttributeConstants.USER_LOAN_TYPE, 1);
return
data
;
return
data
;
}
}
...
@@ -101,7 +104,6 @@ public class AssetAttributeServiceImpl implements IAssetAttributeService {
...
@@ -101,7 +104,6 @@ public class AssetAttributeServiceImpl implements IAssetAttributeService {
// 用户类型特殊处理
// 用户类型特殊处理
QGPreconditions
.
checkArgument
(
data
.
get
(
AssetAttributeConstants
.
USER_LOAN_TYPE
)
!=
null
,
QGExceptionType
.
ASSET_ATTRIBUTE_IS_EMPTY
,
AssetAttributeConstants
.
USER_LOAN_TYPE
);
QGPreconditions
.
checkArgument
(
data
.
get
(
AssetAttributeConstants
.
USER_LOAN_TYPE
)
!=
null
,
QGExceptionType
.
ASSET_ATTRIBUTE_IS_EMPTY
,
AssetAttributeConstants
.
USER_LOAN_TYPE
);
asset
.
setUserLoanType
((
Integer
)
data
.
get
(
AssetAttributeConstants
.
USER_LOAN_TYPE
));
asset
.
setUserLoanType
((
Integer
)
data
.
get
(
AssetAttributeConstants
.
USER_LOAN_TYPE
));
data
.
put
(
"user_loan_type"
,
data
.
get
(
AssetAttributeConstants
.
USER_LOAN_TYPE
));
assetRepository
.
save
(
asset
);
assetRepository
.
save
(
asset
);
if
(
assetAttributeExtendConfigList
!=
null
&&
assetAttributeExtendConfigList
.
size
()
>
0
)
{
if
(
assetAttributeExtendConfigList
!=
null
&&
assetAttributeExtendConfigList
.
size
()
>
0
)
{
...
...
src/main/java/com/quantgroup/asset/distribution/service/asset/impl/AssetServiceImpl.java
View file @
cd590d6a
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
asset
.
impl
;
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
asset
.
impl
;
import
java.lang.reflect.Field
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.TimeUnit
;
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
;
...
@@ -15,23 +13,19 @@ import org.springframework.stereotype.Service;
...
@@ -15,23 +13,19 @@ import org.springframework.stereotype.Service;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.quantgroup.asset.distribution.config.annotation.Attribute
;
import
com.quantgroup.asset.distribution.constant.DistributeLogoConstants
;
import
com.quantgroup.asset.distribution.constant.DistributeLogoConstants
;
import
com.quantgroup.asset.distribution.exception.QGException
;
import
com.quantgroup.asset.distribution.exception.QGException
;
import
com.quantgroup.asset.distribution.exception.QGExceptionType
;
import
com.quantgroup.asset.distribution.exception.QGExceptionType
;
import
com.quantgroup.asset.distribution.exception.QGPreconditions
;
import
com.quantgroup.asset.distribution.model.form.AssetForm
;
import
com.quantgroup.asset.distribution.model.form.AssetForm
;
import
com.quantgroup.asset.distribution.model.response.GlobalResponse
;
import
com.quantgroup.asset.distribution.service.alarm.IAlarmService
;
import
com.quantgroup.asset.distribution.service.alarm.IAlarmService
;
import
com.quantgroup.asset.distribution.service.asset.IAssetAttributeExtendConfigService
;
import
com.quantgroup.asset.distribution.service.asset.IAssetAttributeExtendConfigService
;
import
com.quantgroup.asset.distribution.service.asset.IAssetAttributeService
;
import
com.quantgroup.asset.distribution.service.asset.IAssetAttributeService
;
import
com.quantgroup.asset.distribution.service.asset.IAssetService
;
import
com.quantgroup.asset.distribution.service.asset.IAssetService
;
import
com.quantgroup.asset.distribution.service.distribute.IAssetDistributeService
;
import
com.quantgroup.asset.distribution.service.distribute.IAssetDistributeService
;
import
com.quantgroup.asset.distribution.service.distribute.IDistributeFailLogService
;
import
com.quantgroup.asset.distribution.service.distribute.IDistributeFailLogService
;
import
com.quantgroup.asset.distribution.service.httpclient.IHttpService
;
import
com.quantgroup.asset.distribution.service.jpa.entity.Asset
;
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.AssetAttributeExtendConfig
;
import
com.quantgroup.asset.distribution.service.jpa.repository.IAssetAttributeExtendConfigRepository
;
import
com.quantgroup.asset.distribution.util.UUIDUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -67,6 +61,8 @@ public class AssetServiceImpl implements IAssetService{
...
@@ -67,6 +61,8 @@ public class AssetServiceImpl implements IAssetService{
Map
<
String
,
Object
>
data
=
assetAttributeService
.
getAllAssetAttributeValue
(
assetAttributeExtendConfigList
,
assetForm
);
Map
<
String
,
Object
>
data
=
assetAttributeService
.
getAllAssetAttributeValue
(
assetAttributeExtendConfigList
,
assetForm
);
// 资产入库
// 资产入库
assetAttributeService
.
saveAssetAttrubite
(
asset
,
assetAttributeExtendConfigList
,
data
);
assetAttributeService
.
saveAssetAttrubite
(
asset
,
assetAttributeExtendConfigList
,
data
);
// 把资产基础属性值放入data
data
=
addAssetAttributeToData
(
asset
,
data
);
// 资产分发
// 资产分发
assetDistributeService
.
distribute
(
assetForm
,
asset
,
data
,
DistributeLogoConstants
.
FIRST
);
assetDistributeService
.
distribute
(
assetForm
,
asset
,
data
,
DistributeLogoConstants
.
FIRST
);
}
catch
(
QGException
qe
)
{
}
catch
(
QGException
qe
)
{
...
@@ -130,18 +126,44 @@ public class AssetServiceImpl implements IAssetService{
...
@@ -130,18 +126,44 @@ public class AssetServiceImpl implements IAssetService{
return
true
;
return
true
;
}
}
public
static
void
main
(
String
[]
args
)
{
/**
BigDecimal
min
=
new
BigDecimal
(
"98"
);
* 将资产属性值放入data
BigDecimal
max
=
new
BigDecimal
(
"100"
);
* @param asset
BigDecimal
cha
=
max
.
subtract
(
min
);
* @return
if
(
cha
.
compareTo
(
BigDecimal
.
ZERO
)
>
-
1
&&
cha
.
compareTo
(
BigDecimal
.
ONE
)
<
1
)
{
*/
System
.
out
.
println
(
true
);
public
Map
<
String
,
Object
>
addAssetAttributeToData
(
Asset
asset
,
Map
<
String
,
Object
>
data
)
{
}
else
{
try
{
System
.
out
.
println
(
false
);
Class
<?>
clazz
=
asset
.
getClass
();
Field
[]
flelds
=
clazz
.
getDeclaredFields
();
for
(
Field
field
:
flelds
)
{
if
(
field
.
isAnnotationPresent
(
Attribute
.
class
)
&&
field
.
getAnnotation
(
Attribute
.
class
).
value
())
{
field
.
setAccessible
(
true
);
String
name
=
transformHumpStrToUnderLineStr
(
field
.
getName
());
data
.
put
(
name
,
field
.
get
(
asset
));
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"资产属性值转换放入data异常, asset : {}"
,
JSON
.
toJSONString
(
asset
),
e
);
throw
new
QGException
(
QGExceptionType
.
TRANSFORM_ASSET_ATTRIBUTE_ERROR
);
}
return
data
;
}
/**
* 将驼峰字符转转换为下划线字符串
* @param name
* @return
*/
public
String
transformHumpStrToUnderLineStr
(
String
name
)
{
StringBuilder
sb
=
new
StringBuilder
();
char
[]
chs
=
name
.
toCharArray
();
for
(
int
i
=
0
,
len
=
chs
.
length
;
i
<
len
;
++
i
)
{
if
(
Character
.
isUpperCase
(
chs
[
i
]))
{
sb
.
append
(
"_"
+
Character
.
toLowerCase
(
chs
[
i
]));
}
else
{
sb
.
append
(
chs
[
i
]);
}
}
}
return
sb
.
toString
();
BigDecimal
amount
=
new
BigDecimal
(
"10000"
);
BigDecimal
floor
=
new
BigDecimal
(
"9999"
);
System
.
out
.
println
(
amount
.
compareTo
(
floor
));
}
}
}
}
src/main/java/com/quantgroup/asset/distribution/service/jpa/entity/Asset.java
View file @
cd590d6a
...
@@ -12,6 +12,8 @@ import javax.persistence.PrePersist;
...
@@ -12,6 +12,8 @@ import javax.persistence.PrePersist;
import
javax.persistence.PreUpdate
;
import
javax.persistence.PreUpdate
;
import
javax.persistence.Table
;
import
javax.persistence.Table
;
import
com.quantgroup.asset.distribution.config.annotation.Attribute
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.Getter
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.Setter
;
...
@@ -36,27 +38,35 @@ public class Asset implements Serializable{
...
@@ -36,27 +38,35 @@ public class Asset implements Serializable{
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Long
id
;
private
Long
id
;
@Attribute
@Column
(
name
=
"asset_no"
)
@Column
(
name
=
"asset_no"
)
private
String
assetNo
;
private
String
assetNo
;
@Attribute
@Column
(
name
=
"biz_no"
)
@Column
(
name
=
"biz_no"
)
private
String
bizNo
;
private
String
bizNo
;
@Attribute
@Column
(
name
=
"uuid"
)
@Column
(
name
=
"uuid"
)
private
String
uuid
;
private
String
uuid
;
@Attribute
@Column
(
name
=
"user_loan_type"
)
@Column
(
name
=
"user_loan_type"
)
private
Integer
userLoanType
;
private
Integer
userLoanType
;
@Attribute
@Column
(
name
=
"biz_channel"
)
@Column
(
name
=
"biz_channel"
)
private
String
bizChannel
;
private
String
bizChannel
;
@Attribute
@Column
(
name
=
"finance_product_type"
)
@Column
(
name
=
"finance_product_type"
)
private
Integer
financeProductType
;
private
Integer
financeProductType
;
@Attribute
@Column
(
name
=
"effective_time"
)
@Column
(
name
=
"effective_time"
)
private
Timestamp
effectiveTime
;
private
Timestamp
effectiveTime
;
@Attribute
@Column
(
name
=
"audit_result"
)
@Column
(
name
=
"audit_result"
)
private
Integer
auditResult
;
private
Integer
auditResult
;
...
...
src/test/java/com/quantgroup/asset/distribution/attribute/AssetTest.java
0 → 100644
View file @
cd590d6a
package
com
.
quantgroup
.
asset
.
distribution
.
attribute
;
import
java.lang.reflect.Field
;
import
com.quantgroup.asset.distribution.config.annotation.Attribute
;
import
com.quantgroup.asset.distribution.model.form.AssetForm
;
import
com.quantgroup.asset.distribution.service.jpa.entity.Asset
;
import
com.quantgroup.asset.distribution.util.UUIDUtil
;
/**
* 资产测试
* @author liwenbin
*
*/
public
class
AssetTest
{
public
static
void
main
(
String
[]
args
)
throws
IllegalArgumentException
,
IllegalAccessException
{
AssetForm
assetForm
=
new
AssetForm
();
assetForm
.
setCode
(
"0"
);
assetForm
.
setMsg
(
"success"
);
assetForm
.
setUuid
(
"561e6790-9080-41bc-8c1d-8e2524867b27"
);
assetForm
.
setBizChannel
(
"159843"
);
assetForm
.
setBizNo
(
"SP493016826165714789463533"
);
assetForm
.
setBizType
(
"0"
);
assetForm
.
setAuditResult
(
"false"
);
assetForm
.
setDeadLine
(
"deadLine"
);
assetForm
.
setCallbackUrl
(
"callbackUrl"
);
assetForm
.
setAssetNo
(
UUIDUtil
.
getAssetNo
());
Asset
asset
=
assetForm
.
transToAsset
();
Class
<?>
clazz
=
asset
.
getClass
();
Field
[]
flelds
=
clazz
.
getDeclaredFields
();
for
(
Field
field
:
flelds
)
{
if
(
field
.
isAnnotationPresent
(
Attribute
.
class
)
&&
field
.
getAnnotation
(
Attribute
.
class
).
value
())
{
field
.
setAccessible
(
true
);
String
name
=
field
.
getName
();
System
.
out
.
println
(
field
.
getName
()
+
":"
+
field
.
get
(
asset
));
name
=
checkName
(
name
);
System
.
out
.
println
(
name
+
":"
+
field
.
get
(
asset
));
}
}
}
public
static
String
checkName
(
String
name
)
{
StringBuilder
sb
=
new
StringBuilder
();
char
[]
chs
=
name
.
toCharArray
();
for
(
int
i
=
0
,
len
=
chs
.
length
;
i
<
len
;
++
i
)
{
if
(
Character
.
isUpperCase
(
chs
[
i
]))
{
sb
.
append
(
"_"
+
Character
.
toLowerCase
(
chs
[
i
]));
}
else
{
sb
.
append
(
chs
[
i
]);
}
}
return
sb
.
toString
();
}
}
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