Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
D
data-server
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
licc
data-server
Commits
7c421d96
Commit
7c421d96
authored
Mar 02, 2021
by
licc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码优化4
parent
1ee88893
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
3 deletions
+57
-3
AccountManager.java
...ain/java/cn/wisenergy/service/Manager/AccountManager.java
+56
-3
AccountServiceImpl.java
...ava/cn/wisenergy/service/app/impl/AccountServiceImpl.java
+1
-0
No files found.
wisenergy-service/src/main/java/cn/wisenergy/service/Manager/AccountManager.java
View file @
7c421d96
...
@@ -7,15 +7,18 @@ import cn.wisenergy.model.enums.RebateStatusEnum;
...
@@ -7,15 +7,18 @@ import cn.wisenergy.model.enums.RebateStatusEnum;
import
cn.wisenergy.model.enums.TradeRecordEnum
;
import
cn.wisenergy.model.enums.TradeRecordEnum
;
import
cn.wisenergy.model.vo.TeamPerformanceSortVo
;
import
cn.wisenergy.model.vo.TeamPerformanceSortVo
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.map.HashedMap
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.
text.SimpleDateForma
t
;
import
java.
util.ArrayLis
t
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
/**
* @author 86187
* @author 86187
...
@@ -91,11 +94,17 @@ public class AccountManager {
...
@@ -91,11 +94,17 @@ public class AccountManager {
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateOrSavePrize
(
List
<
TeamPerformanceSortVo
>
listVo
,
List
<
AccountInfo
>
accountInfo
s
,
List
<
ProgressPrize
>
prizes
)
{
public
void
updateOrSavePrize
(
List
<
TeamPerformanceSortVo
>
listVo
,
List
<
AccountInfo
>
accountInfo
List
,
List
<
ProgressPrize
>
prizes
)
{
Date
date
=
new
Date
();
Date
date
=
new
Date
();
String
yearMonth
=
DateUtil
.
convertDateToStr
(
date
,
PATTERN
);
String
yearMonth
=
DateUtil
.
convertDateToStr
(
date
,
PATTERN
);
//判断 prizes 是否为空集合,是新增
//构造一个map key:userId value progressPrize
Map
<
String
,
ProgressPrize
>
map
=
new
HashedMap
(
32
);
for
(
ProgressPrize
progressPrize
:
prizes
)
{
map
.
put
(
progressPrize
.
getUserId
(),
progressPrize
);
}
//1、判断 prizes 是否为空集合,是新增
//新增
//新增
if
(
CollectionUtils
.
isEmpty
(
prizes
))
{
if
(
CollectionUtils
.
isEmpty
(
prizes
))
{
for
(
TeamPerformanceSortVo
sortVo
:
listVo
)
{
for
(
TeamPerformanceSortVo
sortVo
:
listVo
)
{
...
@@ -108,7 +117,51 @@ public class AccountManager {
...
@@ -108,7 +117,51 @@ public class AccountManager {
progressPrizeMapper
.
add
(
progressPrize
);
progressPrizeMapper
.
add
(
progressPrize
);
}
}
}
else
{
}
else
{
//2、不为空。存在的修改,不存在的新增,多余的,删除
List
<
ProgressPrize
>
updateList
=
new
ArrayList
<>();
List
<
ProgressPrize
>
addList
=
new
ArrayList
<>();
List
<
ProgressPrize
>
deleteList
=
new
ArrayList
<>();
List
<
String
>
userIds
=
prizes
.
stream
().
map
(
ProgressPrize:
:
getUserId
).
collect
(
Collectors
.
toList
());
//遍历 筛选出要修改、新增、删除 对象
for
(
TeamPerformanceSortVo
sortVo
:
listVo
)
{
if
(
userIds
.
contains
(
sortVo
.
getUserId
()))
{
//修改
ProgressPrize
prize
=
map
.
get
(
sortVo
.
getUserId
());
prize
.
setGrowthRate
(
sortVo
.
getGrowthRate
());
prize
.
setAwardMoney
(
sortVo
.
getMonthPerformance
());
updateList
.
add
(
prize
);
//移除要修改的
prizes
.
remove
(
prize
);
}
else
{
//新增
String
userId
=
sortVo
.
getTeamPerformance
().
getUserId
();
ProgressPrize
progress
=
new
ProgressPrize
();
progress
.
setUserId
(
userId
);
progress
.
setGrowthRate
(
sortVo
.
getGrowthRate
());
progress
.
setAwardMoney
(
sortVo
.
getMonthPerformance
());
progress
.
setYearMonth
(
yearMonth
);
addList
.
add
(
progress
);
}
}
deleteList
.
addAll
(
prizes
);
for
(
ProgressPrize
updatePrize
:
updateList
)
{
progressPrizeMapper
.
edit
(
updatePrize
);
}
for
(
ProgressPrize
addPrize
:
addList
)
{
progressPrizeMapper
.
add
(
addPrize
);
}
for
(
ProgressPrize
deletePrize
:
deleteList
)
{
progressPrizeMapper
.
delById
(
deletePrize
.
getId
());
}
}
//3、添加账户获得的收益
for
(
AccountInfo
accountInfo
:
accountInfoList
)
{
accountMapper
.
edit
(
accountInfo
);
}
}
}
}
}
}
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/AccountServiceImpl.java
View file @
7c421d96
...
@@ -423,6 +423,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
...
@@ -423,6 +423,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
String
yearMonth
=
DateUtil
.
convertDateToStr
(
date
,
PATTERN
);
String
yearMonth
=
DateUtil
.
convertDateToStr
(
date
,
PATTERN
);
List
<
ProgressPrize
>
prizes
=
progressPrizeMapper
.
getByYearMonth
(
yearMonth
);
List
<
ProgressPrize
>
prizes
=
progressPrizeMapper
.
getByYearMonth
(
yearMonth
);
//修改或保存最大进步奖信息
accountManager
.
updateOrSavePrize
(
listVo
,
updateAccountList
,
prizes
);
accountManager
.
updateOrSavePrize
(
listVo
,
updateAccountList
,
prizes
);
}
}
}
}
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