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 a438f777
authored
Jul 12, 2023
by
丁伟峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
创建订单之前的容量查询,改用新的数据表和逻辑实现
1 parent
df81069f
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
219 additions
and
152 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/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/OrganizationServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/common/CapacityUtils.java
0 → 100644
View file @
a438f77
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 @
a438f77
...
@@ -2,18 +2,39 @@ package com.dituhui.pea.order.common;
...
@@ -2,18 +2,39 @@ package com.dituhui.pea.order.common;
import
java.time.DayOfWeek
;
import
java.time.DayOfWeek
;
import
java.time.LocalDate
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.time.format.TextStyle
;
import
java.time.format.TextStyle
;
import
java.util.Locale
;
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
)
{
public
static
String
toWeekChinese
(
String
date
)
{
LocalDate
d
=
LocalDate
.
parse
(
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
)
{
public
static
String
toWeekChinese
(
int
dayOfWeek
)
{
// TextStyle: SHORT 周一;LONG 星期一;NARROW 一
// TextStyle: SHORT 周一;LONG 星期一;NARROW 一
return
DayOfWeek
.
of
(
dayOfWeek
).
getDisplayName
(
TextStyle
.
SHORT
,
Locale
.
CHINESE
);
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 @
a438f77
...
@@ -22,7 +22,7 @@ import java.util.List;
...
@@ -22,7 +22,7 @@ import java.util.List;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
@Component
@Component
public
class
EngineerUtil
{
public
class
EngineerUtil
s
{
@Autowired
@Autowired
private
OrgTeamEngineerDao
orgTeamEngineerDao
;
private
OrgTeamEngineerDao
orgTeamEngineerDao
;
...
@@ -72,6 +72,7 @@ public class EngineerUtil {
...
@@ -72,6 +72,7 @@ public class EngineerUtil {
private
Specification
<
EngineerInfoEntity
>
buildSpecification
(
String
keyword
)
{
private
Specification
<
EngineerInfoEntity
>
buildSpecification
(
String
keyword
)
{
// 动态查询
return
new
Specification
<
EngineerInfoEntity
>()
{
return
new
Specification
<
EngineerInfoEntity
>()
{
@Override
@Override
public
Predicate
toPredicate
(
Root
<
EngineerInfoEntity
>
root
,
CriteriaQuery
<?>
query
,
CriteriaBuilder
criteriaBuilder
)
{
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 @
a438f77
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数据
ObjectMapper
objectMapper
=
new
ObjectMapper
();
try
{
List
<
BlockInfo
>
blocks
=
new
ArrayList
<>();
JsonNode
responseJson
=
objectMapper
.
readTree
(
responseBody
);
// 获取areaResults[0]的值
for
(
JsonNode
r
:
responseJson
.
get
(
"result"
).
get
(
0
).
get
(
"areaResults"
))
{
// 分单接口暂时无图层返回
blocks
.
add
(
new
BlockInfo
().
setBlockId
(
r
.
get
(
"field3"
).
asText
()).
setBlockName
(
r
.
get
(
"field1"
).
asText
()));
}
return
blocks
;
}
catch
(
Exception
e
)
{
return
null
;
}
}
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 @
a438f77
/*
* 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
;
package
com
.
dituhui
.
pea
.
order
.
controller
;
import
com.dituhui.pea.common.BusinessException
;
import
com.dituhui.pea.common.BusinessException
;
...
@@ -63,7 +47,7 @@ public class OrderCreateController {
...
@@ -63,7 +47,7 @@ public class OrderCreateController {
public
Result
<?>
capacityQuery
(
@Validated
@RequestBody
CapacityOrderQueryDTO
.
Request
reqDTO
)
{
public
Result
<?>
capacityQuery
(
@Validated
@RequestBody
CapacityOrderQueryDTO
.
Request
reqDTO
)
{
Result
<?>
res
=
null
;
Result
<?>
res
=
null
;
try
{
try
{
res
=
capacityQueryService
.
getOne
CapacityData
(
reqDTO
);
res
=
capacityQueryService
.
queryMatch
CapacityData
(
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/dao/CapacityEngineerStatDao.java
View file @
a438f77
...
@@ -3,7 +3,11 @@ package com.dituhui.pea.order.dao;
...
@@ -3,7 +3,11 @@ package com.dituhui.pea.order.dao;
import
com.dituhui.pea.order.entity.CapacityEngineerStatEntity
;
import
com.dituhui.pea.order.entity.CapacityEngineerStatEntity
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
java.util.List
;
public
interface
CapacityEngineerStatDao
extends
JpaRepository
<
CapacityEngineerStatEntity
,
Integer
>
{
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 @
a438f77
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 @
a438f77
...
@@ -6,10 +6,10 @@ import org.springframework.data.jpa.repository.JpaRepository;
...
@@ -6,10 +6,10 @@ import org.springframework.data.jpa.repository.JpaRepository;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
@Repository
@Repository
@Where
(
clause
=
"status = 1"
)
public
interface
MapBlockInfoDao
extends
JpaRepository
<
MapBlockInfoEntity
,
Integer
>
{
public
interface
MapBlockInfoDao
extends
JpaRepository
<
MapBlockInfoEntity
,
Integer
>
{
@Query
(
"select s.teamId from MapBlockInfoEntity s where s.blockId = :blockId and s.layer = :layer"
)
List
<
MapBlockInfoEntity
>
findByBlockIdInAndLayerIdIn
(
List
<
String
>
blockIds
,
List
<
String
>
layerIds
);
String
getTeamIdByBlockIdAndLayer
(
String
blockId
,
String
layer
);
}
}
project-order/src/main/java/com/dituhui/pea/order/dao/SkillInfoDao.java
View file @
a438f77
...
@@ -10,4 +10,5 @@ import java.util.List;
...
@@ -10,4 +10,5 @@ import java.util.List;
public
interface
SkillInfoDao
extends
JpaRepository
<
SkillInfoEntity
,
Long
>
{
public
interface
SkillInfoDao
extends
JpaRepository
<
SkillInfoEntity
,
Long
>
{
List
<
SkillInfoEntity
>
findAll
();
List
<
SkillInfoEntity
>
findAll
();
Page
<
SkillInfoEntity
>
findAll
(
Pageable
pageable
);
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 @
a438f77
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 @
a438f77
...
@@ -2,9 +2,7 @@ package com.dituhui.pea.order.service;
...
@@ -2,9 +2,7 @@ package com.dituhui.pea.order.service;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.dto.CapacityOrderQueryDTO
;
import
com.dituhui.pea.order.dto.CapacityOrderQueryDTO
;
import
com.dituhui.pea.order.dto.CapacityStatQueryDTO
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
public
interface
CapacityQueryService
{
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 @
a438f77
...
@@ -6,9 +6,6 @@ import java.util.List;
...
@@ -6,9 +6,6 @@ import java.util.List;
public
interface
CommonService
{
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
);
void
addOrderEvent
(
String
orderId
,
String
subOrderId
,
String
source
,
String
operator
,
String
event
,
String
content
,
String
memo
);
List
<
LabelValueDTO
>
getSpecialParams
(
String
catalog
,
String
biztype
);
List
<
LabelValueDTO
>
getSpecialParams
(
String
catalog
,
String
biztype
);
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/BusinessTeamServiceImpl.java
View file @
a438f77
...
@@ -2,7 +2,7 @@ package com.dituhui.pea.order.service.impl;
...
@@ -2,7 +2,7 @@ package com.dituhui.pea.order.service.impl;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.util.IdUtil
;
import
com.dituhui.pea.common.Result
;
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.dao.*
;
import
com.dituhui.pea.order.dto.*
;
import
com.dituhui.pea.order.dto.*
;
import
com.dituhui.pea.order.entity.OrgGroupEntity
;
import
com.dituhui.pea.order.entity.OrgGroupEntity
;
...
@@ -89,7 +89,7 @@ public class BusinessTeamServiceImpl implements BusinessTeamService {
...
@@ -89,7 +89,7 @@ public class BusinessTeamServiceImpl implements BusinessTeamService {
List
<
String
>
days
=
Arrays
.
asList
(
workDays
.
split
(
","
));
List
<
String
>
days
=
Arrays
.
asList
(
workDays
.
split
(
","
));
Collections
.
sort
(
days
);
Collections
.
sort
(
days
);
return
days
.
stream
().
map
(
e
->
{
return
days
.
stream
().
map
(
e
->
{
return
DateUtil
.
toWeekChinese
(
Integer
.
parseInt
(
e
));
return
DateUtil
s
.
toWeekChinese
(
Integer
.
parseInt
(
e
));
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
}
}
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/CapacityQueryServiceImpl.java
View file @
a438f77
This diff is collapsed.
Click to expand it.
project-order/src/main/java/com/dituhui/pea/order/service/impl/CommonServiceImpl.java
View file @
a438f77
...
@@ -31,113 +31,11 @@ import java.util.stream.Collectors;
...
@@ -31,113 +31,11 @@ import java.util.stream.Collectors;
public
class
CommonServiceImpl
implements
CommonService
{
public
class
CommonServiceImpl
implements
CommonService
{
@Autowired
@Autowired
private
MapBlockInfoDao
mapBlockInfoDao
;
@Autowired
private
CapacityTeamStatDao
capacityTeamStatDao
;
@Autowired
private
OrderEventDao
orderEventDao
;
private
OrderEventDao
orderEventDao
;
@Autowired
@Autowired
private
PubParamsDao
pubParamsDao
;
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
)
{
public
void
addOrderEvent
(
String
orderId
,
String
subOrderId
,
String
source
,
String
operator
,
String
event
,
String
content
,
String
memo
)
{
OrderEventEntity
entity
=
new
OrderEventEntity
();
OrderEventEntity
entity
=
new
OrderEventEntity
();
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/EngineerCalendarServiceImpl.java
View file @
a438f77
...
@@ -2,8 +2,8 @@ package com.dituhui.pea.order.service.impl;
...
@@ -2,8 +2,8 @@ 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.common.DateUtil
s
;
import
com.dituhui.pea.order.common.EngineerUtil
;
import
com.dituhui.pea.order.common.EngineerUtil
s
;
import
com.dituhui.pea.order.dao.CapacityEngineerCalendarDao
;
import
com.dituhui.pea.order.dao.CapacityEngineerCalendarDao
;
import
com.dituhui.pea.order.dao.OrgTeamDao
;
import
com.dituhui.pea.order.dao.OrgTeamDao
;
import
com.dituhui.pea.order.dao.OrgTeamEngineerDao
;
import
com.dituhui.pea.order.dao.OrgTeamEngineerDao
;
...
@@ -34,7 +34,7 @@ import static com.dituhui.pea.order.config.OrderConfig.PATTERN_DATETIME;
...
@@ -34,7 +34,7 @@ import static com.dituhui.pea.order.config.OrderConfig.PATTERN_DATETIME;
public
class
EngineerCalendarServiceImpl
implements
EngineerCalendarService
{
public
class
EngineerCalendarServiceImpl
implements
EngineerCalendarService
{
@Autowired
@Autowired
private
EngineerUtil
engineerUtil
;
private
EngineerUtil
s
engineerUtil
;
@Autowired
@Autowired
private
OrgTeamEngineerDao
orgTeamEngineerDao
;
private
OrgTeamEngineerDao
orgTeamEngineerDao
;
...
@@ -141,7 +141,7 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
...
@@ -141,7 +141,7 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
EngineerCalendarDTO
.
Calendar
calendar
=
new
EngineerCalendarDTO
.
Calendar
();
EngineerCalendarDTO
.
Calendar
calendar
=
new
EngineerCalendarDTO
.
Calendar
();
calendar
.
setDate
(
date
);
calendar
.
setDate
(
date
);
int
dayOfWeek
=
LocalDate
.
parse
(
date
).
getDayOfWeek
().
getValue
();
int
dayOfWeek
=
LocalDate
.
parse
(
date
).
getDayOfWeek
().
getValue
();
calendar
.
setWeek
(
DateUtil
.
toWeekChinese
(
dayOfWeek
));
calendar
.
setWeek
(
DateUtil
s
.
toWeekChinese
(
dayOfWeek
));
EngineerCalendarDTO
.
Content
content
=
new
EngineerCalendarDTO
.
Content
();
EngineerCalendarDTO
.
Content
content
=
new
EngineerCalendarDTO
.
Content
();
List
<
String
>
workdays
=
Arrays
.
asList
(
e
.
getWorkdays
().
split
(
","
));
List
<
String
>
workdays
=
Arrays
.
asList
(
e
.
getWorkdays
().
split
(
","
));
if
(
workdays
.
contains
(
String
.
valueOf
(
dayOfWeek
)))
{
if
(
workdays
.
contains
(
String
.
valueOf
(
dayOfWeek
)))
{
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/EngineerGanttServiceImpl.java
View file @
a438f77
package
com
.
dituhui
.
pea
.
order
.
service
.
impl
;
package
com
.
dituhui
.
pea
.
order
.
service
.
impl
;
import
com.dituhui.pea.common.Result
;
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.CapacityEngineerStatDao
;
import
com.dituhui.pea.order.dao.EngineerInfoDao
;
import
com.dituhui.pea.order.dao.EngineerInfoDao
;
import
com.dituhui.pea.order.dao.OrderAppointmentDao
;
import
com.dituhui.pea.order.dao.OrderAppointmentDao
;
...
@@ -39,7 +39,7 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
...
@@ -39,7 +39,7 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
private
OrderRequestDao
orderRequestDao
;
private
OrderRequestDao
orderRequestDao
;
@Autowired
@Autowired
private
EngineerUtil
engineerUtil
;
private
EngineerUtil
s
engineerUtils
;
@Override
@Override
public
Result
<?>
getEngineersGanttList
(
EngineersGanttDTO
.
Request
reqDTO
)
{
public
Result
<?>
getEngineersGanttList
(
EngineersGanttDTO
.
Request
reqDTO
)
{
...
@@ -85,7 +85,7 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
...
@@ -85,7 +85,7 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
.
setEngineerName
(
engineerInfo
.
getName
())
.
setEngineerName
(
engineerInfo
.
getName
())
.
setGrade
(
engineerInfo
.
getGrade
());
.
setGrade
(
engineerInfo
.
getGrade
());
CapacityEngineerStatEntity
capacityEngineerStat
=
capacityEngineerStatDao
.
getBy
EngineerCodeAndWorkday
(
engineerCode
,
reqDTO
.
getDate
()
);
CapacityEngineerStatEntity
capacityEngineerStat
=
capacityEngineerStatDao
.
getBy
WorkdayAndEngineerCode
(
reqDTO
.
getDate
(),
engineerCode
);
if
(
capacityEngineerStat
==
null
)
{
if
(
capacityEngineerStat
==
null
)
{
log
.
warn
(
"技术员当日的容量数据不存在,{}{}"
,
engineerCode
,
reqDTO
.
getDate
());
log
.
warn
(
"技术员当日的容量数据不存在,{}{}"
,
engineerCode
,
reqDTO
.
getDate
());
}
else
{
}
else
{
...
@@ -108,39 +108,38 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
...
@@ -108,39 +108,38 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
if
(
teamIds
!=
null
&&
teamIds
.
size
()
>
0
)
{
if
(
teamIds
!=
null
&&
teamIds
.
size
()
>
0
)
{
for
(
String
teamId
:
teamIds
)
{
for
(
String
teamId
:
teamIds
)
{
engineerCodes
.
addAll
(
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
)
{
}
else
if
(
groupIds
!=
null
&&
groupIds
.
size
()
>
0
)
{
for
(
String
groupId
:
groupIds
)
{
for
(
String
groupId
:
groupIds
)
{
engineerCodes
.
addAll
(
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
)
{
}
else
if
(
branchIds
!=
null
&&
branchIds
.
size
()
>
0
)
{
for
(
String
branchId
:
branchIds
)
{
for
(
String
branchId
:
branchIds
)
{
engineerCodes
.
addAll
(
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
{
}
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
));
engineerCodes
=
new
ArrayList
<>(
new
HashSet
<>(
engineerCodes
));
if
(
StringUtils
.
isBlank
(
key
))
{
if
(
StringUtils
.
isBlank
(
key
))
{
return
engineerCodes
;
return
engineerCodes
;
}
else
{
}
else
{
// 最后,还需要根据key进行过滤(需要结合数据库表)
// 最后,还需要根据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
)
{
public
Map
<
String
,
OrderRequestEntity
>
getOrdersByOrderIds
(
List
<
String
>
orderIds
)
{
List
<
OrderRequestEntity
>
orders
=
orderRequestDao
.
findAllByOrderIdIn
(
orderIds
);
List
<
OrderRequestEntity
>
orders
=
orderRequestDao
.
findAllByOrderIdIn
(
orderIds
);
return
orders
.
stream
()
return
orders
.
stream
().
collect
(
Collectors
.
toMap
(
OrderRequestEntity:
:
getOrderId
,
order
->
order
));
.
collect
(
Collectors
.
toMap
(
OrderRequestEntity:
:
getOrderId
,
order
->
order
));
}
}
private
List
<?>
getOrderTips
(
String
orderId
)
{
private
List
<?>
getOrderTips
(
String
orderId
)
{
log
.
info
(
"==> getOrderTips: orderId[{}]"
,
orderId
);
//
log.info("==> getOrderTips: orderId[{}]", orderId);
OrderRequestEntity
order
=
orderRequestDao
.
getByOrderId
(
orderId
);
OrderRequestEntity
order
=
orderRequestDao
.
getByOrderId
(
orderId
);
if
(
order
==
null
)
{
if
(
order
==
null
)
{
log
.
error
(
"对应的订单不存在!{}"
,
orderId
);
log
.
error
(
"对应的订单不存在!{}"
,
orderId
);
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrganizationServiceImpl.java
View file @
a438f77
package
com
.
dituhui
.
pea
.
order
.
service
.
impl
;
package
com
.
dituhui
.
pea
.
order
.
service
.
impl
;
import
com.dituhui.pea.common.Result
;
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.dao.*
;
import
com.dituhui.pea.order.dto.*
;
import
com.dituhui.pea.order.dto.*
;
import
com.dituhui.pea.order.entity.*
;
import
com.dituhui.pea.order.entity.*
;
...
@@ -33,7 +33,7 @@ public class OrganizationServiceImpl implements OrganizationService {
...
@@ -33,7 +33,7 @@ public class OrganizationServiceImpl implements OrganizationService {
private
OrgTeamDao
orgTeamDao
;
private
OrgTeamDao
orgTeamDao
;
@Autowired
@Autowired
private
EngineerUtil
engineerUtil
;
private
EngineerUtil
s
engineerUtils
;
@Override
@Override
public
Result
<?>
getOrganizationTree
(
String
levelType
,
String
levelValue
)
{
public
Result
<?>
getOrganizationTree
(
String
levelType
,
String
levelValue
)
{
...
@@ -115,7 +115,7 @@ public class OrganizationServiceImpl implements OrganizationService {
...
@@ -115,7 +115,7 @@ public class OrganizationServiceImpl implements OrganizationService {
@Override
@Override
public
Result
<?>
getEngineersByLevel
(
String
levelType
,
String
levelValue
)
{
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
->
{
List
<
OrganizationEngineersDTO
.
Engineer
>
engineers1
=
engineers
.
stream
().
map
(
entity
->
{
return
new
OrganizationEngineersDTO
.
Engineer
()
return
new
OrganizationEngineersDTO
.
Engineer
()
.
setEngineerCode
(
entity
.
getEngineerCode
())
.
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