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
18afd43f
Commit
18afd43f
authored
Jun 09, 2020
by
liwenbin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
资产分发订单
parent
5b633179
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
223 additions
and
0 deletions
+223
-0
BizAssetOrderStatus.java
...roup/asset/distribution/constant/BizAssetOrderStatus.java
+19
-0
AssetController.java
...tgroup/asset/distribution/controller/AssetController.java
+6
-0
IBizAssetOrderService.java
...set/distribution/service/asset/IBizAssetOrderService.java
+23
-0
BizAssetOrderServiceImpl.java
...ribution/service/asset/impl/BizAssetOrderServiceImpl.java
+89
-0
BizAssetOrder.java
.../asset/distribution/service/jpa/entity/BizAssetOrder.java
+64
-0
IBizAssetOrderRepository.java
...tion/service/jpa/repository/IBizAssetOrderRepository.java
+17
-0
NotifyServiceImpl.java
...t/distribution/service/notify/impl/NotifyServiceImpl.java
+5
-0
No files found.
src/main/java/com/quantgroup/asset/distribution/constant/BizAssetOrderStatus.java
0 → 100644
View file @
18afd43f
package
com
.
quantgroup
.
asset
.
distribution
.
constant
;
/**
* @author : Hyuk
* @description : BizAssetOrderStatus
* @date : 2020/6/9 3:03 下午
*/
public
class
BizAssetOrderStatus
{
/**
* 分配中
*/
public
static
final
int
DISTRIBUTING
=
1
;
/**
* 分配完成
*/
public
static
final
int
DISTRIBUTE_FINISH
=
2
;
}
src/main/java/com/quantgroup/asset/distribution/controller/AssetController.java
View file @
18afd43f
...
@@ -4,6 +4,7 @@ import java.util.concurrent.TimeUnit;
...
@@ -4,6 +4,7 @@ import java.util.concurrent.TimeUnit;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
com.quantgroup.asset.distribution.service.asset.IBizAssetOrderService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
...
@@ -33,6 +34,8 @@ public class AssetController {
...
@@ -33,6 +34,8 @@ public class AssetController {
private
IAssetService
assetService
;
private
IAssetService
assetService
;
@Autowired
@Autowired
private
IAlarmService
alarmService
;
private
IAlarmService
alarmService
;
@Autowired
private
IBizAssetOrderService
bizAssetOrderService
;
@RequestMapping
(
"/asset_in"
)
@RequestMapping
(
"/asset_in"
)
public
GlobalResponse
assetsIn
(
AssetForm
assetForm
,
HttpServletRequest
request
)
{
public
GlobalResponse
assetsIn
(
AssetForm
assetForm
,
HttpServletRequest
request
)
{
...
@@ -49,6 +52,9 @@ public class AssetController {
...
@@ -49,6 +52,9 @@ public class AssetController {
+
" , code : "
+
response
.
getCode
()
+
" , errorMsg : "
+
response
.
getMsg
());
+
" , code : "
+
response
.
getCode
()
+
" , errorMsg : "
+
response
.
getMsg
());
return
response
;
return
response
;
}
}
// 保存资产分发订单
bizAssetOrderService
.
saveAssetOrder
(
assetForm
);
assetService
.
assetsIn
(
assetForm
);
assetService
.
assetsIn
(
assetForm
);
log
.
info
(
"资产入库分发结束, assetForm : {}, authKey : {}, response : {}, 耗时 : {}"
,
JSON
.
toJSONString
(
assetForm
),
authKey
,
JSON
.
toJSONString
(
response
),
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/service/asset/IBizAssetOrderService.java
0 → 100644
View file @
18afd43f
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
asset
;
import
com.quantgroup.asset.distribution.model.form.AssetForm
;
/**
* @author : Hyuk
* @description : IAssetOrderService
* @date : 2020/6/9 2:51 下午
*/
public
interface
IBizAssetOrderService
{
/**
* 保存资产分发订单
* @param assetForm
*/
public
void
saveAssetOrder
(
AssetForm
assetForm
);
/**
* 资产订单分发完成
* @param assetForm
*/
public
void
finishAssetOrder
(
AssetForm
assetForm
);
}
src/main/java/com/quantgroup/asset/distribution/service/asset/impl/BizAssetOrderServiceImpl.java
0 → 100644
View file @
18afd43f
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
asset
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.quantgroup.asset.distribution.constant.BizAssetOrderStatus
;
import
com.quantgroup.asset.distribution.model.form.AssetForm
;
import
com.quantgroup.asset.distribution.service.alarm.IAlarmService
;
import
com.quantgroup.asset.distribution.service.asset.IBizAssetOrderService
;
import
com.quantgroup.asset.distribution.service.jpa.entity.BizAssetOrder
;
import
com.quantgroup.asset.distribution.service.jpa.repository.IBizAssetOrderRepository
;
import
com.quantgroup.asset.distribution.service.redis.IRedisService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
/**
* @author : Hyuk
* @description : BizAssetOrderServiceImpl
* @date : 2020/6/9 2:55 下午
*/
@Slf4j
@Service
public
class
BizAssetOrderServiceImpl
implements
IBizAssetOrderService
{
@Autowired
private
IBizAssetOrderRepository
bizAssetOrderRepository
;
@Autowired
private
IRedisService
<
BizAssetOrder
>
redisService
;
@Autowired
private
IAlarmService
alarmService
;
private
static
final
String
BIZ_ASSET_ORDER_KEY_PREFIX
=
"ASSET_DISTRIBUTION:BIZ_ASSET_ORDER:KASMN9:"
;
@Override
public
void
saveAssetOrder
(
AssetForm
assetForm
)
{
BizAssetOrder
bizAssetOrder
=
new
BizAssetOrder
();
bizAssetOrder
.
setBizChannel
(
assetForm
.
getBizChannel
());
bizAssetOrder
.
setBizNo
(
assetForm
.
getBizNo
());
bizAssetOrder
.
setBizType
(
Integer
.
parseInt
(
assetForm
.
getBizType
()));
bizAssetOrder
.
setUuid
(
assetForm
.
getUuid
());
bizAssetOrder
.
setContext
(
JSON
.
toJSONString
(
assetForm
));
bizAssetOrder
.
setStatus
(
BizAssetOrderStatus
.
DISTRIBUTING
);
bizAssetOrder
.
setEnable
(
true
);
BizAssetOrder
dbBizAssetOrder
=
bizAssetOrderRepository
.
save
(
bizAssetOrder
);
String
redisKey
=
getBizAssetOrderKey
(
assetForm
.
getUuid
(),
assetForm
.
getBizNo
(),
assetForm
.
getBizType
());
redisService
.
setEntityEx
(
redisKey
,
dbBizAssetOrder
,
30
,
TimeUnit
.
MINUTES
);
}
@Override
public
void
finishAssetOrder
(
AssetForm
assetForm
)
{
// BizAssetOrder bizAssetOrder = redisService.getEntity(getBizAssetOrderKey(assetForm.getUuid(),
// assetForm.getBizNo(), assetForm.getBizType()));
BizAssetOrder
bizAssetOrder
=
null
;
if
(
bizAssetOrder
==
null
)
{
List
<
BizAssetOrder
>
bizAssetOrders
=
bizAssetOrderRepository
.
findByUuidAndBizNoAndBizTypeAndStatusAndEnableIsTrue
(
assetForm
.
getUuid
(),
assetForm
.
getBizNo
(),
Integer
.
parseInt
(
assetForm
.
getBizType
()),
BizAssetOrderStatus
.
DISTRIBUTING
);
if
(
CollectionUtils
.
isEmpty
(
bizAssetOrders
))
{
log
.
info
(
"资产分发订单缺失, uuid : {}, bizNo : {}, bizType : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getBizNo
(),
assetForm
.
getBizType
());
alarmService
.
dingtalkAlarm
(
"Warn"
,
"未找到资产分发中的订单"
,
"uuid : "
+
assetForm
.
getUuid
()
+
" , bizNo : "
+
assetForm
.
getBizNo
()
+
" , bizType : "
+
assetForm
.
getBizType
());
return
;
}
bizAssetOrder
=
bizAssetOrders
.
get
(
0
);
}
bizAssetOrder
.
setStatus
(
BizAssetOrderStatus
.
DISTRIBUTE_FINISH
);
bizAssetOrderRepository
.
save
(
bizAssetOrder
);
}
/**
* 获取资产订单缓存redisKey
* @param uuid
* @param bizNo
* @param bizType
* @return
*/
private
String
getBizAssetOrderKey
(
String
uuid
,
String
bizNo
,
String
bizType
)
{
StringBuilder
sb
=
new
StringBuilder
(
BIZ_ASSET_ORDER_KEY_PREFIX
);
sb
.
append
(
uuid
).
append
(
":"
).
append
(
bizNo
).
append
(
":"
).
append
(
bizType
);
return
sb
.
toString
();
}
}
src/main/java/com/quantgroup/asset/distribution/service/jpa/entity/BizAssetOrder.java
0 → 100644
View file @
18afd43f
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
jpa
.
entity
;
import
lombok.Data
;
import
javax.persistence.*
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
/**
* @author : Hyuk
* @description : BizAssetOrder
* @date : 2020/6/9 11:32 上午
*/
@Data
@Entity
@Table
(
name
=
"biz_asset_order"
)
public
class
BizAssetOrder
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
=
"biz_no"
)
private
String
bizNo
;
@Column
(
name
=
"biz_type"
)
private
Integer
bizType
;
@Column
(
name
=
"uuid"
)
private
String
uuid
;
@Column
(
name
=
"context"
)
private
String
context
;
@Column
(
name
=
"status"
)
private
Integer
status
;
@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/repository/IBizAssetOrderRepository.java
0 → 100644
View file @
18afd43f
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
jpa
.
repository
;
import
com.quantgroup.asset.distribution.service.jpa.entity.BizAssetOrder
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
java.util.List
;
/**
* @author : Hyuk
* @description : IBizAssetOrderRepository
* @date : 2020/6/9 2:49 下午
*/
public
interface
IBizAssetOrderRepository
extends
JpaRepository
<
BizAssetOrder
,
Long
>
{
List
<
BizAssetOrder
>
findByUuidAndBizNoAndBizTypeAndStatusAndEnableIsTrue
(
String
uuid
,
String
bizNo
,
Integer
bizType
,
Integer
status
);
}
src/main/java/com/quantgroup/asset/distribution/service/notify/impl/NotifyServiceImpl.java
View file @
18afd43f
...
@@ -3,6 +3,7 @@ package com.quantgroup.asset.distribution.service.notify.impl;
...
@@ -3,6 +3,7 @@ package com.quantgroup.asset.distribution.service.notify.impl;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
com.quantgroup.asset.distribution.service.asset.IBizAssetOrderService
;
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
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
...
@@ -33,6 +34,8 @@ public class NotifyServiceImpl implements INotifyService{
...
@@ -33,6 +34,8 @@ public class NotifyServiceImpl implements INotifyService{
private
IHttpService
httpService
;
private
IHttpService
httpService
;
@Autowired
@Autowired
private
IAlarmService
alarmService
;
private
IAlarmService
alarmService
;
@Autowired
private
IBizAssetOrderService
bizAssetOrderService
;
@Override
@Override
public
void
notifyFundServer
(
AssetForm
assetForm
,
Map
<
String
,
Object
>
data
)
{
public
void
notifyFundServer
(
AssetForm
assetForm
,
Map
<
String
,
Object
>
data
)
{
...
@@ -48,6 +51,8 @@ public class NotifyServiceImpl implements INotifyService{
...
@@ -48,6 +51,8 @@ public class NotifyServiceImpl implements INotifyService{
log
.
info
(
"通知资金系统结果结束, uuid : {}, bizNo : {}, assetNo : {}, callbackUrl : {}, notifyForm : {}, response : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getBizNo
(),
assetForm
.
getAssetNo
(),
assetForm
.
getCallbackUrl
(),
JSON
.
toJSONString
(
notifyMap
),
JSON
.
toJSONString
(
response
));
log
.
info
(
"通知资金系统结果结束, uuid : {}, bizNo : {}, assetNo : {}, callbackUrl : {}, notifyForm : {}, response : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getBizNo
(),
assetForm
.
getAssetNo
(),
assetForm
.
getCallbackUrl
(),
JSON
.
toJSONString
(
notifyMap
),
JSON
.
toJSONString
(
response
));
if
(
response
==
null
||
response
.
size
()==
0
||
!
"200"
.
equals
(
response
.
get
(
"statusCode"
))
||
(!
"success"
.
equals
(
response
.
get
(
"response"
))
&&
(!
JSONObject
.
isValidObject
(
response
.
get
(
"response"
))
||
0
!=
JSONObject
.
parseObject
(
response
.
get
(
"response"
)).
getInteger
(
"code"
).
intValue
())))
{
if
(
response
==
null
||
response
.
size
()==
0
||
!
"200"
.
equals
(
response
.
get
(
"statusCode"
))
||
(!
"success"
.
equals
(
response
.
get
(
"response"
))
&&
(!
JSONObject
.
isValidObject
(
response
.
get
(
"response"
))
||
0
!=
JSONObject
.
parseObject
(
response
.
get
(
"response"
)).
getInteger
(
"code"
).
intValue
())))
{
throw
new
QGException
(
QGExceptionType
.
NOTIFY_FUND_SERVER_ERROR
,
assetForm
.
getUuid
(),
assetForm
.
getBizNo
(),
assetForm
.
getAssetNo
());
throw
new
QGException
(
QGExceptionType
.
NOTIFY_FUND_SERVER_ERROR
,
assetForm
.
getUuid
(),
assetForm
.
getBizNo
(),
assetForm
.
getAssetNo
());
}
else
{
bizAssetOrderService
.
finishAssetOrder
(
assetForm
);
}
}
}
}
...
...
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