Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
HYH.APSJ
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
佟礼
HYH.APSJ
Commits
a0c8a9c1
Commit
a0c8a9c1
authored
Mar 13, 2026
by
Tong Li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重叠
parent
ff8e1628
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
164 additions
and
109 deletions
+164
-109
ScheduleResultDetail.java
...n/java/com/aps/entity/Algorithm/ScheduleResultDetail.java
+1
-1
GeneticDecoder.java
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
+128
-74
MachineCalculator.java
...ain/java/com/aps/service/Algorithm/MachineCalculator.java
+30
-29
RoutingDataService.java
...in/java/com/aps/service/Algorithm/RoutingDataService.java
+2
-2
PlanResultServiceTest.java
src/test/java/com/aps/demo/PlanResultServiceTest.java
+3
-3
No files found.
src/main/java/com/aps/entity/Algorithm/ScheduleResultDetail.java
View file @
a0c8a9c1
...
...
@@ -16,7 +16,7 @@ public class ScheduleResultDetail {
private
int
EndTime
;
// 相对结束时间(秒)
private
double
OneTime
;
// 单件工时
private
double
Quantity
;
// 时间段
private
double
efficiency
=
1
;
//效率
private
List
<
TimeSegment
>
usedSegment
;
...
...
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
View file @
a0c8a9c1
This diff is collapsed.
Click to expand it.
src/main/java/com/aps/service/Algorithm/MachineCalculator.java
View file @
a0c8a9c1
...
...
@@ -10,6 +10,7 @@ import com.aps.service.plan.MachineSchedulerService;
import
com.baomidou.mybatisplus.core.toolkit.StringUtils
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.time.Duration
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
...
...
@@ -272,7 +273,7 @@ public class MachineCalculator {
String
prevtime
,
CopyOnWriteArrayList
<
GAScheduleResult
>
existingTasks
,
double
oneTime
,
double
quantity
,
boolean
checkprevtime
,
boolean
islockMachineTime
,
boolean
isInterrupt
)
{
CopyOnWriteArrayList
<
GAScheduleResult
>
machineTasks
=
null
;
if
(
existingTasks
!=
null
)
{
if
(
existingTasks
!=
null
&&
existingTasks
.
size
()>
0
)
{
machineTasks
=
existingTasks
.
stream
()
.
filter
(
t
->
t
.
getMachineId
()
==
machine
.
getId
())
.
sorted
(
Comparator
.
comparingInt
(
GAScheduleResult:
:
getStartTime
))
...
...
@@ -506,6 +507,7 @@ public class MachineCalculator {
CopyOnWriteArrayList
<
ScheduleResultDetail
>
times
=
new
CopyOnWriteArrayList
<>();
//第一个数据
TimeSegment
shiftfrist
=
timeSegments
.
get
(
0
);
Map
<
Integer
,
Object
>
outMap
=
CreateScheduleResultDetail
(
shiftfrist
,
st
,
remainingTime
,
oneTime
);
...
...
@@ -517,7 +519,7 @@ public class MachineCalculator {
usedSegments
.
addAll
(
usedSegments1
);
}
// 计算有效时间
//中间的数据
CopyOnWriteArrayList
<
TimeSegment
>
timeSegments2
=
new
CopyOnWriteArrayList
<>(
timeSegments
.
subList
(
1
,
timeSegments
.
size
()-
1
));
...
...
@@ -531,7 +533,14 @@ public class MachineCalculator {
time
.
setKey
(
UUID
.
randomUUID
().
toString
());
time
.
setStartTime
((
int
)
ChronoUnit
.
SECONDS
.
between
(
baseTime
,
effectiveStart
));
time
.
setEndTime
((
int
)
ChronoUnit
.
SECONDS
.
between
(
baseTime
,
effectiveend
));
time
.
setQuantity
((
int
)(
processable
/
oneTime
));
BigDecimal
bd
=
new
BigDecimal
(
String
.
valueOf
(
processable
/
oneTime
));
BigDecimal
roundedBd
=
bd
.
setScale
(
4
,
RoundingMode
.
HALF_UP
);
time
.
setQuantity
(
roundedBd
.
doubleValue
());
time
.
setOneTime
(
oneTime
);
time
.
setUsedSegment
(
timeSegments2
);
timeSegments2
.
forEach
(
t
->
t
.
setUsed
(
true
));
...
...
@@ -540,7 +549,7 @@ public class MachineCalculator {
times
.
add
(
time
);
//最后的时间段
TimeSegment
shiftlast
=
timeSegments
.
get
(
timeSegments
.
size
()-
1
);
Map
<
Integer
,
Object
>
outMaplast
=
CreateScheduleResultDetail
(
shiftlast
,
st
,
remainingTime
,
oneTime
);
...
...
@@ -586,7 +595,12 @@ public class MachineCalculator {
time
.
setStartTime
(
Math
.
abs
((
int
)
ChronoUnit
.
SECONDS
.
between
(
baseTime
,
effectiveStart
)));
time
.
setEndTime
(
Math
.
abs
((
int
)
ChronoUnit
.
SECONDS
.
between
(
baseTime
,
currentTime
)));
time
.
setQuantity
((
int
)(
processable
/
oneTime
));
time
.
setEfficiency
(
shift
.
getEfficiency
());
BigDecimal
bd
=
new
BigDecimal
(
String
.
valueOf
(
processable
/
oneTime
));
BigDecimal
roundedBd
=
bd
.
setScale
(
4
,
RoundingMode
.
HALF_UP
);
time
.
setQuantity
(
roundedBd
.
doubleValue
());
time
.
setOneTime
(
oneTime
);
Map
<
Integer
,
Object
>
outMap
=
new
HashMap
<>();
outMap
.
put
(
1
,
remainingTime
);
...
...
@@ -737,7 +751,7 @@ public class MachineCalculator {
if
(
currentTotal
>=
requiredMinutes
)
{
//
✔️
总时长满足,尝试往前减索引,找「最小满足索引」(减少后续裁剪的工作量)
// 总时长满足,尝试往前减索引,找「最小满足索引」(减少后续裁剪的工作量)
if
(
targetIndex
>
0
)
{
double
prevTotal
=
calculateTotalMinutesByIndex
(
availableSegments
,
currentTime
,
targetIndex
-
1
);
if
(
prevTotal
>=
requiredMinutes
)
{
...
...
@@ -750,7 +764,7 @@ public class MachineCalculator {
double
syday
=
(
int
)
Math
.
ceil
((
requiredMinutes
-
currentTotal
)/(
double
)
ONE_DAY_MINUTES
);
//
❌
总时长不足,往后加索引(每次加5,大步前进,加快逼近速度)
// 总时长不足,往后加索引(每次加5,大步前进,加快逼近速度)
targetIndex
+=
Math
.
max
(
syday
,
5
);
if
(
targetIndex
>=
totalSegmentCount
)
{
// 所有片段总时长不足,抛出异常
...
...
@@ -1026,6 +1040,7 @@ public class MachineCalculator {
LocalDateTime
taskStart
=
baseTime
.
plusSeconds
(
t
.
getStartTime
());
return
taskStart
.
isAfter
(
finalPrevEnd
)
&&
taskStart
.
isBefore
(
shiftStart
);
});
if
(!
hasTask
)
{
// 检查班次间维修窗口
if
(
machine
.
getMaintenanceWindows
()
!=
null
)
{
...
...
@@ -1107,9 +1122,9 @@ public class MachineCalculator {
if
(
slot
==
null
)
{
return
null
;
}
int
processingTime1
=(
int
)
Math
.
ceil
(
processingTime
/
slot
.
getEfficiency
());
// 计算候选开始/结束时间(当前时间往前推加工时长)
LocalDateTime
startCandidate
=
currentTime
.
minusSeconds
(
processingTime
);
LocalDateTime
startCandidate
=
currentTime
.
minusSeconds
(
processingTime
1
);
LocalDateTime
endCandidate
=
currentTime
;
// 检查是否在可用时间段内
...
...
@@ -1225,8 +1240,8 @@ public class MachineCalculator {
.
filter
(
t
->
baseTime
.
plusSeconds
(
t
.
getStartTime
()).
isAfter
(
shiftStart
)
&&
baseTime
.
plusSeconds
(
t
.
getStartTime
()).
isBefore
(
finalPrevEnd
))
.
findFirst
();
if
(
task
.
isPresent
()
)
{
boolean
hasTask
=
CheckTask
(
machine
,
machineTasks
,
prevEnd
,
shiftStart
);
if
(
hasTask
)
{
// 班次间有任务,重置状态重新查找
currentTime
=
shiftStart
;
remainingTime
=
processingTime
;
...
...
@@ -1236,23 +1251,6 @@ public class MachineCalculator {
}
}
// 检查维护窗口
if
(
machine
.
getMaintenanceWindows
()
!=
null
&&
!
machine
.
getMaintenanceWindows
().
isEmpty
())
{
LocalDateTime
finalPrevEnd
=
prevEnd
;
Optional
<
MaintenanceWindow
>
maintenanceTask
=
machine
.
getMaintenanceWindows
().
stream
()
.
filter
(
t
->
t
.
getStartTime
().
isAfter
(
shiftStart
)
&&
t
.
getStartTime
().
isBefore
(
finalPrevEnd
))
.
findFirst
();
if
(
maintenanceTask
.
isPresent
())
{
// 班次间有维护任务,重置状态重新查找
currentTime
=
shiftStart
;
remainingTime
=
processingTime
;
prevEnd
=
LocalDateTime
.
of
(
2000
,
1
,
1
,
0
,
0
);
times
.
clear
();
continue
;
}
}
}
// 调整班次有效结束时间(不超过当前时间)
...
...
@@ -1262,11 +1260,14 @@ public class MachineCalculator {
Duration
availableDuration
=
Duration
.
between
(
shiftStart
,
effectiveEnd
);
long
availableMinutes
=
availableDuration
.
getSeconds
();
// 当前班次可处理的时长(不超过剩余需要的时长)
int
processableMinutes
=
(
int
)
Math
.
min
(
remainingTime
,
availableMinutes
);
long
availableSeconds_e
=
Math
.
round
(
processableMinutes
/
shift
.
getEfficiency
())
;
// 计算当前班次的有效开始时间
LocalDateTime
effectiveStart
=
effectiveEnd
.
minusSeconds
(
processableMinutes
);
LocalDateTime
effectiveStart
=
effectiveEnd
.
minusSeconds
(
availableSeconds_e
);
prevEnd
=
effectiveStart
;
// 更新上一班次结束时间
remainingTime
-=
processableMinutes
;
// 剩余时长递减
currentTime
=
effectiveStart
;
// 更新当前时间,继续循环
...
...
src/main/java/com/aps/service/Algorithm/RoutingDataService.java
View file @
a0c8a9c1
...
...
@@ -98,12 +98,12 @@ public class RoutingDataService {
Map
<
Integer
,
Object
>
list
=
new
HashMap
<>();
List
<
String
>
soutceExecId
=
ProdOrderProcesss
.
stream
()
.
map
(
ProdOrderProcess:
:
getExecId
)
.
distinct
()
// 提取Exec_ID
//
.distinct() // 提取Exec_ID
.
collect
(
Collectors
.
toList
());
List
<
String
>
targetExecId
=
ProdOrderProcesss
.
stream
()
.
map
(
ProdOrderProcess:
:
getTargetExecId
)
.
distinct
()
// 提取TARGET_Exec_ID
//
.distinct() // 提取TARGET_Exec_ID
.
collect
(
Collectors
.
toList
());
List
<
String
>
ExecIdNoChild
=
ProdProcessExecs
.
stream
()
...
...
src/test/java/com/aps/demo/PlanResultServiceTest.java
View file @
a0c8a9c1
...
...
@@ -42,7 +42,7 @@ public class PlanResultServiceTest {
// planResultService.execute2("5475E00B844847ACB6DC20227967BA2F");
// planResultService.execute2("00E0C5D3E4AD4F36B56C39395906618D");
planResultService
.
execute2
(
"92BB773E1E2447C99D8176C991D5C9D2"
);
//
planResultService.execute2("92BB773E1E2447C99D8176C991D5C9D2");
// planResultService.execute2("265F24B6DF3C40E4B17D193B0CC8AAF2");
// LocalDateTime t= LocalDateTime.of(2026, 02, 14, 1, 25, 52);
// List<Integer> opids=new ArrayList<>();//BCA6FA43FFA444D3952CF8F6E1EA291B
...
...
@@ -56,8 +56,8 @@ public class PlanResultServiceTest {
// maintenanceWindow.setEndTime(LocalDateTime.of(2025, 9, 19, 0, 0, 0));
// planResultService.AddMaintenanceWindow("5475E00B844847ACB6DC20227967BA2F",2488l,maintenanceWindow);
// // planResultService.DelOperation("B6AE363FF5044DDF8DECE32D5FE0F7EA",7);
//
planResultService.SpiltOrder("A41D662EE0764D008173C5A0E42B15F6","5f9d5383-b89a-4a4f-8805-2f617c711968",new Double[]{500d, 500d});
planResultService
.
SpiltOperation
(
"92BB773E1E2447C99D8176C991D5C9D2"
,
1
,
new
Double
[]{
50
d
,
50
d
});
//
planResultService.SpiltOrder("A41D662EE0764D008173C5A0E42B15F6","5f9d5383-b89a-4a4f-8805-2f617c711968",new Double[]{500d, 500d});
}
@Test
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment