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 d327c81e
authored
Jun 09, 2023
by
丁伟峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加了容量查询接口实现
1 parent
5d15fe0f
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
250 additions
and
25 deletions
project-order/src/main/java/com/alibaba/cloud/integration/order/controller/CapacityController.java
project-order/src/main/java/com/alibaba/cloud/integration/order/controller/OrderCreateController.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/CapacityOrgStatDao.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/CapacityTeamStatDao.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/OrderChangeDao.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/CapacityQueryReqDTO.java → project-order/src/main/java/com/alibaba/cloud/integration/order/dto/CapacityOrderQueryReqDTO.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/CapacityQueryRespDTO.java → project-order/src/main/java/com/alibaba/cloud/integration/order/dto/CapacityQueryOrderRespDTO.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/CapacityStatQueryReqDTO.java
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/CapacityStatQueryRespDTO.java
project-order/src/main/java/com/alibaba/cloud/integration/order/entity/CapacityOrgStatEntity.java
project-order/src/main/java/com/alibaba/cloud/integration/order/entity/CapacityTeamStatEntity.java
project-order/src/main/java/com/alibaba/cloud/integration/order/service/CapacityQueryService.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/controller/CapacityController.java
0 → 100644
View file @
d327c81
package
com
.
alibaba
.
cloud
.
integration
.
order
.
controller
;
import
com.alibaba.cloud.integration.common.BusinessException
;
import
com.alibaba.cloud.integration.common.Result
;
import
com.alibaba.cloud.integration.order.dto.CapacityStatQueryReqDTO
;
import
com.alibaba.cloud.integration.order.service.CapacityQueryService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
public
class
CapacityController
{
@Autowired
private
CapacityQueryService
capacityQueryService
;
@PostMapping
(
"/capacity/query"
)
public
Result
<?>
capacityQuery
(
@Validated
@RequestBody
CapacityStatQueryReqDTO
reqDTO
)
{
Result
<?>
res
=
null
;
try
{
res
=
capacityQueryService
.
getTeamStatData
(
reqDTO
);
}
catch
(
BusinessException
e
)
{
return
Result
.
failed
(
e
.
getMessage
());
}
return
res
;
}
}
project-order/src/main/java/com/alibaba/cloud/integration/order/controller/OrderCreateController.java
View file @
d327c81
...
...
@@ -19,7 +19,7 @@ package com.alibaba.cloud.integration.order.controller;
import
com.alibaba.cloud.integration.common.BusinessException
;
import
com.alibaba.cloud.integration.common.Result
;
import
com.alibaba.cloud.integration.order.dto.OrderCreateReqDTO
;
import
com.alibaba.cloud.integration.order.dto.CapacityQueryReqDTO
;
import
com.alibaba.cloud.integration.order.dto.Capacity
Order
QueryReqDTO
;
import
com.alibaba.cloud.integration.order.service.OrderService
;
import
com.alibaba.cloud.integration.order.service.CapacityQueryService
;
...
...
@@ -59,7 +59,7 @@ public class OrderCreateController {
}
@PostMapping
(
"/order/service/capacity/query"
)
public
Result
<?>
capacityQuery
(
@Validated
@RequestBody
CapacityQueryReqDTO
capacityQueryReqDTO
)
{
public
Result
<?>
capacityQuery
(
@Validated
@RequestBody
Capacity
Order
QueryReqDTO
capacityQueryReqDTO
)
{
Result
<?>
res
=
null
;
try
{
res
=
capacityQueryService
.
getOneCapacityData
(
capacityQueryReqDTO
);
...
...
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/CapacityOrgStatDao.java
0 → 100644
View file @
d327c81
package
com
.
alibaba
.
cloud
.
integration
.
order
.
dao
;
import
com.alibaba.cloud.integration.order.entity.CapacityOrgStatEntity
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
@Repository
public
interface
CapacityOrgStatDao
extends
JpaRepository
<
CapacityOrgStatEntity
,
Integer
>
{
@Query
(
"select c from CapacityOrgStatEntity c where c.type = 'group' and c.orgId = :groupId and c.workday between :beginDate and :endDate"
)
Page
<?>
findByGroupIdAndWorkdayBetween
(
String
groupId
,
String
beginDate
,
String
endDate
,
Pageable
page
);
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/CapacityTeamStatDao.java
View file @
d327c81
...
...
@@ -2,7 +2,10 @@ package com.alibaba.cloud.integration.order.dao;
import
com.alibaba.cloud.integration.order.entity.CapacityTeamStatEntity
;
import
org.hibernate.annotations.Where
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
...
...
@@ -11,4 +14,7 @@ import java.util.List;
public
interface
CapacityTeamStatDao
extends
JpaRepository
<
CapacityTeamStatEntity
,
Long
>
{
List
<
CapacityTeamStatEntity
>
findAllByTeamIdAndLayerAndWorkdayBetween
(
String
teamId
,
String
layer
,
String
beginDate
,
String
endDate
);
@Query
(
"select c from CapacityTeamStatEntity c where c.teamId = :teamId and c.workday between :beginDate and :endDate"
)
Page
<?>
findByTeamIdAndWorkdayBetween
(
String
teamId
,
String
beginDate
,
String
endDate
,
Pageable
pageable
);
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dao/OrderChangeDao.java
View file @
d327c81
...
...
@@ -13,12 +13,12 @@ import org.springframework.stereotype.Repository;
public
interface
OrderChangeDao
extends
JpaRepository
<
OrderChangeEntity
,
Integer
>
{
@Query
(
"select a from OrderChangeEntity a join OrderRequestEntity b on a.orderId=b.orderId where b.orgClusterId = :clusterId"
)
Page
<
OrderChangeEntity
>
findAllByClusterId
(
Pageable
pageable
,
String
clusterId
);
Page
<
OrderChangeEntity
>
findAllByClusterId
(
String
clusterId
,
Pageable
pageable
);
@Query
(
"select a from OrderChangeEntity a join OrderRequestEntity b on a.orderId=b.orderId where b.orgBranchId = :branchId"
)
Page
<
OrderChangeEntity
>
findAllByBranchId
(
Pageable
pageable
,
String
branchId
);
Page
<
OrderChangeEntity
>
findAllByBranchId
(
String
branchId
,
Pageable
pageable
);
@Query
(
"select a from OrderChangeEntity a join OrderRequestEntity b on a.orderId=b.orderId where b.orgGroupId = :groupId"
)
Page
<
OrderChangeEntity
>
findAllByGroupId
(
Pageable
pageable
,
String
groupId
);
Page
<
OrderChangeEntity
>
findAllByGroupId
(
String
groupId
,
Pageable
pageable
);
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/CapacityQueryReqDTO.java
→
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/Capacity
Order
QueryReqDTO.java
View file @
d327c81
...
...
@@ -3,7 +3,7 @@ package com.alibaba.cloud.integration.order.dto;
import
lombok.Data
;
@Data
public
class
CapacityQueryReqDTO
{
public
class
Capacity
Order
QueryReqDTO
{
private
String
location
;
private
String
address
;
private
String
brand
;
...
...
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/CapacityQueryRespDTO.java
→
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/CapacityQuery
Order
RespDTO.java
View file @
d327c81
...
...
@@ -7,7 +7,7 @@ import java.util.List;
@Data
@Accessors
(
chain
=
true
)
public
class
CapacityQueryRespDTO
{
public
class
CapacityQuery
Order
RespDTO
{
private
String
beginDate
;
private
String
endDate
;
private
String
remark
;
...
...
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/CapacityStatQueryReqDTO.java
0 → 100644
View file @
d327c81
package
com
.
alibaba
.
cloud
.
integration
.
order
.
dto
;
@lombok
.
Data
public
class
CapacityStatQueryReqDTO
{
private
String
beginDate
;
private
String
endDate
;
/**
* cluster/branch/group
*/
private
String
levelType
;
/**
* clusterId/branchId/groupId
*/
private
String
levelValue
;
private
Integer
page
;
private
Integer
pageSize
;
}
project-order/src/main/java/com/alibaba/cloud/integration/order/dto/CapacityStatQueryRespDTO.java
0 → 100644
View file @
d327c81
package
com
.
alibaba
.
cloud
.
integration
.
order
.
dto
;
import
lombok.experimental.Accessors
;
import
java.util.List
;
@lombok
.
Data
@Accessors
(
chain
=
true
)
public
class
CapacityStatQueryRespDTO
{
private
List
<?>
content
;
private
String
levelType
;
private
long
pageCurrent
;
private
long
pages
;
private
long
pageSize
;
private
long
total
;
@lombok
.
Data
@Accessors
(
chain
=
true
)
public
static
class
Content
{
private
long
capAdjust
;
private
long
capTotal
;
private
long
capUsed
;
private
String
createTime
;
private
String
date
;
private
long
engineerNum
;
private
String
groupName
;
private
String
layer
;
private
String
teamName
;
}
}
project-order/src/main/java/com/alibaba/cloud/integration/order/entity/CapacityOrgStatEntity.java
0 → 100644
View file @
d327c81
package
com
.
alibaba
.
cloud
.
integration
.
order
.
entity
;
import
lombok.Data
;
import
javax.persistence.*
;
import
java.util.Date
;
@Data
@Entity
@Table
(
name
=
"capacity_org_stat"
)
public
class
CapacityOrgStatEntity
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Integer
id
;
/**
* 日期
*/
private
String
workday
;
/**
* 类别-分部、小组、工作队
*/
private
String
type
;
/**
* 组织id
*/
private
String
orgId
;
/**
* 技能标签(辅助展示)
*/
private
String
layer
;
/**
* 技术员数量
*/
private
Integer
engineerCount
;
/**
* 总容量
*/
private
Integer
capTotal
;
/**
* 已占容量
*/
private
Integer
capUsedTotal
;
/**
* 剩余可约容量
*/
private
Integer
capLeft
;
/**
* 已约单量
*/
private
Integer
orderCount
;
/**
* 备注
*/
private
String
memo
;
/**
* 创建时间
*/
private
Date
createTime
;
/**
* 更新时间
*/
private
Date
updateTime
;
}
project-order/src/main/java/com/alibaba/cloud/integration/order/entity/CapacityTeamStatEntity.java
View file @
d327c81
...
...
@@ -6,11 +6,6 @@ import javax.persistence.*;
import
java.io.Serializable
;
import
java.util.Date
;
/**
* @description 容量-工作队时间段容量
* @author zhengkai.blog.csdn.net
* @date 2023-05-15
*/
@Entity
@Data
@Table
(
name
=
"capacity_team_stat"
)
...
...
project-order/src/main/java/com/alibaba/cloud/integration/order/service/CapacityQueryService.java
View file @
d327c81
package
com
.
alibaba
.
cloud
.
integration
.
order
.
service
;
import
com.alibaba.cloud.integration.common.Result
;
import
com.alibaba.cloud.integration.order.dto.CapacityQueryReqDTO
;
import
com.alibaba.cloud.integration.order.dto.CapacityOrderQueryReqDTO
;
import
com.alibaba.cloud.integration.order.dto.CapacityStatQueryReqDTO
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
public
interface
CapacityQueryService
{
...
...
@@ -12,5 +13,7 @@ public interface CapacityQueryService {
* @return
* @throws JsonProcessingException
*/
Result
<?>
getOneCapacityData
(
CapacityQueryReqDTO
capacityQueryReqDTO
);
Result
<?>
getOneCapacityData
(
CapacityOrderQueryReqDTO
capacityQueryReqDTO
);
Result
<?>
getTeamStatData
(
CapacityStatQueryReqDTO
capacityStatQueryReqDTO
);
}
project-order/src/main/java/com/alibaba/cloud/integration/order/service/impl/CapacityQueryServiceImpl.java
View file @
d327c81
package
com
.
alibaba
.
cloud
.
integration
.
order
.
service
.
impl
;
import
com.alibaba.cloud.integration.common.Result
;
import
com.alibaba.cloud.integration.order.dao.CapacityTeamStatDao
;
import
com.alibaba.cloud.integration.order.dao.MapBlockInfoDao
;
import
com.alibaba.cloud.integration.order.dao.ProductCategoryDao
;
import
com.alibaba.cloud.integration.order.dto.CapacityQueryReqDTO
;
import
com.alibaba.cloud.integration.order.dto.CapacityQueryRespDTO
;
import
com.alibaba.cloud.integration.order.dao.*
;
import
com.alibaba.cloud.integration.order.dto.CapacityOrderQueryReqDTO
;
import
com.alibaba.cloud.integration.order.dto.CapacityQueryOrderRespDTO
;
import
com.alibaba.cloud.integration.order.dto.CapacityStatQueryReqDTO
;
import
com.alibaba.cloud.integration.order.dto.CapacityStatQueryRespDTO
;
import
com.alibaba.cloud.integration.order.entity.CapacityOrgStatEntity
;
import
com.alibaba.cloud.integration.order.entity.CapacityTeamStatEntity
;
import
com.alibaba.cloud.integration.order.entity.OrgGroupEntity
;
import
com.alibaba.cloud.integration.order.service.CapacityQueryService
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
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.http.*
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.LinkedMultiValueMap
;
...
...
@@ -33,25 +38,68 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
private
CapacityTeamStatDao
capacityTeamStatDao
;
@Autowired
private
CapacityOrgStatDao
capacityOrgStatDao
;
@Autowired
private
ProductCategoryDao
productCategoryDao
;
@Autowired
private
MapBlockInfoDao
mapBlockInfoDao
;
@Autowired
private
OrgGroupDao
orgGroupDao
;
@Autowired
private
OrgTeamDao
orgTeamDao
;
@Override
public
Result
<?>
getOneCapacityData
(
CapacityQueryReqDTO
reqDTO
)
{
public
Result
<?>
getOneCapacityData
(
Capacity
Order
QueryReqDTO
reqDTO
)
{
/*
location ==> [layer_info] ==> team ==> (+skill) ==> [capacity_team_stat]
*/
String
layer
=
productCategoryDao
.
getLayerByBrandAndTypeAndSkill
(
reqDTO
.
getBrand
(),
reqDTO
.
getType
(),
reqDTO
.
getSkill
());
String
teamId
=
getTeamByLayer
(
reqDTO
.
getLocation
(),
reqDTO
.
getAddress
(),
layer
);
CapacityQuery
RespDTO
capacityQueryRespDTO
=
new
CapacityQuery
RespDTO
();
CapacityQuery
OrderRespDTO
capacityQueryRespDTO
=
new
CapacityQueryOrder
RespDTO
();
capacityQueryRespDTO
.
setBeginDate
(
capacityQueryRespDTO
.
getBeginDate
()).
setEndDate
(
reqDTO
.
getEndDate
());
capacityQueryRespDTO
.
setCalendar
(
getTimeRangeByTeamSkill
(
teamId
,
reqDTO
.
getSkill
(),
reqDTO
.
getBeginDate
(),
reqDTO
.
getEndDate
()));
capacityQueryRespDTO
.
setRemark
(
String
.
format
(
"%s-%s"
,
teamId
,
layer
));
return
Result
.
success
(
capacityQueryRespDTO
);
}
@Override
public
Result
<?>
getTeamStatData
(
CapacityStatQueryReqDTO
capacityStatQueryReqDTO
)
{
Page
<?>
stats
=
null
;
Pageable
pageable
=
PageRequest
.
of
(
capacityStatQueryReqDTO
.
getPage
()
-
1
,
capacityStatQueryReqDTO
.
getPageSize
());
if
(
"group"
.
equals
(
capacityStatQueryReqDTO
.
getLevelType
()))
{
stats
=
capacityOrgStatDao
.
findByGroupIdAndWorkdayBetween
(
capacityStatQueryReqDTO
.
getLevelValue
(),
capacityStatQueryReqDTO
.
getBeginDate
(),
capacityStatQueryReqDTO
.
getEndDate
(),
pageable
);
}
else
{
stats
=
capacityTeamStatDao
.
findByTeamIdAndWorkdayBetween
(
capacityStatQueryReqDTO
.
getLevelValue
(),
capacityStatQueryReqDTO
.
getBeginDate
(),
capacityStatQueryReqDTO
.
getEndDate
(),
pageable
);
}
CapacityStatQueryRespDTO
data
=
new
CapacityStatQueryRespDTO
();
data
.
setLevelType
(
capacityStatQueryReqDTO
.
getLevelType
());
data
.
setTotal
(
stats
.
getTotalElements
()).
setPages
(
stats
.
getTotalPages
()).
setPageSize
(
pageable
.
getPageSize
()).
setPageCurrent
(
stats
.
getNumber
());
List
<
CapacityStatQueryRespDTO
.
Content
>
contents
=
new
ArrayList
<>();
for
(
Object
item
:
stats
.
getContent
())
{
CapacityStatQueryRespDTO
.
Content
content
=
new
CapacityStatQueryRespDTO
.
Content
();
if
(
item
instanceof
CapacityOrgStatEntity
)
{
CapacityOrgStatEntity
e
=
(
CapacityOrgStatEntity
)
item
;
OrgGroupEntity
g
=
orgGroupDao
.
getByGroupId
(
e
.
getOrgId
());
content
.
setDate
(
e
.
getWorkday
()).
setLayer
(
e
.
getLayer
()).
setGroupName
(
g
.
getGroupName
())
.
setCapTotal
(
e
.
getCapTotal
()).
setCapUsed
(
e
.
getCapUsedTotal
()).
setEngineerNum
(
e
.
getEngineerCount
()).
setCreateTime
(
e
.
getCreateTime
().
toString
());
}
else
{
CapacityTeamStatEntity
e
=
(
CapacityTeamStatEntity
)
item
;
// capacity_team_stat表中的team_id,直接就是字符串
content
.
setDate
(
e
.
getWorkday
()).
setLayer
(
e
.
getLayer
()).
setTeamName
(
e
.
getTeamId
())
.
setCapTotal
(
e
.
getCapTotal
()).
setCapUsed
(
e
.
getCapUsed
()).
setCapAdjust
(
e
.
getCapAdjust
()).
setEngineerNum
(
e
.
getEngineerCount
()).
setCreateTime
(
e
.
getCreateTime
().
toString
());
}
contents
.
add
(
content
);
}
data
.
setContent
(
contents
);
return
Result
.
success
(
data
);
}
/**
* 根据提供的地址信息,获取对应的片区图层定义的工作队;如果没有找到,返回为空
* 目前layer_info表中,area_data是保存位置围栏的json数据,后面可能会是对于其他图层的引用;
...
...
@@ -145,18 +193,18 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
* @param endDate
* @return
*/
private
List
<
CapacityQueryRespDTO
.
CalendarDTO
>
getTimeRangeByTeamSkill
(
String
teamId
,
String
layer
,
String
beginDate
,
String
endDate
)
{
Map
<
String
,
CapacityQueryRespDTO
.
CalendarDTO
>
dayMaps
=
new
HashMap
<>();
private
List
<
CapacityQuery
Order
RespDTO
.
CalendarDTO
>
getTimeRangeByTeamSkill
(
String
teamId
,
String
layer
,
String
beginDate
,
String
endDate
)
{
Map
<
String
,
CapacityQuery
Order
RespDTO
.
CalendarDTO
>
dayMaps
=
new
HashMap
<>();
List
<
CapacityTeamStatEntity
>
capacityTeamStatEntityList
=
capacityTeamStatDao
.
findAllByTeamIdAndLayerAndWorkdayBetween
(
teamId
,
layer
,
beginDate
,
endDate
);
for
(
CapacityTeamStatEntity
e
:
capacityTeamStatEntityList
)
{
CapacityQuery
RespDTO
.
TimeDTO
timeDTO
=
new
CapacityQuery
RespDTO
.
TimeDTO
();
CapacityQuery
OrderRespDTO
.
TimeDTO
timeDTO
=
new
CapacityQueryOrder
RespDTO
.
TimeDTO
();
timeDTO
.
setType
(
getSpanType
(
e
.
getCapLeft
(),
e
.
getCapTotal
()));
Object
[]
timeSpans
=
getTimeSpanInfo
(
e
.
getWorkday
(),
e
.
getTimeSpan
(),
e
.
getTimeSpanDetail
());
timeDTO
.
setText
((
String
)
timeSpans
[
0
]);
timeDTO
.
setBegin
((
String
)
timeSpans
[
1
]);
timeDTO
.
setEnd
((
String
)
timeSpans
[
2
]);
if
(!
dayMaps
.
containsKey
(
e
.
getWorkday
()))
{
CapacityQuery
RespDTO
.
CalendarDTO
calendarDTO
=
new
CapacityQuery
RespDTO
.
CalendarDTO
();
CapacityQuery
OrderRespDTO
.
CalendarDTO
calendarDTO
=
new
CapacityQueryOrder
RespDTO
.
CalendarDTO
();
calendarDTO
.
setDate
(
e
.
getWorkday
());
calendarDTO
.
setWeek
(
getWeekday
(
e
.
getWorkday
()));
dayMaps
.
put
(
e
.
getWorkday
(),
calendarDTO
);
...
...
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