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 af74c909
authored
Nov 07, 2023
by
Ren Ping
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/develop' into develop
2 parents
39c7d181
8d77e4b3
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
95 additions
and
27 deletions
project-dispatch/src/main/java/com/dituhui/pea/dispatch/constraint/DispatchConstraintProvider.java
project-dispatch/src/main/java/com/dituhui/pea/dispatch/pojo/Technician.java
project-dispatch/src/main/java/com/dituhui/pea/dispatch/utils/DispatchSolutionUtils.java
project-order/src/main/java/com/dituhui/pea/order/common/CapacityUtils.java
project-order/src/main/java/com/dituhui/pea/order/controller/OrderCreateController.java
project-order/src/main/java/com/dituhui/pea/order/dto/OrderServiceDetailResp.java
project-order/src/main/java/com/dituhui/pea/order/dto/param/CapacityQueryDTO.java
project-order/src/main/java/com/dituhui/pea/order/entity/OrgBranchEntity.java
project-order/src/main/java/com/dituhui/pea/order/entity/OrgClusterEntity.java
project-order/src/main/java/com/dituhui/pea/order/entity/OrgGroupEntity.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderAssignImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderServiceDetailImpl.java
project-dispatch/src/main/java/com/dituhui/pea/dispatch/constraint/DispatchConstraintProvider.java
View file @
af74c90
package
com
.
dituhui
.
pea
.
dispatch
.
constraint
;
import
java.util.List
;
import
org.optaplanner.core.api.score.buildin.hardsoftlong.HardSoftLongScore
;
import
org.optaplanner.core.api.score.stream.Constraint
;
import
org.optaplanner.core.api.score.stream.ConstraintFactory
;
...
...
@@ -54,9 +56,31 @@ public class DispatchConstraintProvider implements ConstraintProvider {
protected
Constraint
technicianTimeWindowsMatch
(
ConstraintFactory
factory
)
{
return
factory
.
forEach
(
Technician
.
class
).
filter
(
// EndTime ==0 表示不起作用
technician
->
technician
.
getEndTime
()
>
0
&&
technician
.
getOffWorkTime
()
>
technician
.
getEndTime
())
.
penalizeLong
(
HardSoftLongScore
.
ONE_HARD
,
technician
->
1
)
technician
->
{
boolean
ret
=
false
;
// 单子的服务时间都在时间窗口内
int
[][]
timeWindows
=
technician
.
getTimeWindows
();
List
<
Customer
>
customers
=
technician
.
getCustomerList
();
if
(
null
!=
timeWindows
&&
timeWindows
.
length
>
0
&&
null
!=
customers
&&
customers
.
size
()
>
0
)
{
for
(
Customer
customer
:
customers
)
{
Integer
arrivalTime
=
customer
.
getArrivalTime
();
if
(
arrivalTime
!=
null
&&
arrivalTime
>
0
)
{
boolean
in
=
false
;
for
(
int
[]
window
:
timeWindows
)
{
if
(
window
[
0
]
<=
arrivalTime
&&
window
[
1
]
>=
arrivalTime
)
{
in
=
true
;
break
;
}
}
if
(!
in
)
{
// 到达时间在日历窗口外,惩罚得分
ret
=
true
;
}
}
}
}
return
ret
;
}).
penalizeLong
(
HardSoftLongScore
.
ONE_HARD
,
technician
->
1
)
.
asConstraint
(
ConstraintNameEnum
.
technicianTimeWindowsMatch
.
name
());
}
...
...
project-dispatch/src/main/java/com/dituhui/pea/dispatch/pojo/Technician.java
View file @
af74c90
...
...
@@ -26,8 +26,16 @@ public class Technician {
private
Depot
depot
;
// 上班时间窗 分钟480-1080 8-18点
private
int
startTime
;
private
int
endTime
;
// private int startTime;
// private int endTime;
/**
* 上班多时间窗
* 时间窗格式:[[起始时间段1,结束时间段1],[起始时间段2,结束时间段2]...]
* 时间格式:从0点开始的分钟数,如早上8点为480.
*/
private
int
[][]
timeWindows
;
// 技能
private
Set
<
String
>
skills
;
...
...
@@ -59,8 +67,7 @@ public class Technician {
this
.
id
=
id
;
this
.
code
=
code
;
this
.
depot
=
depot
;
this
.
startTime
=
startTime
;
this
.
endTime
=
endTime
;
this
.
timeWindows
=
new
int
[][]
{
new
int
[]
{
startTime
,
endTime
}
};
this
.
skills
=
skills
;
this
.
preferredlocationDistanceMap
=
preferredlocationDistanceMap
;
this
.
preferredlocation
=
preferredlocation
;
...
...
@@ -71,8 +78,7 @@ public class Technician {
this
.
id
=
id
;
this
.
code
=
code
;
this
.
depot
=
depot
;
this
.
startTime
=
startTime
;
this
.
endTime
=
endTime
;
this
.
timeWindows
=
new
int
[][]
{
new
int
[]
{
startTime
,
endTime
}
};
this
.
skills
=
skills
;
this
.
maxCount
=
maxCount
;
this
.
maxMinute
=
maxMinute
;
...
...
@@ -85,8 +91,7 @@ public class Technician {
this
.
id
=
id
;
this
.
code
=
code
;
this
.
depot
=
depot
;
this
.
startTime
=
startTime
;
this
.
endTime
=
endTime
;
this
.
timeWindows
=
new
int
[][]
{
new
int
[]
{
startTime
,
endTime
}
};
this
.
skills
=
skills
;
this
.
maxCount
=
maxCount
;
this
.
maxMinute
=
maxMinute
;
...
...
@@ -208,8 +213,8 @@ public class Technician {
@Override
public
String
toString
()
{
return
"Technician{"
+
"id="
+
id
+
", code='"
+
code
+
'\''
+
", depot="
+
depot
+
",
startTime="
+
startTime
+
", endTime="
+
endTime
+
", skills="
+
skills
+
", maxCount="
+
maxCount
+
", maxMinute="
+
maxMinute
return
"Technician{"
+
"id="
+
id
+
", code='"
+
code
+
'\''
+
", depot="
+
depot
+
",
timeWindows="
+
timeWindows
+
", skills="
+
skills
+
", maxCount="
+
maxCount
+
", maxMinute="
+
maxMinute
+
", maxDistanceMeter="
+
maxDistanceMeter
+
'}'
;
}
}
project-dispatch/src/main/java/com/dituhui/pea/dispatch/utils/DispatchSolutionUtils.java
View file @
af74c90
...
...
@@ -63,7 +63,7 @@ public class DispatchSolutionUtils {
AtomicInteger
totalNum
=
new
AtomicInteger
(
0
);
solution
.
getTechnicianList
().
forEach
(
technician
->
{
System
.
out
.
printf
(
"技术员%s(%s) [%s,%s]%n"
,
technician
.
getId
(),
technician
.
getCode
(),
printTime
(
technician
.
get
StartTime
()),
printTime
(
technician
.
getEndTime
()
));
printTime
(
technician
.
get
TimeWindows
()[
0
][
0
]),
printTime
(
technician
.
getTimeWindows
()[
0
][
1
]
));
totalNum
.
addAndGet
(
technician
.
getCustomerList
().
size
());
for
(
Customer
customer
:
technician
.
getCustomerList
())
{
Customer
previousCustomer
=
customer
.
getPreviousCustomer
();
...
...
project-order/src/main/java/com/dituhui/pea/order/common/CapacityUtils.java
View file @
af74c90
...
...
@@ -257,10 +257,13 @@ public class CapacityUtils {
long
remain
=
collect
.
stream
().
mapToLong
(
CapacityEngineerSliceUsedEntity:
:
getCapLeft
).
sum
();
segment
.
setRemain
(
remain
);
segment
.
setStatus
(
totalTakeTime
<=
maxDuration
?
1
:
0
);
long
totalCapacity
=
collect
.
stream
().
mapToLong
(
CapacityEngineerSliceUsedEntity:
:
getCapTotal
).
sum
();
segment
.
setTotalCapacity
(
totalCapacity
);
}
else
{
segment
.
setMaxDuration
(
0
);
segment
.
setRemain
(
0
);
segment
.
setStatus
(
0
);
segment
.
setTotalCapacity
(
0
);
}
return
segment
;
}
...
...
project-order/src/main/java/com/dituhui/pea/order/controller/OrderCreateController.java
View file @
af74c90
...
...
@@ -2,16 +2,24 @@ package com.dituhui.pea.order.controller;
import
com.dituhui.pea.common.BusinessException
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.dto.OrderCreateReqDTO
;
import
com.dituhui.pea.order.dto.CapacityOrderQueryDTO
;
import
com.dituhui.pea.order.dto.param.CapacityQueryDTO
;
import
com.dituhui.pea.order.dto.param.OrderDTO
;
import
com.dituhui.pea.order.service.OrderCreateService
;
import
com.dituhui.pea.order.service.CapacityQueryService
;
import
com.dituhui.pea.order.service.OrderCreateService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.time.LocalDate
;
import
java.time.ZoneId
;
/**
* 工单接口
*/
@RestController
@RequestMapping
(
"/pea-order"
)
public
class
OrderCreateController
{
...
...
@@ -44,14 +52,18 @@ public class OrderCreateController {
return
res
;
}
/**
* 改约容量查询
*
* @param reqDTO 查询参数
* @return 返回日期范围内的容量信息
*/
@PostMapping
(
"/order/service/capacity/query"
)
public
Result
<?>
capacityQuery
(
@Validated
@RequestBody
CapacityOrderQueryDTO
.
Request
reqDTO
)
{
Result
<?>
res
=
null
;
try
{
res
=
capacityQueryService
.
queryMatchCapacityData
(
reqDTO
);
}
catch
(
BusinessException
e
)
{
return
Result
.
failed
(
e
.
getMessage
());
}
return
res
;
public
Result
<
CapacityQueryDTO
.
Result
>
capacityQuery
(
@Validated
@RequestBody
CapacityQueryDTO
.
Request
reqDTO
)
{
//查询日期起止参数限制为一月
LocalDate
startDate
=
reqDTO
.
getBeginDate
().
toInstant
().
atZone
(
ZoneId
.
of
(
"+8"
)).
toLocalDate
();
LocalDate
endDate
=
reqDTO
.
getEndDate
().
toInstant
().
atZone
(
ZoneId
.
of
(
"+8"
)).
toLocalDate
();
return
capacityQueryService
.
matchCapacityData
(
reqDTO
,
reqDTO
.
getServices
(),
reqDTO
.
getLocation
(),
startDate
,
endDate
);
}
}
project-order/src/main/java/com/dituhui/pea/order/dto/OrderServiceDetailResp.java
View file @
af74c90
...
...
@@ -91,6 +91,8 @@ public class OrderServiceDetailResp {
*/
private
String
multipleOrders
;
private
String
beanTags
;
@Data
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
public
static
class
OrderDetail
{
...
...
project-order/src/main/java/com/dituhui/pea/order/dto/param/CapacityQueryDTO.java
View file @
af74c90
...
...
@@ -165,6 +165,11 @@ public class CapacityQueryDTO {
* 剩余容量
*/
private
long
remain
;
/**
* 区间总容量
*/
private
long
totalCapacity
;
}
...
...
project-order/src/main/java/com/dituhui/pea/order/entity/OrgBranchEntity.java
View file @
af74c90
...
...
@@ -77,4 +77,8 @@ public class OrgBranchEntity {
* 帐号状态(0无效 1有效)
*/
private
Integer
status
=
1
;
/**
* 账号中心部门id
*/
private
String
bsDeptId
;
}
project-order/src/main/java/com/dituhui/pea/order/entity/OrgClusterEntity.java
View file @
af74c90
...
...
@@ -70,4 +70,8 @@ public class OrgClusterEntity {
* 最长配件保留时长(天)
*/
private
Integer
reserveTimeMax
=
0
;
/**
* 账号中心部门id
*/
private
String
bsDeptId
;
}
project-order/src/main/java/com/dituhui/pea/order/entity/OrgGroupEntity.java
View file @
af74c90
...
...
@@ -121,4 +121,9 @@ public class OrgGroupEntity {
* 帐号状态(0无效 1有效)
*/
private
Integer
status
=
1
;
/**
* 账号中心部门id
*/
private
String
bsDeptId
;
}
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderAssignImpl.java
View file @
af74c90
...
...
@@ -305,6 +305,9 @@ public class OrderAssignImpl implements OrderAssign {
}
else
if
(
recommend
.
equals
(
"group"
))
{
levelType
=
"group"
;
levelValue
=
order
.
getOrgGroupId
();
}
else
if
(
recommend
.
equals
(
"all"
))
{
levelType
=
"cluster"
;
levelValue
=
order
.
getOrgClusterId
();
}
else
{
return
new
HashSet
<>();
}
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderServiceDetailImpl.java
View file @
af74c90
...
...
@@ -93,6 +93,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
res
.
setIsCutoff
(
order
.
getIsCutoff
());
res
.
setIsSpecialTime
(
order
.
getIsSpecialTime
());
res
.
setMultipleOrders
(
order
.
getMultipleOrders
());
res
.
setBeanTags
(
order
.
getBeanTags
());
return
Result
.
success
(
res
);
}
...
...
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