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 9c30ae54
authored
Jul 12, 2023
by
chamberone
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of
https://zhangguoping@gitlab.dituhui.com/bsh/project/pr…
…oject.git into develop
2 parents
b34d651e
8e51050c
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
344 additions
and
231 deletions
project-order/src/main/java/com/dituhui/pea/order/common/CapacityUtils.java
project-order/src/main/java/com/dituhui/pea/order/common/DateUtil.java → project-order/src/main/java/com/dituhui/pea/order/common/DateUtils.java
project-order/src/main/java/com/dituhui/pea/order/common/EngineerUtil.java → project-order/src/main/java/com/dituhui/pea/order/common/EngineerUtils.java
project-order/src/main/java/com/dituhui/pea/order/common/SaasUtils.java
project-order/src/main/java/com/dituhui/pea/order/controller/OrderCreateController.java
project-order/src/main/java/com/dituhui/pea/order/dao/CapacityEngineerStatDao.java
project-order/src/main/java/com/dituhui/pea/order/dao/EngineerSkillDao.java
project-order/src/main/java/com/dituhui/pea/order/dao/MapBlockInfoDao.java
project-order/src/main/java/com/dituhui/pea/order/dao/SkillInfoDao.java
project-order/src/main/java/com/dituhui/pea/order/entity/EngineerSkillEntity.java
project-order/src/main/java/com/dituhui/pea/order/service/CapacityQueryService.java
project-order/src/main/java/com/dituhui/pea/order/service/CommonService.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/BusinessTeamServiceImpl.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/CommonServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/DispatchServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/EngineerCalendarServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/EngineerGanttServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderCreateServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderServiceListServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrganizationServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/common/CapacityUtils.java
0 → 100644
View file @
9c30ae5
package
com
.
dituhui
.
pea
.
order
.
common
;
import
com.dituhui.pea.order.dao.MapBlockInfoDao
;
import
com.dituhui.pea.order.dao.SkillInfoDao
;
import
com.dituhui.pea.order.entity.MapBlockInfoEntity
;
import
com.dituhui.pea.order.entity.SkillInfoEntity
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Component
@Slf4j
public
class
CapacityUtils
{
@Autowired
private
SkillInfoDao
skillInfoDao
;
@Autowired
private
MapBlockInfoDao
mapBlockInfoDao
;
public
List
<
String
>
getTeamIdsByBlockIdsAndLayerIds
(
List
<
String
>
blockIds
,
List
<
String
>
layerIds
)
{
List
<
String
>
teamIds
=
mapBlockInfoDao
.
findByBlockIdInAndLayerIdIn
(
blockIds
,
layerIds
).
stream
().
map
(
MapBlockInfoEntity:
:
getTeamId
).
collect
(
Collectors
.
toList
());
log
.
info
(
"根据输入信息返回对应的可能的工作队列表({}/{}) ===> {}"
,
blockIds
,
layerIds
,
teamIds
);
return
teamIds
;
}
public
List
<
String
>
getLayers
(
String
brand
,
String
type
,
String
skill
)
{
List
<
String
>
layers
=
new
ArrayList
<>();
SkillInfoEntity
entity
=
skillInfoDao
.
getByBrandAndTypeAndSkill
(
brand
,
type
,
skill
);
if
(
entity
!=
null
)
{
layers
.
add
(
entity
.
getLayerId
());
}
return
layers
;
}
}
project-order/src/main/java/com/dituhui/pea/order/common/DateUtil.java
→
project-order/src/main/java/com/dituhui/pea/order/common/DateUtil
s
.java
View file @
9c30ae5
...
...
@@ -2,18 +2,39 @@ package com.dituhui.pea.order.common;
import
java.time.DayOfWeek
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.time.format.TextStyle
;
import
java.util.Locale
;
public
class
DateUtil
{
import
static
com
.
dituhui
.
pea
.
order
.
config
.
OrderConfig
.
PATTERN_DATE
;
import
static
com
.
dituhui
.
pea
.
order
.
config
.
OrderConfig
.
PATTERN_DATETIME
;
public
class
DateUtils
{
public
static
String
toWeekChinese
(
String
date
)
{
LocalDate
d
=
LocalDate
.
parse
(
date
);
return
DateUtil
.
toWeekChinese
(
d
.
getDayOfWeek
().
getValue
());
return
DateUtil
s
.
toWeekChinese
(
d
.
getDayOfWeek
().
getValue
());
}
public
static
String
toWeekChinese
(
int
dayOfWeek
)
{
// TextStyle: SHORT 周一;LONG 星期一;NARROW 一
return
DayOfWeek
.
of
(
dayOfWeek
).
getDisplayName
(
TextStyle
.
SHORT
,
Locale
.
CHINESE
);
}
public
static
String
formatDateTime
(
LocalDateTime
d
,
String
format
){
return
d
.
format
(
DateTimeFormatter
.
ofPattern
(
format
));
}
public
static
String
formatDateTime
(
LocalDateTime
d
){
return
formatDateTime
(
d
,
PATTERN_DATETIME
);
}
public
static
String
formatDate
(
LocalDate
d
,
String
format
){
return
d
.
format
(
DateTimeFormatter
.
ofPattern
(
format
));
}
public
static
String
formatDate
(
LocalDate
d
){
return
formatDate
(
d
,
PATTERN_DATE
);
}
}
project-order/src/main/java/com/dituhui/pea/order/common/EngineerUtil.java
→
project-order/src/main/java/com/dituhui/pea/order/common/EngineerUtil
s
.java
View file @
9c30ae5
...
...
@@ -22,7 +22,7 @@ import java.util.List;
import
java.util.stream.Collectors
;
@Component
public
class
EngineerUtil
{
public
class
EngineerUtil
s
{
@Autowired
private
OrgTeamEngineerDao
orgTeamEngineerDao
;
...
...
@@ -72,6 +72,7 @@ public class EngineerUtil {
private
Specification
<
EngineerInfoEntity
>
buildSpecification
(
String
keyword
)
{
// 动态查询
return
new
Specification
<
EngineerInfoEntity
>()
{
@Override
public
Predicate
toPredicate
(
Root
<
EngineerInfoEntity
>
root
,
CriteriaQuery
<?>
query
,
CriteriaBuilder
criteriaBuilder
)
{
...
...
project-order/src/main/java/com/dituhui/pea/order/common/SaasUtils.java
0 → 100644
View file @
9c30ae5
package
com
.
dituhui
.
pea
.
order
.
common
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
lombok.experimental.Accessors
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.http.*
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.web.client.RestTemplate
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Random
;
import
java.util.stream.Collectors
;
@Component
@Slf4j
public
class
SaasUtils
{
/**
* 根据提供的地址信息,获取对应的片区图层定义的工作队;如果没有找到,返回为空
*/
public
List
<
BlockInfo
>
queryBlocks
(
String
location
,
String
address
)
{
// 根据坐标 查询分单接口,获得区块、图层列表 ===> 查询map_block_info表,根据优先级,确定 工作队;
// 根据工作队+图层,查询 capacity_team_stat,返回
// todo 由于saas的分单接口尚未完成,目前仅仅是调用分单获取图层、区块名称,对于我们的容量查询没有真正使用,目前采用随机返回方式
// 创建RestTemplate实例
log
.
info
(
"===> queryBlocks({}, {})"
,
location
,
address
);
RestTemplate
restTemplate
=
new
RestTemplate
();
// 设置请求头
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
);
// 构建请求参数
String
url
;
MultiValueMap
<
String
,
Object
>
params
=
new
LinkedMultiValueMap
<>();
params
.
add
(
"ak"
,
"284c57cbabad4755a9c657885a8df3e2"
);
if
(
StringUtils
.
isNotEmpty
(
location
))
{
url
=
"https://pea-test.bshg.com.cn/v1/xyfendan"
;
String
[]
coordinates
=
location
.
split
(
","
);
params
.
add
(
"coordinate"
,
String
.
format
(
"{\"x\":%s, \"y\":%s}"
,
coordinates
[
0
],
coordinates
[
1
]));
}
else
{
url
=
"https://pea-test.bshg.com.cn/v2/fendan"
;
params
.
add
(
"addresses"
,
String
.
format
(
"[{\"address\":\"%s\"}]"
,
address
));
}
params
.
add
(
"need_district"
,
"false"
);
params
.
add
(
"need_layer"
,
"true"
);
// params.add("related_point_fields", "");
params
.
add
(
"area_fields"
,
"名称,唯一编号,区块"
);
log
.
info
(
"request params ==> {}"
,
params
);
// 构建请求实体
HttpEntity
<
MultiValueMap
<
String
,
Object
>>
requestEntity
=
new
HttpEntity
<>(
params
,
headers
);
// 发送POST请求
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
exchange
(
url
,
HttpMethod
.
POST
,
requestEntity
,
String
.
class
);
// 获取响应结果
String
responseBody
=
responseEntity
.
getBody
();
log
.
info
(
"after call saas ==> {}"
,
responseEntity
.
getBody
());
// 使用Jackson库解析JSON数据
List
<
BlockInfo
>
blocks
=
new
ArrayList
<>();
ObjectMapper
objectMapper
=
new
ObjectMapper
();
try
{
JsonNode
responseJson
=
objectMapper
.
readTree
(
responseBody
);
// 获取areaResults[0]的值
for
(
JsonNode
r
:
responseJson
.
get
(
"result"
).
get
(
0
).
get
(
"areaResults"
))
{
// 分单接口暂时无图层返回
if
(
r
.
get
(
"field3"
)
!=
null
&&
r
.
get
(
"field1"
)
!=
null
)
{
blocks
.
add
(
new
BlockInfo
().
setBlockId
(
r
.
get
(
"field3"
).
asText
()).
setBlockName
(
r
.
get
(
"field1"
).
asText
()));
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
}
return
blocks
;
}
public
List
<
String
>
queryBlockIds
(
String
location
,
String
address
)
{
return
queryBlocks
(
location
,
address
).
stream
().
map
(
BlockInfo:
:
getBlockId
).
collect
(
Collectors
.
toList
());
}
@lombok
.
Data
@Accessors
(
chain
=
true
)
static
class
BlockInfo
{
private
String
layer
;
private
String
blockId
;
private
String
blockName
;
}
}
project-order/src/main/java/com/dituhui/pea/order/controller/OrderCreateController.java
View file @
9c30ae5
/*
* Copyright 2013-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
dituhui
.
pea
.
order
.
controller
;
import
com.dituhui.pea.common.BusinessException
;
...
...
@@ -63,7 +47,7 @@ public class OrderCreateController {
public
Result
<?>
capacityQuery
(
@Validated
@RequestBody
CapacityOrderQueryDTO
.
Request
reqDTO
)
{
Result
<?>
res
=
null
;
try
{
res
=
capacityQueryService
.
getOne
CapacityData
(
reqDTO
);
res
=
capacityQueryService
.
queryMatch
CapacityData
(
reqDTO
);
}
catch
(
BusinessException
e
)
{
return
Result
.
failed
(
e
.
getMessage
());
}
...
...
project-order/src/main/java/com/dituhui/pea/order/dao/CapacityEngineerStatDao.java
View file @
9c30ae5
...
...
@@ -3,7 +3,11 @@ package com.dituhui.pea.order.dao;
import
com.dituhui.pea.order.entity.CapacityEngineerStatEntity
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
java.util.List
;
public
interface
CapacityEngineerStatDao
extends
JpaRepository
<
CapacityEngineerStatEntity
,
Integer
>
{
CapacityEngineerStatEntity
getByEngineerCodeAndWorkday
(
String
engineerCode
,
String
workday
);
CapacityEngineerStatEntity
getByWorkdayAndEngineerCode
(
String
workday
,
String
engineerCode
);
List
<
CapacityEngineerStatEntity
>
getByWorkdayAndEngineerCodeIn
(
String
workday
,
List
<
String
>
engineerCodes
);
}
project-order/src/main/java/com/dituhui/pea/order/dao/EngineerSkillDao.java
0 → 100644
View file @
9c30ae5
package
com
.
dituhui
.
pea
.
order
.
dao
;
import
com.dituhui.pea.order.entity.EngineerSkillEntity
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
java.util.List
;
public
interface
EngineerSkillDao
extends
JpaRepository
<
EngineerSkillEntity
,
Long
>
{
List
<
EngineerSkillEntity
>
findAllByBrandAndTypeAndSkillAndEngineerCodeIn
(
String
brand
,
String
type
,
String
skill
,
List
<
String
>
engineerCodes
);
}
project-order/src/main/java/com/dituhui/pea/order/dao/MapBlockInfoDao.java
View file @
9c30ae5
...
...
@@ -6,10 +6,10 @@ import org.springframework.data.jpa.repository.JpaRepository;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
@Repository
@Where
(
clause
=
"status = 1"
)
public
interface
MapBlockInfoDao
extends
JpaRepository
<
MapBlockInfoEntity
,
Integer
>
{
@Query
(
"select s.teamId from MapBlockInfoEntity s where s.blockId = :blockId and s.layer = :layer"
)
String
getTeamIdByBlockIdAndLayer
(
String
blockId
,
String
layer
);
List
<
MapBlockInfoEntity
>
findByBlockIdInAndLayerIdIn
(
List
<
String
>
blockIds
,
List
<
String
>
layerIds
);
}
project-order/src/main/java/com/dituhui/pea/order/dao/SkillInfoDao.java
View file @
9c30ae5
...
...
@@ -10,4 +10,5 @@ import java.util.List;
public
interface
SkillInfoDao
extends
JpaRepository
<
SkillInfoEntity
,
Long
>
{
List
<
SkillInfoEntity
>
findAll
();
Page
<
SkillInfoEntity
>
findAll
(
Pageable
pageable
);
SkillInfoEntity
getByBrandAndTypeAndSkill
(
String
brand
,
String
type
,
String
skill
);
}
project-order/src/main/java/com/dituhui/pea/order/entity/EngineerSkillEntity.java
0 → 100644
View file @
9c30ae5
package
com
.
dituhui
.
pea
.
order
.
entity
;
import
lombok.Data
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
@Data
@Entity
@Table
(
name
=
"v_engineer_skill"
)
public
class
EngineerSkillEntity
{
@Id
@GeneratedValue
private
Long
id
;
private
String
engineerCode
;
private
String
skillGroupCode
;
private
String
brand
;
private
String
type
;
private
String
skill
;
}
project-order/src/main/java/com/dituhui/pea/order/service/CapacityQueryService.java
View file @
9c30ae5
...
...
@@ -2,9 +2,7 @@ package com.dituhui.pea.order.service;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.dto.CapacityOrderQueryDTO
;
import
com.dituhui.pea.order.dto.CapacityStatQueryDTO
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
public
interface
CapacityQueryService
{
Result
<?>
getOne
CapacityData
(
CapacityOrderQueryDTO
.
Request
capacityQueryReqDTO
);
Result
<?>
queryMatch
CapacityData
(
CapacityOrderQueryDTO
.
Request
capacityQueryReqDTO
);
}
project-order/src/main/java/com/dituhui/pea/order/service/CommonService.java
View file @
9c30ae5
...
...
@@ -6,9 +6,6 @@ import java.util.List;
public
interface
CommonService
{
String
getTeamIdByInput
(
String
location
,
String
address
,
String
layer
);
void
addOrderEvent
(
String
orderId
,
String
subOrderId
,
String
source
,
String
operator
,
String
event
,
String
content
,
String
memo
);
List
<
LabelValueDTO
>
getSpecialParams
(
String
catalog
,
String
biztype
);
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/BusinessTeamServiceImpl.java
View file @
9c30ae5
...
...
@@ -2,7 +2,7 @@ package com.dituhui.pea.order.service.impl;
import
cn.hutool.core.util.IdUtil
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.common.DateUtil
;
import
com.dituhui.pea.order.common.DateUtil
s
;
import
com.dituhui.pea.order.dao.*
;
import
com.dituhui.pea.order.dto.*
;
import
com.dituhui.pea.order.entity.OrgGroupEntity
;
...
...
@@ -89,7 +89,7 @@ public class BusinessTeamServiceImpl implements BusinessTeamService {
List
<
String
>
days
=
Arrays
.
asList
(
workDays
.
split
(
","
));
Collections
.
sort
(
days
);
return
days
.
stream
().
map
(
e
->
{
return
DateUtil
.
toWeekChinese
(
Integer
.
parseInt
(
e
));
return
DateUtil
s
.
toWeekChinese
(
Integer
.
parseInt
(
e
));
}).
collect
(
Collectors
.
toList
());
}
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/CapacityQueryServiceImpl.java
View file @
9c30ae5
...
...
@@ -2,24 +2,26 @@ package com.dituhui.pea.order.service.impl;
import
cn.hutool.core.date.LocalDateTimeUtil
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.common.CapacityUtils
;
import
com.dituhui.pea.order.common.DateUtils
;
import
com.dituhui.pea.order.common.EngineerUtils
;
import
com.dituhui.pea.order.common.SaasUtils
;
import
com.dituhui.pea.order.dao.*
;
import
com.dituhui.pea.order.dto.CapacityOrderQueryDTO
;
import
com.dituhui.pea.order.dto.CapacityStatQueryDTO
;
import
com.dituhui.pea.order.entity.*
;
import
com.dituhui.pea.order.service.CapacityQueryService
;
import
com.dituhui.pea.order.service.CommonService
;
import
lombok.Data
;
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.time.DayOfWeek
;
import
java.time.LocalDate
;
import
java.time.format.TextStyle
;
import
java.time.temporal.ChronoUnit
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
import
static
com
.
dituhui
.
pea
.
order
.
config
.
OrderConfig
.
PATTERN_DATE
;
...
...
@@ -27,41 +29,55 @@ import static com.dituhui.pea.order.config.OrderConfig.PATTERN_DATE;
@Slf4j
public
class
CapacityQueryServiceImpl
implements
CapacityQueryService
{
private
final
String
[]
fullDay
=
{
"08:00"
,
"18:00"
};
@Autowired
private
CapacityTeamStatDao
capacityTeamStatDao
;
private
SkillInfoDao
skillInfoDao
;
@Autowired
private
CapacityOrgStatDao
capacityOrgStatDao
;
private
CapacityUtils
capacityUtils
;
@Autowired
private
ProductCategoryDao
productCategoryDao
;
private
SaasUtils
saasUtils
;
@Autowired
private
OrgGroupDao
orgGroupDao
;
private
EngineerUtils
engineerUtil
;
@Autowired
private
OrgTeamDao
orgTeamDao
;
private
EngineerSkillDao
engineerSkillDao
;
@Autowired
private
CommonService
commonService
;
private
CapacityEngineerStatDao
capacityEngineerStatDao
;
@Autowired
private
Org
BranchDao
orgBranch
Dao
;
private
Org
TeamDao
orgTeam
Dao
;
@Override
public
Result
<?>
getOne
CapacityData
(
CapacityOrderQueryDTO
.
Request
reqDTO
)
{
public
Result
<?>
queryMatch
CapacityData
(
CapacityOrderQueryDTO
.
Request
reqDTO
)
{
// 单条容量查询
log
.
info
(
"===> getOneCapacityData()"
);
String
layer
=
productCategoryDao
.
getLayerByBrandAndTypeAndSkill
(
reqDTO
.
getBrand
(),
reqDTO
.
getType
(),
reqDTO
.
getSkill
());
String
teamId
=
commonService
.
getTeamIdByInput
(
reqDTO
.
getLocation
(),
reqDTO
.
getAddress
(),
layer
);
log
.
info
(
"teamId[{}]layer[{}]"
,
teamId
,
layer
);
log
.
info
(
"===> queryMatchCapacityData()"
);
List
<
String
>
layerIds
=
capacityUtils
.
getLayers
(
reqDTO
.
getBrand
(),
reqDTO
.
getType
(),
reqDTO
.
getSkill
());
List
<
String
>
blockIds
=
saasUtils
.
queryBlockIds
(
reqDTO
.
getLocation
(),
reqDTO
.
getAddress
());
if
(
blockIds
==
null
||
blockIds
.
size
()
==
0
)
{
log
.
error
(
"分单接口没有查到对应的结果"
);
Result
.
failed
(
String
.
format
(
"分单接口(address:%s)(location:%s) 没有查到配置区块"
,
reqDTO
.
getAddress
(),
reqDTO
.
getLocation
()));
}
List
<
String
>
teamIds
=
capacityUtils
.
getTeamIdsByBlockIdsAndLayerIds
(
blockIds
,
layerIds
);
if
(
teamIds
==
null
||
teamIds
.
size
()
==
0
)
{
Result
.
failed
(
"没有找到匹配的工作队"
);
}
// 选择一个工作队(理论上,只有1个合适的工作队),然后遍历下面的各个技术员,从符合技能的技术员中,汇总相关的容量
// 遍历工作队,每个工作队
String
teamId
=
teamIds
.
get
(
0
);
List
<
String
>
engineerCodes
=
engineerUtil
.
getEngineersByLevel
(
"team"
,
teamId
).
stream
()
.
map
(
EngineerInfoEntity:
:
getEngineerCode
).
collect
(
Collectors
.
toList
());
List
<
String
>
matchEngineerCodes
=
engineerSkillDao
.
findAllByBrandAndTypeAndSkillAndEngineerCodeIn
(
reqDTO
.
getBrand
(),
reqDTO
.
getType
(),
reqDTO
.
getSkill
(),
engineerCodes
).
stream
()
.
map
(
EngineerSkillEntity:
:
getEngineerCode
).
collect
(
Collectors
.
toList
());
log
.
info
(
"符合技能要求的工作队[{}]符合技能要求的技术员[{}]"
,
teamId
,
matchEngineerCodes
);
SkillInfoEntity
skillInfoEntity
=
skillInfoDao
.
getByBrandAndTypeAndSkill
(
reqDTO
.
getBrand
(),
reqDTO
.
getType
(),
reqDTO
.
getSkill
());
List
<
CapacityOrderQueryDTO
.
CalendarDTO
>
calendars
=
getSummaryOfEngineersCapacity
(
teamId
,
matchEngineerCodes
,
reqDTO
.
getStartDate
(),
reqDTO
.
getEndDate
(),
skillInfoEntity
.
getTakeTime
());
CapacityOrderQueryDTO
.
Result
rs
=
new
CapacityOrderQueryDTO
.
Result
();
rs
.
setCalendar
(
calendars
);
rs
.
setStartDate
(
reqDTO
.
getStartDate
()).
setEndDate
(
reqDTO
.
getEndDate
());
rs
.
setCalendar
(
getTeamCapacityByLayerAndDays
(
teamId
,
layer
,
reqDTO
.
getStartDate
(),
reqDTO
.
getEndDate
()));
rs
.
setLegend
(
getLengends
());
rs
.
setRemark
(
String
.
format
(
"%s-%s"
,
teamId
,
layer
));
rs
.
setRemark
(
String
.
format
(
"%s-%s"
,
teamId
,
layer
Ids
));
return
Result
.
success
(
rs
);
}
...
...
@@ -73,6 +89,7 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
return
legends
;
}
private
int
getSpanType
(
int
capLeft
,
int
capTotal
)
{
float
ratio
=
(
float
)
capLeft
/
capTotal
;
if
(
ratio
<
0.3
)
{
...
...
@@ -84,62 +101,69 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
}
}
private
Object
[]
getTimeSpanInfo
(
String
date
,
String
timeSpan
,
String
timeSpanDetail
)
{
@Data
static
class
SpanInfo
{
private
String
title
;
private
String
timeBegin
;
private
String
timeEnd
;
}
private
SpanInfo
getTimeSpanInfo
(
String
teamId
,
String
date
,
String
timeSpan
,
String
timeSpanDetail
)
{
// 如果是"全天",直接返回标题和2个时间点;否则,解析timeSpanDetail中的数据返回
Object
[]
result
=
new
Object
[
3
];
OrgTeamEntity
orgTeamEntity
=
orgTeamDao
.
getByTeamId
(
teamId
);
SpanInfo
r
=
new
SpanInfo
();
if
(
"全天"
.
equals
(
timeSpan
))
{
result
[
0
]
=
"全天都可以"
;
result
[
1
]
=
String
.
format
(
"%s %s:00"
,
date
,
fullDay
[
0
]);
result
[
2
]
=
String
.
format
(
"%s %s:00"
,
date
,
fullDay
[
1
]);
return
result
;
r
.
setTitle
(
"全天都可以"
);
r
.
setTimeBegin
(
String
.
format
(
"%s %s:00"
,
date
,
orgTeamEntity
.
getWorkOn
()));
r
.
setTimeEnd
(
String
.
format
(
"%s %s:00"
,
date
,
orgTeamEntity
.
getWorkOff
()));
}
else
{
String
[]
times
=
timeSpanDetail
.
split
(
"~"
);
r
.
setTitle
(
String
.
format
(
"%s:00-%s:00"
,
times
[
0
],
times
[
1
]));
r
.
setTimeBegin
(
String
.
format
(
"%s %s:00"
,
date
,
times
[
0
]));
r
.
setTimeEnd
(
String
.
format
(
"%s %s:00"
,
date
,
times
[
1
]));
}
String
[]
times
=
timeSpanDetail
.
split
(
"~"
);
result
[
0
]
=
String
.
format
(
"%s:00-%s:00"
,
times
[
0
],
times
[
1
]);
result
[
1
]
=
String
.
format
(
"%s %s:00"
,
date
,
times
[
0
]);
result
[
2
]
=
String
.
format
(
"%s %s:00"
,
date
,
times
[
1
]);
return
result
;
return
r
;
}
/**
* 根据工作队、技能,返回对应时间段内的容量
*
* @param teamId
* @param layer
* @param beginDate
* @param endDate
* @return
* 查询日期范围内,技术员的容量。由于与具体的技能场景相关,因此,还需要检查最小需要的时间,如果不满足不返回;
*/
private
List
<
CapacityOrderQueryDTO
.
CalendarDTO
>
getTeamCapacityByLayerAndDays
(
String
teamId
,
String
layer
,
String
beginDate
,
String
endDate
)
{
log
.
info
(
"==> getTimeRangeByTeamSkill({}, {}, {}, {})"
,
teamId
,
layer
,
beginDate
,
endDate
);
Map
<
String
,
CapacityOrderQueryDTO
.
CalendarDTO
>
dayMaps
=
new
HashMap
<>();
List
<
CapacityTeamStatEntity
>
capacityTeamStatEntityList
=
capacityTeamStatDao
.
findAllByTeamIdAndLayerAndWorkdayBetween
(
teamId
,
layer
,
beginDate
,
endDate
);
for
(
CapacityTeamStatEntity
e
:
capacityTeamStatEntityList
)
{
log
.
info
(
"CapacityTeamStatEntity ==> {}"
,
e
);
CapacityOrderQueryDTO
.
TimeDTO
timeDTO
=
new
CapacityOrderQueryDTO
.
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
]);
CapacityOrderQueryDTO
.
CalendarDTO
calendarDTO
=
null
;
if
(
dayMaps
.
containsKey
(
e
.
getWorkday
()))
{
calendarDTO
=
dayMaps
.
get
(
e
.
getWorkday
());
}
else
{
calendarDTO
=
new
CapacityOrderQueryDTO
.
CalendarDTO
();
calendarDTO
.
setDate
(
e
.
getWorkday
()).
setWeek
(
getWeekday
(
e
.
getWorkday
()));
calendarDTO
.
setTimes
(
new
ArrayList
<>());
}
calendarDTO
.
getTimes
().
add
(
timeDTO
);
dayMaps
.
put
(
e
.
getWorkday
(),
calendarDTO
);
private
List
<
CapacityOrderQueryDTO
.
CalendarDTO
>
getSummaryOfEngineersCapacity
(
String
teamId
,
List
<
String
>
engineerCodes
,
String
bdate
,
String
edate
,
Integer
leastMinutes
)
{
log
.
info
(
"==> getSummaryOfEngineersCapacity({}, {}, {})"
,
engineerCodes
,
bdate
,
edate
);
List
<
CapacityOrderQueryDTO
.
CalendarDTO
>
rs
=
new
ArrayList
<>();
LocalDate
startDate
=
LocalDate
.
parse
(
bdate
);
LocalDate
endDate
=
LocalDate
.
parse
(
edate
);
List
<
String
>
datesInRange
=
Stream
.
iterate
(
startDate
,
date
->
date
.
plusDays
(
1
))
.
limit
(
ChronoUnit
.
DAYS
.
between
(
startDate
,
endDate
.
plusDays
(
1
)))
.
map
(
DateUtils:
:
formatDate
)
.
collect
(
Collectors
.
toList
());
for
(
String
date
:
datesInRange
)
{
CapacityOrderQueryDTO
.
CalendarDTO
calendar
=
getCapacityOneDay
(
teamId
,
engineerCodes
,
date
,
leastMinutes
);
rs
.
add
(
calendar
);
}
return
new
ArrayList
<>(
dayMaps
.
values
()).
stream
()
.
sorted
(
Comparator
.
comparing
(
CapacityOrderQueryDTO
.
CalendarDTO
::
getDate
)).
collect
(
Collectors
.
toList
());
return
rs
;
}
private
String
getWeekday
(
String
day
)
{
LocalDate
date
=
LocalDateTimeUtil
.
parseDate
(
day
,
PATTERN_DATE
);
DayOfWeek
weekday
=
date
.
getDayOfWeek
();
return
weekday
.
getDisplayName
(
TextStyle
.
SHORT
,
Locale
.
CHINA
);
private
CapacityOrderQueryDTO
.
CalendarDTO
getCapacityOneDay
(
String
teamId
,
List
<
String
>
engineerCodes
,
String
date
,
Integer
leastMinutes
)
{
CapacityOrderQueryDTO
.
CalendarDTO
calendar
=
new
CapacityOrderQueryDTO
.
CalendarDTO
();
calendar
.
setDate
(
date
);
calendar
.
setWeek
(
DateUtils
.
toWeekChinese
(
date
));
// 暂时是全天
// 总的容量
// List<CapacityEngineerStatEntity> stats = capacityEngineerStatDao.getByWorkdayAndEngineerCodeIn(date, engineerCodes).stream().filter(e->e.getMaxDuration()>leastMinutes).collect(Collectors.toList());
List
<
CapacityEngineerStatEntity
>
stats
=
capacityEngineerStatDao
.
getByWorkdayAndEngineerCodeIn
(
date
,
engineerCodes
);
CapacityOrderQueryDTO
.
TimeDTO
timeDTO
=
new
CapacityOrderQueryDTO
.
TimeDTO
();
SpanInfo
info
=
getTimeSpanInfo
(
teamId
,
date
,
"全天"
,
"08~18"
);
timeDTO
.
setText
(
info
.
getTitle
());
timeDTO
.
setBegin
(
info
.
getTimeBegin
());
timeDTO
.
setEnd
(
info
.
getTimeEnd
());
int
total
=
stats
.
stream
().
mapToInt
(
CapacityEngineerStatEntity:
:
getCapTotal
).
sum
();
int
left
=
stats
.
stream
().
mapToInt
(
CapacityEngineerStatEntity:
:
getCapLeft
).
sum
();
timeDTO
.
setType
(
getSpanType
(
left
,
total
));
calendar
.
setTimes
(
List
.
of
(
timeDTO
));
return
calendar
;
}
}
project-order/src/main/java/com/dituhui/pea/order/service/impl/CommonServiceImpl.java
View file @
9c30ae5
...
...
@@ -31,113 +31,11 @@ import java.util.stream.Collectors;
public
class
CommonServiceImpl
implements
CommonService
{
@Autowired
private
MapBlockInfoDao
mapBlockInfoDao
;
@Autowired
private
CapacityTeamStatDao
capacityTeamStatDao
;
@Autowired
private
OrderEventDao
orderEventDao
;
@Autowired
private
PubParamsDao
pubParamsDao
;
public
String
getTeamIdByInput
(
String
location
,
String
address
,
String
layer
)
{
// todo 目前会随机兜底,后面将合理化
log
.
info
(
"====== getTeamIdByInput ==="
);
String
teamId
=
null
;
List
<
LayerAndArea
>
layerAndAreas
=
getLayerAndAreas
(
location
,
address
);
if
(
layerAndAreas
==
null
||
layerAndAreas
.
size
()
==
0
)
{
// 分单接口没有查到,本地随机处理一下
teamId
=
capacityTeamStatDao
.
getRandomTeamIdByLayer
(
layer
);
log
.
info
(
"分单接口没有查到,本地随机处理一下 ==> {}"
,
teamId
);
}
else
{
// 分单接口查到了areaId(blockId),查询map_block_info,从而限定groupId,然后再随机teamId,这样就相对真实一点
// 生成随机索引
int
randomIndex
=
new
Random
().
nextInt
(
layerAndAreas
.
size
());
// 获取随机元素
LayerAndArea
layerAndArea
=
layerAndAreas
.
get
(
randomIndex
);
teamId
=
mapBlockInfoDao
.
getTeamIdByBlockIdAndLayer
(
layerAndArea
.
areaId
,
layer
);
log
.
info
(
"分单接口查询返回区块,layerAndArea=={}, teamId=={}"
,
layerAndArea
,
teamId
);
}
if
(
StringUtils
.
isEmpty
(
teamId
))
{
teamId
=
capacityTeamStatDao
.
getRandomTeamId
();
log
.
info
(
"查询没有teamId,需要随机生成teamId=={}"
,
teamId
);
}
log
.
info
(
"teamId ==> {}"
,
teamId
);
assert
(
StringUtils
.
isNotEmpty
(
teamId
));
return
teamId
;
}
/**
* 根据提供的地址信息,获取对应的片区图层定义的工作队;如果没有找到,返回为空
* 目前layer_info表中,area_data是保存位置围栏的json数据,后面可能会是对于其他图层的引用;
*
* @param location
* @return
*/
private
List
<
LayerAndArea
>
getLayerAndAreas
(
String
location
,
String
address
)
{
// 根据坐标 查询分单接口,获得区块、图层列表 ===> 查询map_block_info表,根据优先级,确定 工作队;
// 根据工作队+图层,查询 capacity_team_stat,返回
// todo 由于saas的分单接口尚未完成,目前仅仅是调用分单获取图层、区块名称,对于我们的容量查询没有真正使用,目前采用随机返回方式
// 创建RestTemplate实例
log
.
info
(
"===> getLayerAndAreas({}, {})"
,
location
,
address
);
RestTemplate
restTemplate
=
new
RestTemplate
();
// 设置请求头
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
);
// 构建请求参数
String
url
;
MultiValueMap
<
String
,
Object
>
params
=
new
LinkedMultiValueMap
<>();
params
.
add
(
"ak"
,
"284c57cbabad4755a9c657885a8df3e2"
);
if
(
StringUtils
.
isNotEmpty
(
location
))
{
url
=
"https://pea-test.bshg.com.cn/v1/xyfendan"
;
String
[]
coordinates
=
location
.
split
(
","
);
params
.
add
(
"coordinate"
,
String
.
format
(
"{\"x\":%s, \"y\":%s}"
,
coordinates
[
0
],
coordinates
[
1
]));
}
else
{
url
=
"https://pea-test.bshg.com.cn/v2/fendan"
;
params
.
add
(
"addresses"
,
String
.
format
(
"[{\"address\":\"%s\"}]"
,
address
));
}
params
.
add
(
"need_district"
,
"false"
);
params
.
add
(
"need_layer"
,
"true"
);
// params.add("related_point_fields", "");
params
.
add
(
"area_fields"
,
"名称,唯一编号,区块"
);
log
.
info
(
"request params ==> {}"
,
params
);
// 构建请求实体
HttpEntity
<
MultiValueMap
<
String
,
Object
>>
requestEntity
=
new
HttpEntity
<>(
params
,
headers
);
// 发送POST请求
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
exchange
(
url
,
HttpMethod
.
POST
,
requestEntity
,
String
.
class
);
// 获取响应结果
String
responseBody
=
responseEntity
.
getBody
();
log
.
info
(
"after call saas ==> {}"
,
responseEntity
.
getBody
());
// 使用Jackson库解析JSON数据
ObjectMapper
objectMapper
=
new
ObjectMapper
();
try
{
List
<
LayerAndArea
>
results
=
new
ArrayList
<>();
JsonNode
responseJson
=
objectMapper
.
readTree
(
responseBody
);
// 获取areaResults[0]的值
for
(
JsonNode
r
:
responseJson
.
get
(
"result"
).
get
(
0
).
get
(
"areaResults"
))
{
// 分单接口暂时无图层返回
results
.
add
(
new
LayerAndArea
().
setAreaId
(
r
.
get
(
"field3"
).
asText
()).
setAreaName
(
r
.
get
(
"field1"
).
asText
()));
}
return
results
;
}
catch
(
Exception
e
)
{
return
null
;
}
}
@lombok
.
Data
@Accessors
(
chain
=
true
)
private
static
class
LayerAndArea
{
private
String
layer
;
private
String
areaId
;
private
String
areaName
;
}
public
void
addOrderEvent
(
String
orderId
,
String
subOrderId
,
String
source
,
String
operator
,
String
event
,
String
content
,
String
memo
)
{
OrderEventEntity
entity
=
new
OrderEventEntity
();
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/DispatchServiceImpl.java
View file @
9c30ae5
...
...
@@ -73,8 +73,8 @@ public class DispatchServiceImpl implements DispatchService {
item
.
setRemark
(
o
.
getApplyNote
());
item
.
setCustomerName
(
o
.
getName
());
String
description
=
String
.
format
(
"%s:%s%s-%s\n%s:%s"
,
o
.
getOrderId
(),
o
.
getSkill
(),
o
.
getType
(),
o
.
getBrand
(),
o
.
getName
(),
o
.
getAddress
());
String
description
=
String
.
format
(
"%s:%s%s-%s\n%s:%s
-%s-%s
"
,
o
.
getOrderId
(),
o
.
getSkill
(),
o
.
getType
(),
o
.
getBrand
(),
o
.
getName
(),
o
.
get
City
(),
o
.
getCounty
(),
o
.
get
Address
());
item
.
setDescription
(
description
);
String
key
=
String
.
format
(
"%s%s%s"
,
o
.
getBrand
(),
o
.
getType
(),
o
.
getSkill
());
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/EngineerCalendarServiceImpl.java
View file @
9c30ae5
...
...
@@ -2,8 +2,8 @@ package com.dituhui.pea.order.service.impl;
import
cn.hutool.core.date.LocalDateTimeUtil
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.common.DateUtil
;
import
com.dituhui.pea.order.common.EngineerUtil
;
import
com.dituhui.pea.order.common.DateUtil
s
;
import
com.dituhui.pea.order.common.EngineerUtil
s
;
import
com.dituhui.pea.order.dao.CapacityEngineerCalendarDao
;
import
com.dituhui.pea.order.dao.OrgTeamDao
;
import
com.dituhui.pea.order.dao.OrgTeamEngineerDao
;
...
...
@@ -34,7 +34,7 @@ import static com.dituhui.pea.order.config.OrderConfig.PATTERN_DATETIME;
public
class
EngineerCalendarServiceImpl
implements
EngineerCalendarService
{
@Autowired
private
EngineerUtil
engineerUtil
;
private
EngineerUtil
s
engineerUtil
;
@Autowired
private
OrgTeamEngineerDao
orgTeamEngineerDao
;
...
...
@@ -141,7 +141,7 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
EngineerCalendarDTO
.
Calendar
calendar
=
new
EngineerCalendarDTO
.
Calendar
();
calendar
.
setDate
(
date
);
int
dayOfWeek
=
LocalDate
.
parse
(
date
).
getDayOfWeek
().
getValue
();
calendar
.
setWeek
(
DateUtil
.
toWeekChinese
(
dayOfWeek
));
calendar
.
setWeek
(
DateUtil
s
.
toWeekChinese
(
dayOfWeek
));
EngineerCalendarDTO
.
Content
content
=
new
EngineerCalendarDTO
.
Content
();
List
<
String
>
workdays
=
Arrays
.
asList
(
e
.
getWorkdays
().
split
(
","
));
if
(
workdays
.
contains
(
String
.
valueOf
(
dayOfWeek
)))
{
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/EngineerGanttServiceImpl.java
View file @
9c30ae5
package
com
.
dituhui
.
pea
.
order
.
service
.
impl
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.common.EngineerUtil
;
import
com.dituhui.pea.order.common.EngineerUtil
s
;
import
com.dituhui.pea.order.dao.CapacityEngineerStatDao
;
import
com.dituhui.pea.order.dao.EngineerInfoDao
;
import
com.dituhui.pea.order.dao.OrderAppointmentDao
;
...
...
@@ -39,7 +39,7 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
private
OrderRequestDao
orderRequestDao
;
@Autowired
private
EngineerUtil
engineerUtil
;
private
EngineerUtil
s
engineerUtils
;
@Override
public
Result
<?>
getEngineersGanttList
(
EngineersGanttDTO
.
Request
reqDTO
)
{
...
...
@@ -85,7 +85,7 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
.
setEngineerName
(
engineerInfo
.
getName
())
.
setGrade
(
engineerInfo
.
getGrade
());
CapacityEngineerStatEntity
capacityEngineerStat
=
capacityEngineerStatDao
.
getBy
EngineerCodeAndWorkday
(
engineerCode
,
reqDTO
.
getDate
()
);
CapacityEngineerStatEntity
capacityEngineerStat
=
capacityEngineerStatDao
.
getBy
WorkdayAndEngineerCode
(
reqDTO
.
getDate
(),
engineerCode
);
if
(
capacityEngineerStat
==
null
)
{
log
.
warn
(
"技术员当日的容量数据不存在,{}{}"
,
engineerCode
,
reqDTO
.
getDate
());
}
else
{
...
...
@@ -108,39 +108,38 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
if
(
teamIds
!=
null
&&
teamIds
.
size
()
>
0
)
{
for
(
String
teamId
:
teamIds
)
{
engineerCodes
.
addAll
(
engineerUtil
.
getEngineersByLevel
(
"team"
,
teamId
).
stream
().
map
(
EngineerInfoEntity:
:
getEngineerCode
).
collect
(
Collectors
.
toList
()));
engineerUtil
s
.
getEngineersByLevel
(
"team"
,
teamId
).
stream
().
map
(
EngineerInfoEntity:
:
getEngineerCode
).
collect
(
Collectors
.
toList
()));
}
}
else
if
(
groupIds
!=
null
&&
groupIds
.
size
()
>
0
)
{
for
(
String
groupId
:
groupIds
)
{
engineerCodes
.
addAll
(
engineerUtil
.
getEngineersByLevel
(
"group"
,
groupId
).
stream
().
map
(
EngineerInfoEntity:
:
getEngineerCode
).
collect
(
Collectors
.
toList
()));
engineerUtil
s
.
getEngineersByLevel
(
"group"
,
groupId
).
stream
().
map
(
EngineerInfoEntity:
:
getEngineerCode
).
collect
(
Collectors
.
toList
()));
}
}
else
if
(
branchIds
!=
null
&&
branchIds
.
size
()
>
0
)
{
for
(
String
branchId
:
branchIds
)
{
engineerCodes
.
addAll
(
engineerUtil
.
getEngineersByLevel
(
"branch"
,
branchId
).
stream
().
map
(
EngineerInfoEntity:
:
getEngineerCode
).
collect
(
Collectors
.
toList
()));
engineerUtil
s
.
getEngineersByLevel
(
"branch"
,
branchId
).
stream
().
map
(
EngineerInfoEntity:
:
getEngineerCode
).
collect
(
Collectors
.
toList
()));
}
}
else
{
engineerCodes
.
addAll
(
engineerUtil
.
getEngineersByLevel
(
levelType
,
levelValue
).
stream
().
map
(
EngineerInfoEntity:
:
getEngineerCode
).
collect
(
Collectors
.
toList
()));
engineerCodes
.
addAll
(
engineerUtil
s
.
getEngineersByLevel
(
levelType
,
levelValue
).
stream
().
map
(
EngineerInfoEntity:
:
getEngineerCode
).
collect
(
Collectors
.
toList
()));
}
engineerCodes
=
new
ArrayList
<>(
new
HashSet
<>(
engineerCodes
));
if
(
StringUtils
.
isBlank
(
key
))
{
return
engineerCodes
;
}
else
{
// 最后,还需要根据key进行过滤(需要结合数据库表)
return
engineerUtil
.
filterEngineersByKey
(
engineerCodes
,
key
).
stream
().
map
(
EngineerInfoEntity:
:
getEngineerCode
).
collect
(
Collectors
.
toList
());
return
engineerUtil
s
.
filterEngineersByKey
(
engineerCodes
,
key
).
stream
().
map
(
EngineerInfoEntity:
:
getEngineerCode
).
collect
(
Collectors
.
toList
());
}
}
public
Map
<
String
,
OrderRequestEntity
>
getOrdersByOrderIds
(
List
<
String
>
orderIds
)
{
List
<
OrderRequestEntity
>
orders
=
orderRequestDao
.
findAllByOrderIdIn
(
orderIds
);
return
orders
.
stream
()
.
collect
(
Collectors
.
toMap
(
OrderRequestEntity:
:
getOrderId
,
order
->
order
));
return
orders
.
stream
().
collect
(
Collectors
.
toMap
(
OrderRequestEntity:
:
getOrderId
,
order
->
order
));
}
private
List
<?>
getOrderTips
(
String
orderId
)
{
log
.
info
(
"==> getOrderTips: orderId[{}]"
,
orderId
);
//
log.info("==> getOrderTips: orderId[{}]", orderId);
OrderRequestEntity
order
=
orderRequestDao
.
getByOrderId
(
orderId
);
if
(
order
==
null
)
{
log
.
error
(
"对应的订单不存在!{}"
,
orderId
);
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderCreateServiceImpl.java
View file @
9c30ae5
...
...
@@ -19,6 +19,8 @@ package com.dituhui.pea.order.service.impl;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.date.LocalDateTimeUtil
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.common.CapacityUtils
;
import
com.dituhui.pea.order.common.SaasUtils
;
import
com.dituhui.pea.order.dao.OrderRequestDao
;
import
com.dituhui.pea.order.dao.OrgTeamDao
;
import
com.dituhui.pea.order.dao.ProductCategoryDao
;
...
...
@@ -59,6 +61,10 @@ public class OrderCreateServiceImpl implements OrderCreateService {
@Autowired
private
CommonService
commonService
;
@Autowired
private
CapacityUtils
capacityUtils
;
@Autowired
private
SaasUtils
saasUtils
;
private
List
<
LabelValueDTO
>
getPriorities
()
{
String
[]
priorities
=
{
"紧急"
,
"正常"
};
...
...
@@ -116,9 +122,23 @@ public class OrderCreateServiceImpl implements OrderCreateService {
entity
.
setCounty
(
location
.
getDistrict
());
entity
.
setAddress
(
location
.
getFormattedAddress
());
// 根据分单,填写clusterId/branchId/groupId/teamId等
String
layer
=
productCategoryDao
.
getLayerByBrandAndTypeAndSkill
(
req
.
getBrand
(),
req
.
getType
(),
req
.
getSkill
());
String
loc
=
String
.
format
(
"%f,%f"
,
req
.
getLocation
().
getLng
(),
req
.
getLocation
().
getLat
());
String
teamId
=
commonService
.
getTeamIdByInput
(
loc
,
req
.
getAddress
(),
layer
);
List
<
String
>
layerIds
=
capacityUtils
.
getLayers
(
req
.
getBrand
(),
req
.
getType
(),
req
.
getSkill
());
List
<
String
>
blockIds
=
saasUtils
.
queryBlockIds
(
loc
,
req
.
getAddress
());
if
(
blockIds
==
null
||
blockIds
.
size
()
==
0
)
{
log
.
error
(
"分单接口没有查到对应的结果"
);
Result
.
failed
(
String
.
format
(
"分单接口(address:%s)(location:%s) 没有查到配置区块"
,
req
.
getAddress
(),
req
.
getLocation
()));
}
List
<
String
>
teamIds
=
capacityUtils
.
getTeamIdsByBlockIdsAndLayerIds
(
blockIds
,
layerIds
);
if
(
teamIds
==
null
||
teamIds
.
size
()
==
0
)
{
Result
.
failed
(
"没有找到匹配的工作队"
);
}
// 选择一个工作队(理论上,只有1个合适的工作队),然后遍历下面的各个技术员,从符合技能的技术员中,汇总相关的容量
// 遍历工作队,每个工作队
String
teamId
=
teamIds
.
get
(
0
);
OrgTeamEntity
teamEntity
=
orgTeamDao
.
getByTeamId
(
teamId
);
entity
.
setOrgClusterId
(
teamEntity
.
getClusterId
());
entity
.
setOrgBranchId
(
teamEntity
.
getBranchId
());
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderServiceListServiceImpl.java
View file @
9c30ae5
...
...
@@ -119,7 +119,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
record
.
setSkill
(
o
.
getSkill
());
record
.
setName
(
o
.
getName
());
record
.
setPhone
(
o
.
getPhone
());
record
.
setAddress
(
o
.
getAddress
(
));
record
.
setAddress
(
String
.
format
(
"%s-%s-%s"
,
o
.
getCity
(),
o
.
getCounty
(),
o
.
getAddress
()
));
record
.
setX
(
o
.
getX
());
record
.
setY
(
o
.
getY
());
record
.
setSource
(
o
.
getSource
());
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrganizationServiceImpl.java
View file @
9c30ae5
package
com
.
dituhui
.
pea
.
order
.
service
.
impl
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.common.EngineerUtil
;
import
com.dituhui.pea.order.common.EngineerUtil
s
;
import
com.dituhui.pea.order.dao.*
;
import
com.dituhui.pea.order.dto.*
;
import
com.dituhui.pea.order.entity.*
;
...
...
@@ -33,7 +33,7 @@ public class OrganizationServiceImpl implements OrganizationService {
private
OrgTeamDao
orgTeamDao
;
@Autowired
private
EngineerUtil
engineerUtil
;
private
EngineerUtil
s
engineerUtils
;
@Override
public
Result
<?>
getOrganizationTree
(
String
levelType
,
String
levelValue
)
{
...
...
@@ -115,7 +115,7 @@ public class OrganizationServiceImpl implements OrganizationService {
@Override
public
Result
<?>
getEngineersByLevel
(
String
levelType
,
String
levelValue
)
{
List
<
EngineerInfoEntity
>
engineers
=
engineerUtil
.
getEngineersByLevel
(
levelType
,
levelValue
);
List
<
EngineerInfoEntity
>
engineers
=
engineerUtil
s
.
getEngineersByLevel
(
levelType
,
levelValue
);
List
<
OrganizationEngineersDTO
.
Engineer
>
engineers1
=
engineers
.
stream
().
map
(
entity
->
{
return
new
OrganizationEngineersDTO
.
Engineer
()
.
setEngineerCode
(
entity
.
getEngineerCode
())
...
...
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