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 6cd6bfbe
authored
Nov 08, 2023
by
刘鑫
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(工程师容量): 改派到人容量查询接口逻辑完善
1 parent
1c76361d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
46 deletions
project-order/src/main/java/com/dituhui/pea/order/controller/PeaApiController.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/CapacityQueryServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/controller/PeaApiController.java
View file @
6cd6bfb
...
@@ -5,9 +5,6 @@ import com.dituhui.pea.common.Result;
...
@@ -5,9 +5,6 @@ import com.dituhui.pea.common.Result;
import
com.dituhui.pea.enums.StatusCodeEnum
;
import
com.dituhui.pea.enums.StatusCodeEnum
;
import
com.dituhui.pea.order.common.jackson.DateUtil
;
import
com.dituhui.pea.order.common.jackson.DateUtil
;
import
com.dituhui.pea.order.common.jackson.JsonUtil
;
import
com.dituhui.pea.order.common.jackson.JsonUtil
;
import
com.dituhui.pea.order.dto.param.*
;
import
com.dituhui.pea.order.enums.OrderStatusEnum
;
import
com.dituhui.pea.order.enums.ServiceStatusEnum
;
import
com.dituhui.pea.order.dao.TableCodeCheckDao
;
import
com.dituhui.pea.order.dao.TableCodeCheckDao
;
import
com.dituhui.pea.order.dto.param.BaseDistance
;
import
com.dituhui.pea.order.dto.param.BaseDistance
;
import
com.dituhui.pea.order.dto.param.BaseDistanceParam
;
import
com.dituhui.pea.order.dto.param.BaseDistanceParam
;
...
@@ -43,13 +40,11 @@ import javax.validation.constraints.NotNull;
...
@@ -43,13 +40,11 @@ import javax.validation.constraints.NotNull;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.time.LocalDate
;
import
java.time.LocalDate
;
import
java.time.ZoneId
;
import
java.time.ZoneId
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Objects
;
import
java.util.Random
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
/**
/**
...
@@ -127,15 +122,15 @@ public class PeaApiController {
...
@@ -127,15 +122,15 @@ public class PeaApiController {
.
map
(
source
->
{
.
map
(
source
->
{
TypeCodeCheckTableEntity
brand
=
tableCodeCheckDao
.
findByTypeAndCode
(
"BRAND"
,
source
.
getBrand
());
TypeCodeCheckTableEntity
brand
=
tableCodeCheckDao
.
findByTypeAndCode
(
"BRAND"
,
source
.
getBrand
());
if
(
Objects
.
isNull
(
brand
))
{
if
(
Objects
.
isNull
(
brand
))
{
throw
new
BusinessException
(
"查询不到:"
+
source
.
getBrand
()
+
"对应的品牌"
);
throw
new
BusinessException
(
"查询不到:"
+
source
.
getBrand
()
+
"对应的品牌"
);
}
}
TypeCodeCheckTableEntity
type
=
tableCodeCheckDao
.
findByTypeAndCode
(
"TYPE"
,
source
.
getProductType
());
TypeCodeCheckTableEntity
type
=
tableCodeCheckDao
.
findByTypeAndCode
(
"TYPE"
,
source
.
getProductType
());
if
(
Objects
.
isNull
(
type
))
{
if
(
Objects
.
isNull
(
type
))
{
throw
new
BusinessException
(
"查询不到:"
+
source
.
getProductType
()
+
"对应的产品类型"
);
throw
new
BusinessException
(
"查询不到:"
+
source
.
getProductType
()
+
"对应的产品类型"
);
}
}
TypeCodeCheckTableEntity
skill
=
tableCodeCheckDao
.
findByTypeAndCode
(
"SKILL"
,
source
.
getServiceType
());
TypeCodeCheckTableEntity
skill
=
tableCodeCheckDao
.
findByTypeAndCode
(
"SKILL"
,
source
.
getServiceType
());
if
(
Objects
.
isNull
(
skill
))
{
if
(
Objects
.
isNull
(
skill
))
{
throw
new
BusinessException
(
"查询不到:"
+
source
.
getServiceType
()
+
"对应的技能"
);
throw
new
BusinessException
(
"查询不到:"
+
source
.
getServiceType
()
+
"对应的技能"
);
}
}
CapacityQueryDTO
.
Service
service
=
new
CapacityQueryDTO
.
Service
();
CapacityQueryDTO
.
Service
service
=
new
CapacityQueryDTO
.
Service
();
...
@@ -172,22 +167,11 @@ public class PeaApiController {
...
@@ -172,22 +167,11 @@ public class PeaApiController {
@RequestParam
(
"beginDate"
)
Date
beginDate
,
@RequestParam
(
"beginDate"
)
Date
beginDate
,
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
,
timezone
=
"GMT+8"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
,
timezone
=
"GMT+8"
)
Date
endDate
)
throws
IOException
{
Date
endDate
)
{
ArrayList
<
String
>
strings
=
new
ArrayList
<>();
CapacityQueryDTO
.
PersonalResult
result
=
capacityQueryService
.
queryEngineerCapacity
(
engineerCode
,
strings
.
add
(
half_capacity
);
beginDate
.
toInstant
().
atZone
(
ZoneId
.
of
(
"+8"
)).
toLocalDate
(),
strings
.
add
(
day_capacity
);
endDate
.
toInstant
().
atZone
(
ZoneId
.
of
(
"+8"
)).
toLocalDate
());
strings
.
add
(
half_capacity2
);
strings
.
add
(
date_capacity
);
Random
random
=
new
Random
();
int
i
=
random
.
nextInt
(
4
);
CapacityQueryDTO
.
Result
resultTemp
=
JsonUtil
.
parse
(
strings
.
get
(
i
),
CapacityQueryDTO
.
Result
.
class
).
get
();
CapacityQueryDTO
.
PersonalResult
result
=
new
CapacityQueryDTO
.
PersonalResult
();
result
.
setDatas
(
resultTemp
.
getDatas
());
result
.
setEngineerCode
(
engineerCode
);
return
Result
.
success
(
result
);
return
Result
.
success
(
result
);
}
}
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/CapacityQueryServiceImpl.java
View file @
6cd6bfb
...
@@ -156,7 +156,6 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
...
@@ -156,7 +156,6 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
LocalTime
.
of
(
8
,
0
),
LocalTime
.
of
(
8
,
0
),
LocalTime
.
of
(
18
,
0
)));
LocalTime
.
of
(
18
,
0
)));
LocalDate
currentDate
=
beginDate
;
//定义返回值
//定义返回值
CapacityQueryDTO
.
Result
result
=
new
CapacityQueryDTO
.
Result
();
CapacityQueryDTO
.
Result
result
=
new
CapacityQueryDTO
.
Result
();
result
.
setGroupId
(
groupList
.
get
(
0
));
result
.
setGroupId
(
groupList
.
get
(
0
));
...
@@ -168,6 +167,7 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
...
@@ -168,6 +167,7 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
Semaphore
semaphore
=
new
Semaphore
(
corePoolSize
);
Semaphore
semaphore
=
new
Semaphore
(
corePoolSize
);
List
<
Future
<
CapacityQueryDTO
.
Data
>>
futureDatas
=
new
ArrayList
<>();
List
<
Future
<
CapacityQueryDTO
.
Data
>>
futureDatas
=
new
ArrayList
<>();
LocalDate
currentDate
=
beginDate
;
while
(!
currentDate
.
isAfter
(
endDate
))
{
while
(!
currentDate
.
isAfter
(
endDate
))
{
log
.
info
(
"【matchCapacityData】----------->开始计算{}的容量"
,
currentDate
);
log
.
info
(
"【matchCapacityData】----------->开始计算{}的容量"
,
currentDate
);
Task
task
=
new
Task
(
allFulfillEngineer
,
currentDate
,
halfDayTypeTimeSlice
,
Task
task
=
new
Task
(
allFulfillEngineer
,
currentDate
,
halfDayTypeTimeSlice
,
...
@@ -245,8 +245,37 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
...
@@ -245,8 +245,37 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
@Override
@Override
public
CapacityQueryDTO
.
PersonalResult
queryEngineerCapacity
(
String
engineerCode
,
LocalDate
startDate
,
LocalDate
endDate
)
{
public
CapacityQueryDTO
.
PersonalResult
queryEngineerCapacity
(
String
engineerCode
,
LocalDate
startDate
,
LocalDate
endDate
)
{
//
// 根据工程师编号获取工程师信息
return
null
;
EngineerInfoEntity
engineerInfo
=
engineerInfoDao
.
getByEngineerCode
(
engineerCode
);
if
(
Objects
.
isNull
(
engineerInfo
))
{
throw
new
BusinessException
(
"未查找到工号为"
+
engineerCode
+
"的工程师信息"
);
}
//查询单个工程师日期范围内的技能容量信息 后加和汇总
CopyOnWriteArrayList
<
TimeSliceEntity
>
halfDayTypeTimeSlice
=
new
CopyOnWriteArrayList
<>(
timeSliceDao
.
findByType
(
"HALF_DAY"
));
CopyOnWriteArrayList
<
TimeSliceEntity
>
allDayTypeTimeSlice
=
new
CopyOnWriteArrayList
<>(
timeSliceDao
.
findByType
(
"ALL_DAY"
));
CopyOnWriteArrayList
<
TimeSliceEntity
>
timeSliceEntities
=
new
CopyOnWriteArrayList
<>(
sliceTime
(
LocalDate
.
now
(),
LocalTime
.
of
(
8
,
0
),
LocalTime
.
of
(
18
,
0
)));
LocalDate
currentDate
=
startDate
;
ArrayList
<
CapacityQueryDTO
.
Data
>
resultData
=
new
ArrayList
<>();
while
(!
currentDate
.
isAfter
(
endDate
))
{
log
.
info
(
"【matchCapacityData】----------->开始计算工程师{}在{}的容量"
,
engineerCode
,
currentDate
);
//获取工程师当天不同时间类型的容量数据
List
<
CapacityEngineerSliceUsedEntity
>
engineerTimeSlice
=
engineerSliceUsedCapacityDao
.
findByWorkdayAndEngineerCode
(
DateTimeUtil
.
formatDate
(
currentDate
),
engineerCode
);
CapacityQueryDTO
.
Data
data
=
getData
(
currentDate
,
halfDayTypeTimeSlice
,
1
,
allDayTypeTimeSlice
,
timeSliceEntities
,
engineerTimeSlice
);
resultData
.
add
(
data
);
currentDate
=
currentDate
.
plusDays
(
1
);
}
CapacityQueryDTO
.
PersonalResult
result
=
new
CapacityQueryDTO
.
PersonalResult
();
result
.
setEngineerCode
(
engineerInfo
.
getEngineerCode
());
result
.
setEngineerName
(
engineerInfo
.
getName
());
result
.
setDatas
(
resultData
);
return
result
;
}
}
@Override
@Override
...
@@ -396,28 +425,37 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
...
@@ -396,28 +425,37 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
allEngineerTimeSlice
.
addAll
(
engineerTimeSlice
);
allEngineerTimeSlice
.
addAll
(
engineerTimeSlice
);
}
}
}
}
List
<
CapacityQueryDTO
.
Segment
>
objects
=
new
ArrayList
<>();
return
CapacityQueryServiceImpl
.
getData
(
currentDate
,
halfDayTypeTimeSlice
,
totalTakeTime
,
//计算所有工程师全天天类型容量
allDayTypeTimeSlice
,
timeSliceEntities
,
allEngineerTimeSlice
);
if
(
CollectionUtils
.
isNotEmpty
(
allDayTypeTimeSlice
))
{
}
List
<
CapacityQueryDTO
.
Segment
>
engineerAllDay
=
CapacityUtils
.
getEngineerTypeDay
(
allDayTypeTimeSlice
,
}
allEngineerTimeSlice
,
currentDate
,
totalTakeTime
);
objects
.
addAll
(
engineerAllDay
);
private
static
CapacityQueryDTO
.
Data
getData
(
LocalDate
currentDate
,
List
<
TimeSliceEntity
>
halfDayTypeTimeSlice
,
}
int
totalTakeTime
,
//计算所有工程师半天类型容量
List
<
TimeSliceEntity
>
allDayTypeTimeSlice
,
if
(
CollectionUtils
.
isNotEmpty
(
halfDayTypeTimeSlice
))
{
List
<
TimeSliceEntity
>
timeSliceEntities
,
List
<
CapacityQueryDTO
.
Segment
>
engineerHalfDay
=
CapacityUtils
.
getEngineerTypeDay
(
halfDayTypeTimeSlice
,
List
<
CapacityEngineerSliceUsedEntity
>
allEngineerTimeSlice
)
{
allEngineerTimeSlice
,
currentDate
,
totalTakeTime
);
List
<
CapacityQueryDTO
.
Segment
>
objects
=
new
ArrayList
<>();
objects
.
addAll
(
engineerHalfDay
);
//计算所有工程师全天天类型容量
}
if
(
CollectionUtils
.
isNotEmpty
(
allDayTypeTimeSlice
))
{
//计算所有工程师时间段类型容量
List
<
CapacityQueryDTO
.
Segment
>
engineerAllDay
=
CapacityUtils
.
getEngineerTypeDay
(
allDayTypeTimeSlice
,
List
<
CapacityQueryDTO
.
Segment
>
timeSliceTwoHour
=
CapacityUtils
.
getEngineerTypeDay
(
timeSliceEntities
,
allEngineerTimeSlice
,
currentDate
,
totalTakeTime
);
allEngineerTimeSlice
,
currentDate
,
totalTakeTime
);
objects
.
addAll
(
timeSliceTwoHour
);
objects
.
addAll
(
engineerAllDay
);
CapacityQueryDTO
.
Data
data
=
new
CapacityQueryDTO
.
Data
();
}
data
.
setDate
(
DateUtil
.
toDate
(
currentDate
));
//计算所有工程师半天类型容量
data
.
setSegments
(
objects
);
if
(
CollectionUtils
.
isNotEmpty
(
halfDayTypeTimeSlice
))
{
return
data
;
List
<
CapacityQueryDTO
.
Segment
>
engineerHalfDay
=
CapacityUtils
.
getEngineerTypeDay
(
halfDayTypeTimeSlice
,
allEngineerTimeSlice
,
currentDate
,
totalTakeTime
);
objects
.
addAll
(
engineerHalfDay
);
}
}
//计算所有工程师时间段类型容量
List
<
CapacityQueryDTO
.
Segment
>
timeSliceTwoHour
=
CapacityUtils
.
getEngineerTypeDay
(
timeSliceEntities
,
allEngineerTimeSlice
,
currentDate
,
totalTakeTime
);
objects
.
addAll
(
timeSliceTwoHour
);
CapacityQueryDTO
.
Data
data
=
new
CapacityQueryDTO
.
Data
();
data
.
setDate
(
DateUtil
.
toDate
(
currentDate
));
data
.
setSegments
(
objects
);
return
data
;
}
}
private
SpanInfo
getTimeSpanInfo
(
String
teamId
,
String
date
,
String
timeSpan
,
String
timeSpanDetail
)
{
private
SpanInfo
getTimeSpanInfo
(
String
teamId
,
String
date
,
String
timeSpan
,
String
timeSpanDetail
)
{
...
...
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