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 ea051d6f
authored
Nov 07, 2023
by
刘鑫
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of
https://gitlab.dituhui.com/bsh/project/project
into develop
2 parents
b10f663e
51a6ab44
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
14 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/dto/OrderServiceDetailResp.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 @
ea051d6
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 @
ea051d6
...
...
@@ -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 @
ea051d6
...
...
@@ -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/dto/OrderServiceDetailResp.java
View file @
ea051d6
...
...
@@ -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/service/impl/OrderServiceDetailImpl.java
View file @
ea051d6
...
...
@@ -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