Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
S
stockPriceTack
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘长帅
stockPriceTack
Commits
e8f77a13
Commit
e8f77a13
authored
May 25, 2022
by
liucx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
定时任务
parent
8c0d3919
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
3116 additions
and
15 deletions
+3116
-15
index.pb
.idea/sonarlint/issuestore/index.pb
+2668
-0
workspace.xml
.idea/workspace.xml
+25
-15
AssetAccountProductRelation.java
...et/common/pojo/dao/asset/AssetAccountProductRelation.java
+24
-0
SmartAccountProductRelation.java
...et/common/pojo/dao/smart/SmartAccountProductRelation.java
+22
-0
AssetStockPriceTask.java
...ech/telmarket/task/followAccount/AssetStockPriceTask.java
+186
-0
SmartStockPriceTask.java
...ech/telmarket/task/followAccount/SmartStockPriceTask.java
+191
-0
No files found.
.idea/sonarlint/issuestore/index.pb
View file @
e8f77a13
This source diff could not be displayed because it is too large. You can
view the blob
instead.
.idea/workspace.xml
View file @
e8f77a13
...
@@ -5,7 +5,10 @@
...
@@ -5,7 +5,10 @@
</component>
</component>
<component
name=
"ChangeListManager"
>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"87728678-ea41-4406-bbc7-9c6c6813eb7d"
name=
"Default Changelist"
comment=
"上传"
>
<list
default=
"true"
id=
"87728678-ea41-4406-bbc7-9c6c6813eb7d"
name=
"Default Changelist"
comment=
"上传"
>
<change
afterPath=
"$PROJECT_DIR$/src/main/java/com/zfxftech/telmarket/task/followAccount/StockPriceTask.java"
afterDir=
"false"
/>
<change
afterPath=
"$PROJECT_DIR$/src/main/java/com/zfxftech/telmarket/task/followAccount/AssetStockPriceTask.java"
afterDir=
"false"
/>
<change
afterPath=
"$PROJECT_DIR$/src/main/java/com/zfxftech/telmarket/task/followAccount/SmartStockPriceTask.java"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/sonarlint/issuestore/index.pb"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/sonarlint/issuestore/index.pb"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
</list>
</list>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"HIGHLIGHT_CONFLICTS"
value=
"true"
/>
<option
name=
"HIGHLIGHT_CONFLICTS"
value=
"true"
/>
...
@@ -48,21 +51,18 @@
...
@@ -48,21 +51,18 @@
<property
name=
"SONARLINT_PRECOMMIT_ANALYSIS"
value=
"true"
/>
<property
name=
"SONARLINT_PRECOMMIT_ANALYSIS"
value=
"true"
/>
<property
name=
"WebServerToolWindowFactoryState"
value=
"false"
/>
<property
name=
"WebServerToolWindowFactoryState"
value=
"false"
/>
<property
name=
"aspect.path.notification.shown"
value=
"true"
/>
<property
name=
"aspect.path.notification.shown"
value=
"true"
/>
<property
name=
"last_opened_file_path"
value=
"$PROJECT_DIR$
/src/main/java/com/zfxftech/telmarket/task/followAccount
"
/>
<property
name=
"last_opened_file_path"
value=
"$PROJECT_DIR$"
/>
<property
name=
"settings.editor.selected.configurable"
value=
"MavenSettings"
/>
<property
name=
"settings.editor.selected.configurable"
value=
"MavenSettings"
/>
</component>
</component>
<component
name=
"RecentsManager"
>
<key
name=
"CopyFile.RECENT_KEYS"
>
<recent
name=
"D:\stockPricetask\stockpricetack\src\main\java\com\zfxftech\telmarket\task\followAccount"
/>
</key>
<key
name=
"CopyClassDialog.RECENTS_KEY"
>
<recent
name=
"com.zfxftech.telmarket.task.followAccount"
/>
</key>
</component>
<component
name=
"RunManager"
>
<component
name=
"RunManager"
>
<configuration
default=
"true"
type=
"ArquillianJUnit"
factoryName=
""
nameIsGenerated=
"true"
>
<option
name=
"arquillianRunConfiguration"
>
<value>
<option
name=
"containerStateName"
value=
""
/>
</value>
</option>
<option
name=
"TEST_OBJECT"
value=
"class"
/>
<method
v=
"2"
>
<option
name=
"Make"
enabled=
"true"
/>
</method>
</configuration>
<configuration
name=
"NewInvestApplication"
type=
"SpringBootApplicationConfigurationType"
factoryName=
"Spring Boot"
>
<configuration
name=
"NewInvestApplication"
type=
"SpringBootApplicationConfigurationType"
factoryName=
"Spring Boot"
>
<module
name=
"invest"
/>
<module
name=
"invest"
/>
<option
name=
"SPRING_BOOT_MAIN_CLASS"
value=
"com.zfxftech.telmarket.NewInvestApplication"
/>
<option
name=
"SPRING_BOOT_MAIN_CLASS"
value=
"com.zfxftech.telmarket.NewInvestApplication"
/>
...
@@ -82,7 +82,9 @@
...
@@ -82,7 +82,9 @@
<option
name=
"number"
value=
"Default"
/>
<option
name=
"number"
value=
"Default"
/>
<option
name=
"presentableId"
value=
"Default"
/>
<option
name=
"presentableId"
value=
"Default"
/>
<updated>
1653440926847
</updated>
<updated>
1653440926847
</updated>
<workItem
from=
"1653440928814"
duration=
"837000"
/>
<workItem
from=
"1653440928814"
duration=
"874000"
/>
<workItem
from=
"1653466009407"
duration=
"206000"
/>
<workItem
from=
"1653471319452"
duration=
"879000"
/>
</task>
</task>
<task
id=
"LOCAL-00001"
summary=
"上传"
>
<task
id=
"LOCAL-00001"
summary=
"上传"
>
<created>
1653440999839
</created>
<created>
1653440999839
</created>
...
@@ -98,7 +100,14 @@
...
@@ -98,7 +100,14 @@
<option
name=
"project"
value=
"LOCAL"
/>
<option
name=
"project"
value=
"LOCAL"
/>
<updated>
1653441464906
</updated>
<updated>
1653441464906
</updated>
</task>
</task>
<option
name=
"localTasksCounter"
value=
"3"
/>
<task
id=
"LOCAL-00003"
summary=
"上传"
>
<created>
1653441806141
</created>
<option
name=
"number"
value=
"00003"
/>
<option
name=
"presentableId"
value=
"LOCAL-00003"
/>
<option
name=
"project"
value=
"LOCAL"
/>
<updated>
1653441806141
</updated>
</task>
<option
name=
"localTasksCounter"
value=
"4"
/>
<servers
/>
<servers
/>
</component>
</component>
<component
name=
"TypeScriptGeneratedFilesManager"
>
<component
name=
"TypeScriptGeneratedFilesManager"
>
...
@@ -114,6 +123,7 @@
...
@@ -114,6 +123,7 @@
</entry>
</entry>
</map>
</map>
</option>
</option>
<option
name=
"oldMeFiltersMigrated"
value=
"true"
/>
</component>
</component>
<component
name=
"VcsManagerConfiguration"
>
<component
name=
"VcsManagerConfiguration"
>
<option
name=
"ADD_EXTERNAL_FILES_SILENTLY"
value=
"true"
/>
<option
name=
"ADD_EXTERNAL_FILES_SILENTLY"
value=
"true"
/>
...
...
src/main/java/com/zfxftech/telmarket/common/pojo/dao/asset/AssetAccountProductRelation.java
View file @
e8f77a13
...
@@ -118,4 +118,28 @@ public class AssetAccountProductRelation {
...
@@ -118,4 +118,28 @@ public class AssetAccountProductRelation {
*/
*/
private
String
remark
;
private
String
remark
;
/**
* 示范总资产
*/
private
BigDecimal
simulatedTotalPrice
;
/**
* 示范盈亏比例
*/
private
BigDecimal
simulatedTotalProfit
;
/**
* 示范持仓比
*/
private
BigDecimal
simulatedProportion
;
/**
* 示范盘盈亏金额
*/
private
BigDecimal
profitAmount
;
/**
* 示范盘持仓数量
*/
private
int
positionCount
;
}
}
\ No newline at end of file
src/main/java/com/zfxftech/telmarket/common/pojo/dao/smart/SmartAccountProductRelation.java
View file @
e8f77a13
...
@@ -118,4 +118,26 @@ public class SmartAccountProductRelation {
...
@@ -118,4 +118,26 @@ public class SmartAccountProductRelation {
*/
*/
private
String
remark
;
private
String
remark
;
/**
* 示范总资产
*/
private
BigDecimal
simulatedTotalPrice
;
/**
* 示范盈亏比例
*/
private
BigDecimal
simulatedTotalProfit
;
/**
* 示范持仓比
*/
private
BigDecimal
simulatedProportion
;
/**
* 示范盘盈亏金额
*/
private
BigDecimal
profitAmount
;
/**
* 示范盘持仓数量
*/
private
int
positionCount
;
}
}
\ No newline at end of file
src/main/java/com/zfxftech/telmarket/task/followAccount/AssetStockPriceTask.java
0 → 100644
View file @
e8f77a13
package
com
.
zfxftech
.
telmarket
.
task
.
followAccount
;
import
com.zfxftech.telmarket.common.config.CommonConfig
;
import
com.zfxftech.telmarket.common.pojo.dao.AccountProductRelation
;
import
com.zfxftech.telmarket.common.pojo.dao.MemberBase
;
import
com.zfxftech.telmarket.common.pojo.dao.StockPosition
;
import
com.zfxftech.telmarket.common.pojo.dao.asset.AssetAccountProductRelation
;
import
com.zfxftech.telmarket.common.pojo.dao.asset.AssetStockPosition
;
import
com.zfxftech.telmarket.common.pojo.vo.MarketDetailsVO
;
import
com.zfxftech.telmarket.common.pojo.vo.asset.AssetMarketDetailsVO
;
import
com.zfxftech.telmarket.common.util.DateUtil
;
import
com.zfxftech.telmarket.common.util.OptionalUtil
;
import
com.zfxftech.telmarket.service.business.*
;
import
com.zfxftech.telmarket.service.business.asset.AssetAccountProductRelationService
;
import
com.zfxftech.telmarket.service.business.asset.AssetStockPositionService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.ApplicationArguments
;
import
org.springframework.boot.ApplicationRunner
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.ObjectUtils
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.atomic.AtomicReference
;
import
static
com
.
zfxftech
.
telmarket
.
common
.
constant
.
AdminConstant
.
MarketTypeEnum
.
REAL
;
import
static
com
.
zfxftech
.
telmarket
.
common
.
constant
.
AdminConstant
.
MarketTypeEnum
.
SIMULATED
;
/**
* Create time: 2022/1/26
*/
@Slf4j
@Component
@Order
(
value
=
1
)
/**
* 资管计算总市值、股票市值、持仓数量
*/
public
class
AssetStockPriceTask
implements
ApplicationRunner
{
@Autowired
private
AssetAccountProductRelationService
accountProductRelationService
;
@Autowired
private
AssetStockPositionService
stockPositionService
;
@Autowired
private
CommonConfig
commonConfig
;
@Autowired
private
UsMemberBaseService
memberBaseService
;
@Override
public
void
run
(
ApplicationArguments
args
)
throws
Exception
{
log
.
info
(
"私人定制计算股票统计日志开始"
);
//log.info("私人定制计算股票统计日志开始配置更新开关状态:" + commonConfig.getStockPriceTask());
//if (commonConfig.getStockPriceTask() != null && commonConfig.getStockPriceTask().equals("run")) {
if
(
true
)
{
//分页查询异动配置列表
ExecutorService
PersonalexecutorService
=
Executors
.
newSingleThreadExecutor
();
ExecutorService
executorServicePersonal
=
Executors
.
newFixedThreadPool
(
100
);
CompletableFuture
.
runAsync
(()
->
{
while
(
true
)
{
// if (DateUtil.isTradeDayForChangeRemind()) {
if
(
true
)
{
AtomicReference
<
Integer
>
pageNo
=
new
AtomicReference
<>(
1
);
Integer
pageSize
=
100
;
Date
startTime
=
new
Date
();
List
<
CompletableFuture
<
String
>>
futureList
=
new
ArrayList
<>();
List
<
AssetAccountProductRelation
>
accountProductRelations
=
accountProductRelationService
.
queryAll
();
if
(!
ObjectUtils
.
isEmpty
(
accountProductRelations
)
&&
accountProductRelations
.
size
()
>
0
)
{
log
.
info
(
"私人定制计算股票统计数据大小:{}"
,
accountProductRelations
.
size
());
Integer
pageTOtl
=
accountProductRelations
.
size
()
%
pageSize
==
0
?
accountProductRelations
.
size
()
/
pageSize
:
accountProductRelations
.
size
()
/
pageSize
+
1
;
for
(
Integer
i
=
0
;
i
<
pageTOtl
;
i
++)
{
List
<
AssetAccountProductRelation
>
accountProductRelationList
=
this
.
page
(
accountProductRelations
,
pageNo
.
get
(),
pageSize
);
CompletableFuture
cf
=
CompletableFuture
.
supplyAsync
(()
->
{
for
(
AssetAccountProductRelation
accountProductRelation
:
accountProductRelationList
)
{
this
.
AccountProductRelationTask
(
accountProductRelation
);
}
return
" "
;
},
executorServicePersonal
).
handle
((
result
,
ex
)
->
{
if
(
null
!=
ex
)
{
log
.
error
(
"资管错误消息:{}"
,
ex
);
return
0
;
}
else
{
return
result
;
}
});
futureList
.
add
(
cf
);
pageNo
.
set
(
pageNo
.
get
()
+
1
);
}
}
try
{
CompletableFuture
<
Void
>
combinedFuture
=
CompletableFuture
.
allOf
(
futureList
.
toArray
(
new
CompletableFuture
[
0
]));
combinedFuture
.
get
();
log
.
info
(
"持仓统计--------主线程开始阻塞,消息发送完成--------"
);
log
.
info
(
"持仓统计,本次共计算"
+
(
ObjectUtils
.
isEmpty
(
accountProductRelations
)
==
true
?
0
:
accountProductRelations
.
size
())
+
"持仓统计。耗时"
+
DateUtil
.
calculateTimeGapSecond
(
startTime
,
new
Date
())
+
"秒"
);
}
catch
(
Exception
e
)
{
log
.
error
(
"持仓统计错误信息:{}"
,
e
);
e
.
printStackTrace
();
}
try
{
Thread
.
sleep
(
20000
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
else
{
try
{
Thread
.
sleep
(
8000
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
},
PersonalexecutorService
);
}
}
public
List
<
AssetAccountProductRelation
>
page
(
List
<
AssetAccountProductRelation
>
list
,
Integer
pageNo
,
Integer
pageSize
)
{
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
list
;
}
List
<
AssetAccountProductRelation
>
resultList
=
new
ArrayList
();
// 所有dataList数据中的第几条
int
currIdx
=
pageNo
>
1
?
(
pageNo
-
1
)
*
pageSize
:
0
;
for
(
int
i
=
0
;
i
<
pageSize
&&
i
<
list
.
size
()
-
currIdx
;
i
++)
{
resultList
.
add
(
list
.
get
(
currIdx
+
i
));
}
return
resultList
;
}
//私人定制
public
void
AccountProductRelationTask
(
AssetAccountProductRelation
accountProductRelation
)
{
String
type
=
SIMULATED
.
getCode
();
OptionalUtil
.
checkNull
(
accountProductRelation
,
"当前用户产品关系不存在"
);
//查询客户信息
Long
customerId
=
accountProductRelation
.
getCustomerId
();
MemberBase
memberBase
=
memberBaseService
.
queryUsMemberBaseById
(
customerId
);
Long
marketId
=
accountProductRelation
.
getSimulatedMarketId
();
OptionalUtil
.
checkNull
(
memberBase
,
"查询用户数据不存在"
);
//查询持仓信息
BigDecimal
funding
=
null
;
//获取可用资金
if
(
REAL
.
getCode
().
equals
(
type
))
{
funding
=
accountProductRelation
.
getRealFunding
();
}
if
(
SIMULATED
.
getCode
().
equals
(
type
))
{
funding
=
accountProductRelation
.
getSimulatedFunding
();
}
//获取所有买入过的股票
List
<
AssetStockPosition
>
stockPositions
=
stockPositionService
.
queryStockPositions
(
marketId
);
//汇总数据
AssetMarketDetailsVO
marketDetailsVO
=
stockPositionService
.
createMarketDetailsVO
(
memberBase
,
stockPositions
,
funding
,
accountProductRelation
,
marketId
);
//示范盈亏比例
accountProductRelation
.
setSimulatedTotalProfit
(
new
BigDecimal
(
marketDetailsVO
.
getTotalProfitRate
()));
//示范盘总资产
accountProductRelation
.
setSimulatedTotalPrice
(
new
BigDecimal
(
marketDetailsVO
.
getTotalPrice
()));
//示范持仓比
accountProductRelation
.
setSimulatedProportion
(
new
BigDecimal
(
marketDetailsVO
.
getPosition
()));
//示范盘持仓数量
accountProductRelation
.
setPositionCount
(
ObjectUtils
.
isEmpty
(
stockPositions
.
size
())
?
0
:
stockPositions
.
size
());
//示范盘盈亏金额
accountProductRelation
.
setProfitAmount
(
new
BigDecimal
(
marketDetailsVO
.
getTotalProfit
()));
accountProductRelationService
.
updateAccountProductRelation
(
accountProductRelation
);
}
}
src/main/java/com/zfxftech/telmarket/task/followAccount/SmartStockPriceTask.java
0 → 100644
View file @
e8f77a13
package
com
.
zfxftech
.
telmarket
.
task
.
followAccount
;
import
com.zfxftech.telmarket.common.config.CommonConfig
;
import
com.zfxftech.telmarket.common.pojo.dao.AccountProductRelation
;
import
com.zfxftech.telmarket.common.pojo.dao.MemberBase
;
import
com.zfxftech.telmarket.common.pojo.dao.StockPosition
;
import
com.zfxftech.telmarket.common.pojo.dao.smart.SmartAccountProductRelation
;
import
com.zfxftech.telmarket.common.pojo.dao.smart.SmartStockPosition
;
import
com.zfxftech.telmarket.common.pojo.vo.MarketDetailsVO
;
import
com.zfxftech.telmarket.common.pojo.vo.smart.SmartMarketDetailsVO
;
import
com.zfxftech.telmarket.common.util.DateUtil
;
import
com.zfxftech.telmarket.common.util.OptionalUtil
;
import
com.zfxftech.telmarket.service.business.*
;
import
com.zfxftech.telmarket.service.business.smart.SmartAccountProductRelationService
;
import
com.zfxftech.telmarket.service.business.smart.SmartStockPositionService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.ApplicationArguments
;
import
org.springframework.boot.ApplicationRunner
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.ObjectUtils
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.atomic.AtomicReference
;
import
static
com
.
zfxftech
.
telmarket
.
common
.
constant
.
AdminConstant
.
MarketTypeEnum
.
REAL
;
import
static
com
.
zfxftech
.
telmarket
.
common
.
constant
.
AdminConstant
.
MarketTypeEnum
.
SIMULATED
;
/**
* Create time: 2022/1/26
*/
@Slf4j
@Component
@Order
(
value
=
1
)
/**
* 智能跟投计算总市值、股票市值、持仓数量
*/
public
class
SmartStockPriceTask
implements
ApplicationRunner
{
@Autowired
private
SmartAccountProductRelationService
accountProductRelationService
;
@Autowired
private
SmartStockPositionService
stockPositionService
;
@Autowired
private
StockCodeService
stockCodeService
;
@Autowired
private
CommonConfig
commonConfig
;
@Autowired
private
UsMemberBaseService
memberBaseService
;
@Override
public
void
run
(
ApplicationArguments
args
)
throws
Exception
{
log
.
info
(
"私人定制计算股票统计日志开始"
);
//log.info("私人定制计算股票统计日志开始配置更新开关状态:" + commonConfig.getStockPriceTask());
//if (commonConfig.getStockPriceTask() != null && commonConfig.getStockPriceTask().equals("run")) {
if
(
true
)
{
//分页查询异动配置列表
ExecutorService
PersonalexecutorService
=
Executors
.
newSingleThreadExecutor
();
ExecutorService
executorServicePersonal
=
Executors
.
newFixedThreadPool
(
100
);
CompletableFuture
.
runAsync
(()
->
{
while
(
true
)
{
// if (DateUtil.isTradeDayForChangeRemind()) {
if
(
true
)
{
AtomicReference
<
Integer
>
pageNo
=
new
AtomicReference
<>(
1
);
Integer
pageSize
=
100
;
Date
startTime
=
new
Date
();
List
<
CompletableFuture
<
String
>>
futureList
=
new
ArrayList
<>();
List
<
SmartAccountProductRelation
>
accountProductRelations
=
accountProductRelationService
.
queryAll
();
if
(!
ObjectUtils
.
isEmpty
(
accountProductRelations
)
&&
accountProductRelations
.
size
()
>
0
)
{
log
.
info
(
"私人定制计算股票统计数据大小:{}"
,
accountProductRelations
.
size
());
Integer
pageTOtl
=
accountProductRelations
.
size
()
%
pageSize
==
0
?
accountProductRelations
.
size
()
/
pageSize
:
accountProductRelations
.
size
()
/
pageSize
+
1
;
for
(
Integer
i
=
0
;
i
<
pageTOtl
;
i
++)
{
List
<
SmartAccountProductRelation
>
accountProductRelationList
=
this
.
page
(
accountProductRelations
,
pageNo
.
get
(),
pageSize
);
CompletableFuture
cf
=
CompletableFuture
.
supplyAsync
(()
->
{
for
(
SmartAccountProductRelation
accountProductRelation
:
accountProductRelationList
)
{
this
.
AccountProductRelationTask
(
accountProductRelation
);
}
return
" "
;
},
executorServicePersonal
).
handle
((
result
,
ex
)
->
{
if
(
null
!=
ex
)
{
log
.
error
(
"资管错误消息:{}"
,
ex
);
return
0
;
}
else
{
return
result
;
}
});
futureList
.
add
(
cf
);
pageNo
.
set
(
pageNo
.
get
()
+
1
);
}
}
try
{
CompletableFuture
<
Void
>
combinedFuture
=
CompletableFuture
.
allOf
(
futureList
.
toArray
(
new
CompletableFuture
[
0
]));
combinedFuture
.
get
();
log
.
info
(
"持仓统计--------主线程开始阻塞,消息发送完成--------"
);
log
.
info
(
"持仓统计,本次共计算"
+
(
ObjectUtils
.
isEmpty
(
accountProductRelations
)
==
true
?
0
:
accountProductRelations
.
size
())
+
"持仓统计。耗时"
+
DateUtil
.
calculateTimeGapSecond
(
startTime
,
new
Date
())
+
"秒"
);
}
catch
(
Exception
e
)
{
log
.
error
(
"持仓统计错误信息:{}"
,
e
);
e
.
printStackTrace
();
}
try
{
Thread
.
sleep
(
20000
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
else
{
try
{
Thread
.
sleep
(
8000
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
},
PersonalexecutorService
);
}
}
public
List
<
SmartAccountProductRelation
>
page
(
List
<
SmartAccountProductRelation
>
list
,
Integer
pageNo
,
Integer
pageSize
)
{
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
list
;
}
List
<
SmartAccountProductRelation
>
resultList
=
new
ArrayList
();
// 所有dataList数据中的第几条
int
currIdx
=
pageNo
>
1
?
(
pageNo
-
1
)
*
pageSize
:
0
;
for
(
int
i
=
0
;
i
<
pageSize
&&
i
<
list
.
size
()
-
currIdx
;
i
++)
{
resultList
.
add
(
list
.
get
(
currIdx
+
i
));
}
return
resultList
;
}
//私人定制
public
void
AccountProductRelationTask
(
SmartAccountProductRelation
accountProductRelation
)
{
String
type
=
SIMULATED
.
getCode
();
OptionalUtil
.
checkNull
(
accountProductRelation
,
"当前用户产品关系不存在"
);
//查询客户信息
Long
customerId
=
accountProductRelation
.
getCustomerId
();
MemberBase
memberBase
=
memberBaseService
.
queryUsMemberBaseById
(
customerId
);
Long
marketId
=
accountProductRelation
.
getSimulatedMarketId
();
OptionalUtil
.
checkNull
(
memberBase
,
"查询用户数据不存在"
);
//查询持仓信息
BigDecimal
funding
=
null
;
//获取可用资金
if
(
REAL
.
getCode
().
equals
(
type
))
{
funding
=
accountProductRelation
.
getRealFunding
();
}
if
(
SIMULATED
.
getCode
().
equals
(
type
))
{
funding
=
accountProductRelation
.
getSimulatedFunding
();
}
//获取所有买入过的股票
List
<
SmartStockPosition
>
stockPositions
=
stockPositionService
.
queryStockPositions
(
marketId
);
//汇总数据
SmartMarketDetailsVO
marketDetailsVO
=
stockPositionService
.
createMarketDetailsVO
(
memberBase
,
stockPositions
,
funding
,
accountProductRelation
,
marketId
);
//示范盈亏比例
accountProductRelation
.
setSimulatedTotalProfit
(
new
BigDecimal
(
marketDetailsVO
.
getTotalProfitRate
()));
//示范盘总资产
accountProductRelation
.
setSimulatedTotalPrice
(
new
BigDecimal
(
marketDetailsVO
.
getTotalPrice
()));
//示范持仓比
accountProductRelation
.
setSimulatedProportion
(
new
BigDecimal
(
marketDetailsVO
.
getPosition
()));
//示范盘持仓数量
accountProductRelation
.
setPositionCount
(
ObjectUtils
.
isEmpty
(
stockPositions
.
size
())
?
0
:
stockPositions
.
size
());
//示范盘盈亏金额
accountProductRelation
.
setProfitAmount
(
new
BigDecimal
(
marketDetailsVO
.
getTotalProfit
()));
accountProductRelationService
.
updateAccountProductRelation
(
accountProductRelation
);
}
}
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