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
8ae9b1fe
Commit
8ae9b1fe
authored
Aug 02, 2019
by
liwenbin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加参数校验失败报警
parent
763102ef
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
12 deletions
+26
-12
AssetController.java
...tgroup/asset/distribution/controller/AssetController.java
+11
-4
AssetResponse.java
...roup/asset/distribution/enums/response/AssetResponse.java
+5
-1
IAssetService.java
...group/asset/distribution/service/asset/IAssetService.java
+2
-1
AssetServiceImpl.java
...set/distribution/service/asset/impl/AssetServiceImpl.java
+8
-6
No files found.
src/main/java/com/quantgroup/asset/distribution/controller/AssetController.java
View file @
8ae9b1fe
...
@@ -13,6 +13,7 @@ import com.google.common.base.Stopwatch;
...
@@ -13,6 +13,7 @@ import com.google.common.base.Stopwatch;
import
com.quantgroup.asset.distribution.enums.response.AssetResponse
;
import
com.quantgroup.asset.distribution.enums.response.AssetResponse
;
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.model.response.GlobalResponse
;
import
com.quantgroup.asset.distribution.service.alarm.IAlarmService
;
import
com.quantgroup.asset.distribution.service.asset.IAssetService
;
import
com.quantgroup.asset.distribution.service.asset.IAssetService
;
import
com.quantgroup.asset.distribution.util.UUIDUtil
;
import
com.quantgroup.asset.distribution.util.UUIDUtil
;
...
@@ -30,6 +31,8 @@ public class AssetController {
...
@@ -30,6 +31,8 @@ public class AssetController {
@Autowired
@Autowired
private
IAssetService
assetService
;
private
IAssetService
assetService
;
@Autowired
private
IAlarmService
alarmService
;
@RequestMapping
(
"/asset_in"
)
@RequestMapping
(
"/asset_in"
)
public
GlobalResponse
assetsIn
(
AssetForm
assetForm
,
HttpServletRequest
request
)
{
public
GlobalResponse
assetsIn
(
AssetForm
assetForm
,
HttpServletRequest
request
)
{
...
@@ -37,13 +40,17 @@ public class AssetController {
...
@@ -37,13 +40,17 @@ public class AssetController {
assetForm
.
setAssetNo
(
UUIDUtil
.
getAssetNo
());
assetForm
.
setAssetNo
(
UUIDUtil
.
getAssetNo
());
String
authKey
=
request
.
getHeader
(
"as_auth_key"
);
String
authKey
=
request
.
getHeader
(
"as_auth_key"
);
log
.
info
(
"资产入库分发开始, assetForm : {}, authKey : {}"
,
JSON
.
toJSONString
(
assetForm
),
authKey
);
log
.
info
(
"资产入库分发开始, assetForm : {}, authKey : {}"
,
JSON
.
toJSONString
(
assetForm
),
authKey
);
boolean
check
=
assetService
.
checkAssetForm
(
assetForm
);
GlobalResponse
response
=
assetService
.
checkAssetForm
(
assetForm
);
if
(
!
check
)
{
if
(
response
.
getCode
()
!=
0
)
{
log
.
info
(
"资产入库入参错误, assetForm : {}, authKey : {}, 耗时 : {}"
,
JSON
.
toJSONString
(
assetForm
),
authKey
,
stopwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
));
log
.
info
(
"资产入库入参错误, assetForm : {}, authKey : {}, 耗时 : {}"
,
JSON
.
toJSONString
(
assetForm
),
authKey
,
stopwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
));
return
GlobalResponse
.
create
(
AssetResponse
.
ASSET_FORM_IS_ERROR
);
alarmService
.
dingtalkAlarm
(
"Warn"
,
"资产入库参数校验失败"
,
"bizChannel : "
+
assetForm
.
getBizChannel
()
+
" , bizType : "
+
assetForm
.
getBizType
()
+
" , bizNo : "
+
assetForm
.
getBizNo
()
+
" , assetNo : "
+
assetForm
.
getAssetNo
()
+
" , uuid : "
+
assetForm
.
getUuid
()
+
" , code : "
+
response
.
getCode
()
+
" , errorMsg : "
+
response
.
getMsg
());
return
response
;
}
}
assetService
.
assetsIn
(
assetForm
);
assetService
.
assetsIn
(
assetForm
);
log
.
info
(
"资产入库分发结束, assetForm : {}, authKey : {}, response : {}, 耗时 : {}"
,
JSON
.
toJSONString
(
assetForm
),
authKey
,
JSON
.
toJSONString
(
AssetResponse
.
SUCCESS
),
stopwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
));
log
.
info
(
"资产入库分发结束, assetForm : {}, authKey : {}, response : {}, 耗时 : {}"
,
JSON
.
toJSONString
(
assetForm
),
authKey
,
JSON
.
toJSONString
(
response
),
stopwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
));
return
GlobalResponse
.
create
(
AssetResponse
.
SUCCESS
);
return
GlobalResponse
.
create
(
AssetResponse
.
SUCCESS
);
}
}
}
}
src/main/java/com/quantgroup/asset/distribution/enums/response/AssetResponse.java
View file @
8ae9b1fe
...
@@ -10,7 +10,11 @@ import lombok.Getter;
...
@@ -10,7 +10,11 @@ import lombok.Getter;
public
enum
AssetResponse
implements
GlobalResponseEnum
{
public
enum
AssetResponse
implements
GlobalResponseEnum
{
SUCCESS
(
0
,
"success"
),
SUCCESS
(
0
,
"success"
),
ASSET_FORM_IS_ERROR
(
2001
,
"资产入库参数错误!"
);
ASSET_FORM_IS_ERROR
(
1001
,
"资产入库参数错误!"
),
AUDIT_RESULT_OR_DEAD_LINE_IS_EMPTY
(
1002
,
"auditResult或deadLine为空"
),
AMOUNT_OR_FINANCE_PRODUCTS_IS_EMPTY
(
1003
,
"auditResult为true时, 金融产品集或amount为空"
),
FINANCE_PRODUCTS_IS_ERROR1
(
1004
,
"金融产品集不符合(0 <= max - min <= 1)规则"
),
FINANCE_PRODUCTS_IS_ERROR2
(
1005
,
"金融产品及不符合(amount >= floor)规则"
);
@Getter
@Getter
private
int
code
;
private
int
code
;
...
...
src/main/java/com/quantgroup/asset/distribution/service/asset/IAssetService.java
View file @
8ae9b1fe
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
asset
;
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
asset
;
import
com.quantgroup.asset.distribution.model.form.AssetForm
;
import
com.quantgroup.asset.distribution.model.form.AssetForm
;
import
com.quantgroup.asset.distribution.model.response.GlobalResponse
;
/**
/**
* 资产Service
* 资产Service
...
@@ -21,5 +22,5 @@ public interface IAssetService {
...
@@ -21,5 +22,5 @@ public interface IAssetService {
* @param assetForm
* @param assetForm
* @return
* @return
*/
*/
public
boolean
checkAssetForm
(
AssetForm
assetForm
);
public
GlobalResponse
checkAssetForm
(
AssetForm
assetForm
);
}
}
src/main/java/com/quantgroup/asset/distribution/service/asset/impl/AssetServiceImpl.java
View file @
8ae9b1fe
...
@@ -17,9 +17,11 @@ import com.alibaba.fastjson.JSONObject;
...
@@ -17,9 +17,11 @@ import com.alibaba.fastjson.JSONObject;
import
com.google.common.base.Stopwatch
;
import
com.google.common.base.Stopwatch
;
import
com.quantgroup.asset.distribution.config.annotation.Attribute
;
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.enums.response.AssetResponse
;
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.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
;
...
@@ -93,17 +95,17 @@ public class AssetServiceImpl implements IAssetService{
...
@@ -93,17 +95,17 @@ public class AssetServiceImpl implements IAssetService{
}
}
@Override
@Override
public
boolean
checkAssetForm
(
AssetForm
assetForm
)
{
public
GlobalResponse
checkAssetForm
(
AssetForm
assetForm
)
{
// auditResult和deadLine必填
// auditResult和deadLine必填
if
(
StringUtils
.
isEmpty
(
assetForm
.
getAuditResult
())
||
StringUtils
.
isEmpty
(
assetForm
.
getDeadLine
()))
{
if
(
StringUtils
.
isEmpty
(
assetForm
.
getAuditResult
())
||
StringUtils
.
isEmpty
(
assetForm
.
getDeadLine
()))
{
log
.
info
(
"资产入库auditResult或deadLine为空, uuid : {}, bizNo : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getBizNo
());
log
.
info
(
"资产入库auditResult或deadLine为空, uuid : {}, bizNo : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getBizNo
());
return
false
;
return
GlobalResponse
.
create
(
AssetResponse
.
AUDIT_RESULT_OR_DEAD_LINE_IS_EMPTY
)
;
}
}
if
(
"true"
.
equals
(
assetForm
.
getAuditResult
()))
{
if
(
"true"
.
equals
(
assetForm
.
getAuditResult
()))
{
if
(
StringUtils
.
isEmpty
(
assetForm
.
getFinanceProducts
())
||
StringUtils
.
isEmpty
(
assetForm
.
getAmount
()))
{
if
(
StringUtils
.
isEmpty
(
assetForm
.
getFinanceProducts
())
||
StringUtils
.
isEmpty
(
assetForm
.
getAmount
()))
{
// auditResult为true,金融产品集和amount不能为空
// auditResult为true,金融产品集和amount不能为空
log
.
info
(
"资产入库auditResult为true时, 金融产品集或amount为空, uuid : {}, bizNo : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getBizNo
());
log
.
info
(
"资产入库auditResult为true时, 金融产品集或amount为空, uuid : {}, bizNo : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getBizNo
());
return
false
;
return
GlobalResponse
.
create
(
AssetResponse
.
AMOUNT_OR_FINANCE_PRODUCTS_IS_EMPTY
)
;
}
}
BigDecimal
amount
=
new
BigDecimal
(
assetForm
.
getAmount
());
BigDecimal
amount
=
new
BigDecimal
(
assetForm
.
getAmount
());
BigDecimal
floor
=
null
;
BigDecimal
floor
=
null
;
...
@@ -116,7 +118,7 @@ public class AssetServiceImpl implements IAssetService{
...
@@ -116,7 +118,7 @@ public class AssetServiceImpl implements IAssetService{
// 0 <= max - min <= 1
// 0 <= max - min <= 1
if
(!(
cha
.
compareTo
(
BigDecimal
.
ZERO
)
>
-
1
&&
cha
.
compareTo
(
BigDecimal
.
ONE
)
<
1
))
{
if
(!(
cha
.
compareTo
(
BigDecimal
.
ZERO
)
>
-
1
&&
cha
.
compareTo
(
BigDecimal
.
ONE
)
<
1
))
{
log
.
info
(
"资产入库,金融产品集不符合(0 <= max - min <= 1)规则, uuid : {}, bizNo : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getBizNo
());
log
.
info
(
"资产入库,金融产品集不符合(0 <= max - min <= 1)规则, uuid : {}, bizNo : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getBizNo
());
return
false
;
return
GlobalResponse
.
create
(
AssetResponse
.
FINANCE_PRODUCTS_IS_ERROR1
)
;
}
}
if
(
floor
==
null
||
min
.
compareTo
(
floor
)
<
0
)
{
if
(
floor
==
null
||
min
.
compareTo
(
floor
)
<
0
)
{
floor
=
min
;
floor
=
min
;
...
@@ -125,10 +127,10 @@ public class AssetServiceImpl implements IAssetService{
...
@@ -125,10 +127,10 @@ public class AssetServiceImpl implements IAssetService{
// amount >= floor
// amount >= floor
if
(
amount
.
compareTo
(
floor
)
<
0
)
{
if
(
amount
.
compareTo
(
floor
)
<
0
)
{
log
.
info
(
"资产入库,金融产品及不符合(amount >= floor)规则, uuid : {}, bizNo : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getBizNo
());
log
.
info
(
"资产入库,金融产品及不符合(amount >= floor)规则, uuid : {}, bizNo : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getBizNo
());
return
false
;
return
GlobalResponse
.
create
(
AssetResponse
.
FINANCE_PRODUCTS_IS_ERROR2
)
;
}
}
}
}
return
true
;
return
GlobalResponse
.
create
(
AssetResponse
.
SUCCESS
)
;
}
}
/**
/**
...
...
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