Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
yangxiujun
/
paidan_demo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit eece8e37
authored
Jun 15, 2023
by
丁伟峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改了返回的字段要素,并改用了strem方式简化逻辑
1 parent
09dbc25a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
39 deletions
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/CapacityStatQueryRespDTO.java
project-order/src/main/java/com/alibaba/cloud/integration/order/service/impl/CapacityQueryServiceImpl.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/CapacityStatQueryRespDTO.java
View file @
eece8e3
...
@@ -24,9 +24,10 @@ public class CapacityStatQueryRespDTO {
...
@@ -24,9 +24,10 @@ public class CapacityStatQueryRespDTO {
private
Date
updateTime
;
private
Date
updateTime
;
private
String
date
;
private
String
date
;
private
long
engineerNum
;
private
long
engineerNum
;
private
String
groupName
;
private
String
levelType
;
private
String
levelValue
;
private
String
layer
;
private
String
layer
;
private
String
team
Name
;
private
String
show
Name
;
}
}
}
}
...
...
project-order/src/main/java/com/alibaba/cloud/integration/order/service/impl/CapacityQueryServiceImpl.java
View file @
eece8e3
...
@@ -21,6 +21,7 @@ import java.time.LocalDate;
...
@@ -21,6 +21,7 @@ import java.time.LocalDate;
import
java.time.format.DateTimeFormatter
;
import
java.time.format.DateTimeFormatter
;
import
java.time.format.TextStyle
;
import
java.time.format.TextStyle
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Service
@Service
@Slf4j
@Slf4j
...
@@ -78,21 +79,32 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
...
@@ -78,21 +79,32 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
// 根据大区/分部/分站查询,分别返回分部/分站/工作队的容量
// 根据大区/分部/分站查询,分别返回分部/分站/工作队的容量
Page
<?>
stats
=
null
;
Page
<?>
stats
=
null
;
Pageable
pageable
=
PageRequest
.
of
(
reqDTO
.
getPage
()
-
1
,
reqDTO
.
getSize
());
Pageable
pageable
=
PageRequest
.
of
(
reqDTO
.
getPage
()
-
1
,
reqDTO
.
getSize
());
if
(
"cluster"
.
equals
(
reqDTO
.
getLevelType
()))
{
Map
<
String
,
String
>
names
=
null
;
List
<
String
>
branchIds
=
getBranchIdsByClusterId
(
reqDTO
.
getLevelValue
());
String
levelType
=
reqDTO
.
getLevelType
();
log
.
info
(
"levelType: {} ==> branchIds: {}"
,
reqDTO
.
getLevelType
(),
branchIds
);
String
levelValue
=
reqDTO
.
getLevelValue
();
if
(
"cluster"
.
equals
(
levelType
))
{
names
=
orgBranchDao
.
findAllByClusterId
(
levelValue
).
stream
()
.
collect
(
Collectors
.
toMap
(
OrgBranchEntity:
:
getBranchId
,
OrgBranchEntity:
:
getBranchName
));
;
List
<
String
>
branchIds
=
new
ArrayList
<>(
names
.
keySet
());
log
.
info
(
"levelType: {} ==> branchIds: {}"
,
levelType
,
branchIds
);
stats
=
capacityOrgStatDao
.
findByBranchIdsAndWorkdayBetween
(
branchIds
,
reqDTO
.
getStartDate
(),
reqDTO
.
getEndDate
(),
pageable
);
stats
=
capacityOrgStatDao
.
findByBranchIdsAndWorkdayBetween
(
branchIds
,
reqDTO
.
getStartDate
(),
reqDTO
.
getEndDate
(),
pageable
);
}
else
if
(
"branch"
.
equals
(
reqDTO
.
getLevelType
()))
{
}
else
if
(
"branch"
.
equals
(
reqDTO
.
getLevelType
()))
{
List
<
String
>
groupIds
=
getGroupIdsByBranchId
(
reqDTO
.
getLevelValue
());
names
=
orgGroupDao
.
findAllByBranchId
(
levelValue
).
stream
()
log
.
info
(
"levelType: {} ==> groupIds: {}"
,
reqDTO
.
getLevelType
(),
groupIds
);
.
collect
(
Collectors
.
toMap
(
OrgGroupEntity:
:
getGroupId
,
OrgGroupEntity:
:
getGroupName
));
List
<
String
>
groupIds
=
new
ArrayList
<>(
names
.
keySet
());
log
.
info
(
"levelType: {} ==> groupIds: {}"
,
levelType
,
groupIds
);
stats
=
capacityOrgStatDao
.
findByGroupIdsAndWorkdayBetween
(
groupIds
,
reqDTO
.
getStartDate
(),
reqDTO
.
getEndDate
(),
pageable
);
stats
=
capacityOrgStatDao
.
findByGroupIdsAndWorkdayBetween
(
groupIds
,
reqDTO
.
getStartDate
(),
reqDTO
.
getEndDate
(),
pageable
);
}
else
{
}
else
{
List
<
String
>
teamIds
=
getTeamIdsByGroupId
(
reqDTO
.
getLevelValue
());
names
=
orgTeamDao
.
findAllByGroupId
(
levelValue
).
stream
()
log
.
info
(
"levelType: {} ==> teamIds: {}"
,
reqDTO
.
getLevelType
(),
teamIds
);
.
collect
(
Collectors
.
toMap
(
OrgTeamEntity:
:
getTeamId
,
OrgTeamEntity:
:
getTeamName
));
List
<
String
>
teamIds
=
new
ArrayList
<>(
names
.
keySet
());
log
.
info
(
"levelType: {} ==> teamIds: {}"
,
levelType
,
teamIds
);
stats
=
capacityTeamStatDao
.
findByTeamIdsAndWorkdayBetween
(
teamIds
,
reqDTO
.
getStartDate
(),
reqDTO
.
getEndDate
(),
pageable
);
stats
=
capacityTeamStatDao
.
findByTeamIdsAndWorkdayBetween
(
teamIds
,
reqDTO
.
getStartDate
(),
reqDTO
.
getEndDate
(),
pageable
);
}
}
CapacityStatQueryRespDTO
data
=
new
CapacityStatQueryRespDTO
();
CapacityStatQueryRespDTO
data
=
new
CapacityStatQueryRespDTO
();
data
.
setLevelType
(
reqDTO
.
getLevelType
()
);
data
.
setLevelType
(
levelType
);
data
.
setTotal
(
stats
.
getTotalElements
()).
setPages
(
stats
.
getTotalPages
()).
setPageSize
(
pageable
.
getPageSize
()).
setPageCurrent
(
stats
.
getNumber
());
data
.
setTotal
(
stats
.
getTotalElements
()).
setPages
(
stats
.
getTotalPages
()).
setPageSize
(
pageable
.
getPageSize
()).
setPageCurrent
(
stats
.
getNumber
());
List
<
CapacityStatQueryRespDTO
.
Content
>
contents
=
new
ArrayList
<>();
List
<
CapacityStatQueryRespDTO
.
Content
>
contents
=
new
ArrayList
<>();
...
@@ -101,10 +113,8 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
...
@@ -101,10 +113,8 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
if
(
item
instanceof
CapacityOrgStatEntity
)
{
if
(
item
instanceof
CapacityOrgStatEntity
)
{
// cluster/branch查询,都是capacity_org_stat
// cluster/branch查询,都是capacity_org_stat
CapacityOrgStatEntity
e
=
(
CapacityOrgStatEntity
)
item
;
CapacityOrgStatEntity
e
=
(
CapacityOrgStatEntity
)
item
;
if
(
"group"
.
equals
(
e
.
getType
()))
{
content
.
setLevelType
(
e
.
getType
()).
setLevelValue
(
e
.
getOrgId
());
OrgGroupEntity
g
=
orgGroupDao
.
getByGroupId
(
e
.
getOrgId
());
content
.
setShowName
(
names
.
get
(
e
.
getOrgId
()));
content
.
setGroupName
(
g
.
getGroupName
());
}
content
.
setDate
(
e
.
getWorkday
()).
setLayer
(
e
.
getLayer
())
content
.
setDate
(
e
.
getWorkday
()).
setLayer
(
e
.
getLayer
())
.
setCapTotal
(
e
.
getCapTotal
()).
setCapUsed
(
e
.
getCapUsedTotal
())
.
setCapTotal
(
e
.
getCapTotal
()).
setCapUsed
(
e
.
getCapUsedTotal
())
.
setEngineerNum
(
e
.
getEngineerCount
()).
setUpdateTime
(
e
.
getUpdateTime
());
.
setEngineerNum
(
e
.
getEngineerCount
()).
setUpdateTime
(
e
.
getUpdateTime
());
...
@@ -112,7 +122,9 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
...
@@ -112,7 +122,9 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
// group查询,是capacity_team_stat
// group查询,是capacity_team_stat
CapacityTeamStatEntity
e
=
(
CapacityTeamStatEntity
)
item
;
CapacityTeamStatEntity
e
=
(
CapacityTeamStatEntity
)
item
;
// capacity_team_stat表中的team_id,直接就是字符串
// capacity_team_stat表中的team_id,直接就是字符串
content
.
setDate
(
e
.
getWorkday
()).
setLayer
(
e
.
getLayer
()).
setTeamName
(
e
.
getTeamId
())
content
.
setLevelType
(
"team"
).
setLevelValue
(
e
.
getTeamId
());
content
.
setShowName
(
names
.
get
(
e
.
getTeamId
()));
content
.
setDate
(
e
.
getWorkday
()).
setLayer
(
e
.
getLayer
()).
setShowName
(
e
.
getTeamId
())
.
setCapTotal
(
e
.
getCapTotal
()).
setCapUsed
(
e
.
getCapUsed
()).
setCapAdjust
(
e
.
getCapAdjust
())
.
setCapTotal
(
e
.
getCapTotal
()).
setCapUsed
(
e
.
getCapUsed
()).
setCapAdjust
(
e
.
getCapAdjust
())
.
setEngineerNum
(
e
.
getEngineerCount
()).
setUpdateTime
(
e
.
getUpdateTime
());
.
setEngineerNum
(
e
.
getEngineerCount
()).
setUpdateTime
(
e
.
getUpdateTime
());
}
}
...
@@ -123,30 +135,6 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
...
@@ -123,30 +135,6 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
return
Result
.
success
(
data
);
return
Result
.
success
(
data
);
}
}
private
List
<
String
>
getTeamIdsByGroupId
(
String
groupId
)
{
List
<
String
>
teamIds
=
new
ArrayList
<>();
for
(
OrgTeamEntity
e
:
orgTeamDao
.
findAllByGroupId
(
groupId
))
{
teamIds
.
add
(
e
.
getTeamId
());
}
return
teamIds
;
}
private
List
<
String
>
getBranchIdsByClusterId
(
String
clusterId
)
{
List
<
String
>
branchIds
=
new
ArrayList
<>();
for
(
OrgBranchEntity
e
:
orgBranchDao
.
findAllByClusterId
(
clusterId
))
{
branchIds
.
add
(
e
.
getBranchId
());
}
return
branchIds
;
}
private
List
<
String
>
getGroupIdsByBranchId
(
String
branchId
)
{
List
<
String
>
groupIds
=
new
ArrayList
<>();
for
(
OrgGroupEntity
e
:
orgGroupDao
.
findAllByBranchId
(
branchId
))
{
groupIds
.
add
(
e
.
getGroupId
());
}
return
groupIds
;
}
private
int
getSpanType
(
int
capLeft
,
int
capTotal
)
{
private
int
getSpanType
(
int
capLeft
,
int
capTotal
)
{
float
ratio
=
(
float
)
capLeft
/
capTotal
;
float
ratio
=
(
float
)
capLeft
/
capTotal
;
if
(
ratio
<
0.3
)
{
if
(
ratio
<
0.3
)
{
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment