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 9a762940
authored
Jul 11, 2023
by
丁伟峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
将原先的创建订单查询容量,与各个机构/工作队的容量统计展示,剥离到不同的模块
1 parent
5897512c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
114 additions
and
93 deletions
project-order/src/main/java/com/dituhui/pea/order/controller/CapacityController.java
project-order/src/main/java/com/dituhui/pea/order/service/CapacityQueryService.java
project-order/src/main/java/com/dituhui/pea/order/service/OrgCapacityService.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/CapacityQueryServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrgCapacityServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/controller/CapacityController.java
View file @
9a76294
...
@@ -3,7 +3,7 @@ package com.dituhui.pea.order.controller;
...
@@ -3,7 +3,7 @@ package com.dituhui.pea.order.controller;
import
com.dituhui.pea.common.BusinessException
;
import
com.dituhui.pea.common.BusinessException
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.dto.CapacityStatQueryDTO
;
import
com.dituhui.pea.order.dto.CapacityStatQueryDTO
;
import
com.dituhui.pea.order.service.
CapacityQuer
yService
;
import
com.dituhui.pea.order.service.
OrgCapacit
yService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
@@ -13,13 +13,13 @@ import org.springframework.web.bind.annotation.*;
...
@@ -13,13 +13,13 @@ import org.springframework.web.bind.annotation.*;
public
class
CapacityController
{
public
class
CapacityController
{
@Autowired
@Autowired
private
CapacityQueryService
capacityQuer
yService
;
private
OrgCapacityService
orgCapacit
yService
;
@GetMapping
(
"/capacity/query"
)
@GetMapping
(
"/capacity/query"
)
public
Result
<?>
capacityQuery
(
@Validated
CapacityStatQueryDTO
.
Request
reqDTO
)
{
public
Result
<?>
capacityQuery
(
@Validated
CapacityStatQueryDTO
.
Request
reqDTO
)
{
Result
<?>
res
=
null
;
Result
<?>
res
=
null
;
try
{
try
{
res
=
capacityQueryService
.
getTeamStat
Data
(
reqDTO
);
res
=
orgCapacityService
.
getOrgCapacity
Data
(
reqDTO
);
}
catch
(
BusinessException
e
)
{
}
catch
(
BusinessException
e
)
{
return
Result
.
failed
(
e
.
getMessage
());
return
Result
.
failed
(
e
.
getMessage
());
}
}
...
...
project-order/src/main/java/com/dituhui/pea/order/service/CapacityQueryService.java
View file @
9a76294
...
@@ -6,14 +6,5 @@ import com.dituhui.pea.order.dto.CapacityStatQueryDTO;
...
@@ -6,14 +6,5 @@ import com.dituhui.pea.order.dto.CapacityStatQueryDTO;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
public
interface
CapacityQueryService
{
public
interface
CapacityQueryService
{
/**
* 单条容量查询
* @param capacityQueryReqDTO
* @return
* @throws JsonProcessingException
*/
Result
<?>
getOneCapacityData
(
CapacityOrderQueryDTO
.
Request
capacityQueryReqDTO
);
Result
<?>
getOneCapacityData
(
CapacityOrderQueryDTO
.
Request
capacityQueryReqDTO
);
Result
<?>
getTeamStatData
(
CapacityStatQueryDTO
.
Request
capacityStatQueryReqDTO
);
}
}
project-order/src/main/java/com/dituhui/pea/order/service/OrgCapacityService.java
0 → 100644
View file @
9a76294
package
com
.
dituhui
.
pea
.
order
.
service
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.dto.CapacityStatQueryDTO
;
public
interface
OrgCapacityService
{
Result
<?>
getOrgCapacityData
(
CapacityStatQueryDTO
.
Request
capacityStatQueryReqDTO
);
}
project-order/src/main/java/com/dituhui/pea/order/service/impl/CapacityQueryServiceImpl.java
View file @
9a76294
...
@@ -2,6 +2,7 @@ package com.dituhui.pea.order.service.impl;
...
@@ -2,6 +2,7 @@ package com.dituhui.pea.order.service.impl;
import
cn.hutool.core.date.LocalDateTimeUtil
;
import
cn.hutool.core.date.LocalDateTimeUtil
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.common.DateUtil
;
import
com.dituhui.pea.order.dao.*
;
import
com.dituhui.pea.order.dao.*
;
import
com.dituhui.pea.order.dto.CapacityOrderQueryDTO
;
import
com.dituhui.pea.order.dto.CapacityOrderQueryDTO
;
import
com.dituhui.pea.order.dto.CapacityStatQueryDTO
;
import
com.dituhui.pea.order.dto.CapacityStatQueryDTO
;
...
@@ -33,24 +34,11 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
...
@@ -33,24 +34,11 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
private
CapacityTeamStatDao
capacityTeamStatDao
;
private
CapacityTeamStatDao
capacityTeamStatDao
;
@Autowired
@Autowired
private
CapacityOrgStatDao
capacityOrgStatDao
;
@Autowired
private
ProductCategoryDao
productCategoryDao
;
private
ProductCategoryDao
productCategoryDao
;
@Autowired
private
OrgGroupDao
orgGroupDao
;
@Autowired
private
OrgTeamDao
orgTeamDao
;
@Autowired
@Autowired
private
CommonService
commonService
;
private
CommonService
commonService
;
@Autowired
private
OrgBranchDao
orgBranchDao
;
@Override
@Override
public
Result
<?>
getOneCapacityData
(
CapacityOrderQueryDTO
.
Request
reqDTO
)
{
public
Result
<?>
getOneCapacityData
(
CapacityOrderQueryDTO
.
Request
reqDTO
)
{
// 单条容量查询
// 单条容量查询
...
@@ -74,68 +62,6 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
...
@@ -74,68 +62,6 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
return
legends
;
return
legends
;
}
}
@Override
public
Result
<?>
getTeamStatData
(
CapacityStatQueryDTO
.
Request
reqDTO
)
{
// 根据大区/分部/分站查询,分别返回分部/分站/工作队的容量
Page
<?>
stats
=
null
;
Pageable
pageable
=
PageRequest
.
of
(
reqDTO
.
getPage
()
-
1
,
reqDTO
.
getSize
());
Map
<
String
,
String
>
names
=
null
;
String
levelType
=
reqDTO
.
getLevelType
();
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
);
}
else
if
(
"branch"
.
equals
(
reqDTO
.
getLevelType
()))
{
names
=
orgGroupDao
.
findAllByBranchId
(
levelValue
).
stream
()
.
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
);
}
else
{
names
=
orgTeamDao
.
findAllByGroupId
(
levelValue
).
stream
()
.
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
);
}
CapacityStatQueryDTO
.
Result
rs
=
new
CapacityStatQueryDTO
.
Result
();
rs
.
setLevelType
(
levelType
);
rs
.
setTotal
(
stats
.
getTotalElements
()).
setPages
(
stats
.
getTotalPages
()).
setPageSize
(
pageable
.
getPageSize
()).
setPageCurrent
(
stats
.
getNumber
());
List
<
CapacityStatQueryDTO
.
Content
>
contents
=
new
ArrayList
<>();
for
(
Object
item
:
stats
.
getContent
())
{
CapacityStatQueryDTO
.
Content
content
=
new
CapacityStatQueryDTO
.
Content
();
if
(
item
instanceof
CapacityOrgStatEntity
)
{
// cluster/branch查询,都是capacity_org_stat
CapacityOrgStatEntity
e
=
(
CapacityOrgStatEntity
)
item
;
content
.
setLevelType
(
e
.
getType
()).
setLevelValue
(
e
.
getOrgId
());
content
.
setShowName
(
names
.
get
(
e
.
getOrgId
()));
content
.
setDate
(
e
.
getWorkday
()).
setLayer
(
e
.
getLayer
())
.
setCapTotal
(
e
.
getCapTotal
()).
setCapUsed
(
e
.
getCapUsedTotal
())
.
setEngineerNum
(
e
.
getEngineerCount
()).
setUpdateTime
(
e
.
getUpdateTime
());
}
else
{
// group查询,是capacity_team_stat
CapacityTeamStatEntity
e
=
(
CapacityTeamStatEntity
)
item
;
// capacity_team_stat表中的team_id,直接就是字符串
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
())
.
setEngineerNum
(
e
.
getEngineerCount
()).
setUpdateTime
(
e
.
getUpdateTime
());
}
contents
.
add
(
content
);
}
contents
.
stream
().
sorted
(
Comparator
.
comparing
(
CapacityStatQueryDTO
.
Content
::
getDate
)).
collect
(
Collectors
.
toList
());
rs
.
setContent
(
contents
);
return
Result
.
success
(
rs
);
}
private
int
getSpanType
(
int
capLeft
,
int
capTotal
)
{
private
int
getSpanType
(
int
capLeft
,
int
capTotal
)
{
float
ratio
=
(
float
)
capLeft
/
capTotal
;
float
ratio
=
(
float
)
capLeft
/
capTotal
;
...
@@ -191,7 +117,7 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
...
@@ -191,7 +117,7 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
calendarDTO
=
dayMaps
.
get
(
e
.
getWorkday
());
calendarDTO
=
dayMaps
.
get
(
e
.
getWorkday
());
}
else
{
}
else
{
calendarDTO
=
new
CapacityOrderQueryDTO
.
CalendarDTO
();
calendarDTO
=
new
CapacityOrderQueryDTO
.
CalendarDTO
();
calendarDTO
.
setDate
(
e
.
getWorkday
()).
setWeek
(
getWeekday
(
e
.
getWorkday
()));
calendarDTO
.
setDate
(
e
.
getWorkday
()).
setWeek
(
DateUtil
.
toWeekChinese
(
e
.
getWorkday
()));
calendarDTO
.
setTimes
(
new
ArrayList
<>());
calendarDTO
.
setTimes
(
new
ArrayList
<>());
}
}
calendarDTO
.
getTimes
().
add
(
timeDTO
);
calendarDTO
.
getTimes
().
add
(
timeDTO
);
...
@@ -201,9 +127,5 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
...
@@ -201,9 +127,5 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
.
sorted
(
Comparator
.
comparing
(
CapacityOrderQueryDTO
.
CalendarDTO
::
getDate
)).
collect
(
Collectors
.
toList
());
.
sorted
(
Comparator
.
comparing
(
CapacityOrderQueryDTO
.
CalendarDTO
::
getDate
)).
collect
(
Collectors
.
toList
());
}
}
private
String
getWeekday
(
String
day
)
{
LocalDate
date
=
LocalDateTimeUtil
.
parseDate
(
day
,
PATTERN_DATE
);
DayOfWeek
weekday
=
date
.
getDayOfWeek
();
return
weekday
.
getDisplayName
(
TextStyle
.
SHORT
,
Locale
.
CHINA
);
}
}
}
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrgCapacityServiceImpl.java
0 → 100644
View file @
9a76294
package
com
.
dituhui
.
pea
.
order
.
service
.
impl
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.dao.*
;
import
com.dituhui.pea.order.dto.CapacityStatQueryDTO
;
import
com.dituhui.pea.order.entity.*
;
import
com.dituhui.pea.order.service.OrgCapacityService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
@Service
@Slf4j
public
class
OrgCapacityServiceImpl
implements
OrgCapacityService
{
@Autowired
private
OrgGroupDao
orgGroupDao
;
@Autowired
private
OrgTeamDao
orgTeamDao
;
@Autowired
private
CapacityOrgStatDao
capacityOrgStatDao
;
@Autowired
private
OrgBranchDao
orgBranchDao
;
@Autowired
private
CapacityTeamStatDao
capacityTeamStatDao
;
@Override
public
Result
<?>
getOrgCapacityData
(
CapacityStatQueryDTO
.
Request
reqDTO
)
{
// 根据大区/分部/分站查询,分别返回分部/分站/工作队的容量
Page
<?>
stats
=
null
;
Pageable
pageable
=
PageRequest
.
of
(
reqDTO
.
getPage
()
-
1
,
reqDTO
.
getSize
());
Map
<
String
,
String
>
names
=
null
;
String
levelType
=
reqDTO
.
getLevelType
();
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
);
}
else
if
(
"branch"
.
equals
(
reqDTO
.
getLevelType
()))
{
names
=
orgGroupDao
.
findAllByBranchId
(
levelValue
).
stream
()
.
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
);
}
else
{
names
=
orgTeamDao
.
findAllByGroupId
(
levelValue
).
stream
()
.
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
);
}
CapacityStatQueryDTO
.
Result
rs
=
new
CapacityStatQueryDTO
.
Result
();
rs
.
setLevelType
(
levelType
);
rs
.
setTotal
(
stats
.
getTotalElements
()).
setPages
(
stats
.
getTotalPages
()).
setPageSize
(
pageable
.
getPageSize
()).
setPageCurrent
(
stats
.
getNumber
());
List
<
CapacityStatQueryDTO
.
Content
>
contents
=
new
ArrayList
<>();
for
(
Object
item
:
stats
.
getContent
())
{
CapacityStatQueryDTO
.
Content
content
=
new
CapacityStatQueryDTO
.
Content
();
if
(
item
instanceof
CapacityOrgStatEntity
)
{
// cluster/branch查询,都是capacity_org_stat
CapacityOrgStatEntity
e
=
(
CapacityOrgStatEntity
)
item
;
content
.
setLevelType
(
e
.
getType
()).
setLevelValue
(
e
.
getOrgId
());
content
.
setShowName
(
names
.
get
(
e
.
getOrgId
()));
content
.
setDate
(
e
.
getWorkday
()).
setLayer
(
e
.
getLayer
())
.
setCapTotal
(
e
.
getCapTotal
()).
setCapUsed
(
e
.
getCapUsedTotal
())
.
setEngineerNum
(
e
.
getEngineerCount
()).
setUpdateTime
(
e
.
getUpdateTime
());
}
else
{
// group查询,是capacity_team_stat
CapacityTeamStatEntity
e
=
(
CapacityTeamStatEntity
)
item
;
// capacity_team_stat表中的team_id,直接就是字符串
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
())
.
setEngineerNum
(
e
.
getEngineerCount
()).
setUpdateTime
(
e
.
getUpdateTime
());
}
contents
.
add
(
content
);
}
contents
.
stream
().
sorted
(
Comparator
.
comparing
(
CapacityStatQueryDTO
.
Content
::
getDate
)).
collect
(
Collectors
.
toList
());
rs
.
setContent
(
contents
);
return
Result
.
success
(
rs
);
}
}
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