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
a84189b4
Commit
a84189b4
authored
Mar 26, 2026
by
DESKTOP-VKRD9QF\Administration
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
滚动排产修改
parent
503590db
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
231 additions
and
50 deletions
+231
-50
LockedOrderProcessorService.java
...ava/com/aps/service/plan/LockedOrderProcessorService.java
+73
-4
PlanResultService.java
src/main/java/com/aps/service/plan/PlanResultService.java
+158
-46
No files found.
src/main/java/com/aps/service/plan/LockedOrderProcessorService.java
View file @
a84189b4
...
@@ -2,10 +2,7 @@ package com.aps.service.plan;
...
@@ -2,10 +2,7 @@ package com.aps.service.plan;
import
com.aps.common.util.ProductionDeepCopyUtil
;
import
com.aps.common.util.ProductionDeepCopyUtil
;
import
com.aps.common.util.redis.RedisUtils
;
import
com.aps.common.util.redis.RedisUtils
;
import
com.aps.entity.Algorithm.Chromosome
;
import
com.aps.entity.Algorithm.*
;
import
com.aps.entity.Algorithm.GAScheduleResult
;
import
com.aps.entity.Algorithm.GlobalOperationInfo
;
import
com.aps.entity.Algorithm.ScheduleResultDetail
;
import
com.aps.entity.ApsTimeConfig
;
import
com.aps.entity.ApsTimeConfig
;
import
com.aps.entity.Dispatch
;
import
com.aps.entity.Dispatch
;
import
com.aps.entity.MesShiftWorkSched
;
import
com.aps.entity.MesShiftWorkSched
;
...
@@ -546,10 +543,12 @@ public class LockedOrderProcessorService {
...
@@ -546,10 +543,12 @@ public class LockedOrderProcessorService {
.
orElse
(
0
);
.
orElse
(
0
);
int
nextAvailableId
=
maxExistingId
+
1
;
int
nextAvailableId
=
maxExistingId
+
1
;
Map
<
Integer
,
Integer
>
lockedEntryIdMapping
=
new
HashMap
<>();
// 为锁定期Entry重新分配ID
// 为锁定期Entry重新分配ID
for
(
Entry
lockedEntry
:
data
.
entries
.
values
())
{
for
(
Entry
lockedEntry
:
data
.
entries
.
values
())
{
int
oldId
=
lockedEntry
.
getId
();
int
oldId
=
lockedEntry
.
getId
();
lockedEntryIdMapping
.
put
(
oldId
,
nextAvailableId
);
lockedEntry
.
setId
(
nextAvailableId
);
lockedEntry
.
setId
(
nextAvailableId
);
// 更新对应的GAScheduleResult的operationId(包括result和resultOld)
// 更新对应的GAScheduleResult的operationId(包括result和resultOld)
...
@@ -577,6 +576,76 @@ public class LockedOrderProcessorService {
...
@@ -577,6 +576,76 @@ public class LockedOrderProcessorService {
nextAvailableId
++;
nextAvailableId
++;
}
}
// 同步更新锁定期Entry内部依赖中的工序ID引用(仅修正本批次重分配的ID)
for
(
Entry
lockedEntry
:
data
.
entries
.
values
())
{
if
(
lockedEntry
.
getPrevEntryIds
()
!=
null
)
{
for
(
OperationDependency
dep
:
lockedEntry
.
getPrevEntryIds
())
{
if
(
dep
==
null
)
{
continue
;
}
Integer
newPrev
=
lockedEntryIdMapping
.
get
(
dep
.
getPrevOperationId
());
if
(
newPrev
!=
null
)
{
dep
.
setPrevOperationId
(
newPrev
);
}
Integer
newNext
=
lockedEntryIdMapping
.
get
(
dep
.
getNextOperationId
());
if
(
newNext
!=
null
)
{
dep
.
setNextOperationId
(
newNext
);
}
}
}
if
(
lockedEntry
.
getNextEntryIds
()
!=
null
)
{
for
(
OperationDependency
dep
:
lockedEntry
.
getNextEntryIds
())
{
if
(
dep
==
null
)
{
continue
;
}
Integer
newPrev
=
lockedEntryIdMapping
.
get
(
dep
.
getPrevOperationId
());
if
(
newPrev
!=
null
)
{
dep
.
setPrevOperationId
(
newPrev
);
}
Integer
newNext
=
lockedEntryIdMapping
.
get
(
dep
.
getNextOperationId
());
if
(
newNext
!=
null
)
{
dep
.
setNextOperationId
(
newNext
);
}
}
}
}
// 同步更新锁定期Entry内部依赖中的工序ID引用(仅修正本批次重分配的ID)
for
(
Entry
lockedEntry
:
data
.
entries
.
values
())
{
if
(
lockedEntry
.
getPrevEntryIds
()
!=
null
)
{
for
(
OperationDependency
dep
:
lockedEntry
.
getPrevEntryIds
())
{
if
(
dep
==
null
)
{
continue
;
}
Integer
newPrev
=
lockedEntryIdMapping
.
get
(
dep
.
getPrevOperationId
());
if
(
newPrev
!=
null
)
{
dep
.
setPrevOperationId
(
newPrev
);
}
Integer
newNext
=
lockedEntryIdMapping
.
get
(
dep
.
getNextOperationId
());
if
(
newNext
!=
null
)
{
dep
.
setNextOperationId
(
newNext
);
}
}
}
if
(
lockedEntry
.
getNextEntryIds
()
!=
null
)
{
for
(
OperationDependency
dep
:
lockedEntry
.
getNextEntryIds
())
{
if
(
dep
==
null
)
{
continue
;
}
Integer
newPrev
=
lockedEntryIdMapping
.
get
(
dep
.
getPrevOperationId
());
if
(
newPrev
!=
null
)
{
dep
.
setPrevOperationId
(
newPrev
);
}
Integer
newNext
=
lockedEntryIdMapping
.
get
(
dep
.
getNextOperationId
());
if
(
newNext
!=
null
)
{
dep
.
setNextOperationId
(
newNext
);
}
}
}
}
chromosome
.
getAllOperations
().
addAll
(
data
.
entries
.
values
());
chromosome
.
getAllOperations
().
addAll
(
data
.
entries
.
values
());
log
.
debug
(
"成功添加 {} 个锁定期Entry到allOperations中,大小从{}变为{},ID范围: {}-{}"
,
log
.
debug
(
"成功添加 {} 个锁定期Entry到allOperations中,大小从{}变为{},ID范围: {}-{}"
,
data
.
entries
.
size
(),
beforeEntrySize
,
chromosome
.
getAllOperations
().
size
(),
data
.
entries
.
size
(),
beforeEntrySize
,
chromosome
.
getAllOperations
().
size
(),
...
...
src/main/java/com/aps/service/plan/PlanResultService.java
View file @
a84189b4
...
@@ -1288,6 +1288,10 @@ public class PlanResultService {
...
@@ -1288,6 +1288,10 @@ public class PlanResultService {
GlobalParam
globalParam
=
new
GlobalParam
();
GlobalParam
globalParam
=
new
GlobalParam
();
Chromosome
chromosome
=
_sceneService
.
loadChromosomeFromFile
(
SceneId
);
Chromosome
chromosome
=
_sceneService
.
loadChromosomeFromFile
(
SceneId
);
// 拖拽前清理历史工单在设备上的静态占位段,确保历史工单移动后可释放产能
int
releasedCount
=
releaseLockedOccupancyForDrag
(
chromosome
);
// WriteScheduleSummary(chromosome);
// WriteScheduleSummary(chromosome);
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
(
materialRequirementService
,
this
);
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
(
materialRequirementService
,
this
);
...
@@ -1298,6 +1302,114 @@ public class PlanResultService {
...
@@ -1298,6 +1302,114 @@ public class PlanResultService {
_sceneService
.
saveChromosomeToFile
(
chromosome
,
SceneId
);
_sceneService
.
saveChromosomeToFile
(
chromosome
,
SceneId
);
return
chromosome
;
return
chromosome
;
}
}
/**
* 释放历史工单占用段(拖拽前调用)
*/
private
int
releaseLockedOccupancyForDrag
(
Chromosome
chromosome
)
{
if
(
chromosome
==
null
||
chromosome
.
getInitMachines
()
==
null
||
chromosome
.
getInitMachines
().
isEmpty
())
{
return
0
;
}
int
releasedCount
=
0
;
for
(
Machine
machine
:
chromosome
.
getInitMachines
())
{
if
(
machine
==
null
||
machine
.
getAvailability
()
==
null
||
machine
.
getAvailability
().
isEmpty
())
{
continue
;
}
for
(
TimeSegment
segment
:
machine
.
getAvailability
())
{
if
(
segment
==
null
)
{
continue
;
}
boolean
lockedOccupyKey
=
segment
.
getKey
()
!=
null
&&
segment
.
getKey
().
startsWith
(
"LOCKED_OCCUPY_"
);
boolean
usedRegularOrMaintenance
=
segment
.
isUsed
()
&&
(
segment
.
getType
()
==
SegmentType
.
REGULAR
||
segment
.
getType
()
==
SegmentType
.
MAINTENANCE
);
if
(
lockedOccupyKey
||
usedRegularOrMaintenance
)
{
releasedCount
++;
segment
.
setUsed
(
false
);
segment
.
setType
(
SegmentType
.
REGULAR
);
if
(
lockedOccupyKey
)
{
segment
.
setKey
(
UUID
.
randomUUID
().
toString
());
}
}
}
machine
.
getAvailability
().
sort
(
Comparator
.
comparing
(
TimeSegment:
:
getStart
));
}
return
releasedCount
;
}
private
long
countMachineAvailabilitySegments
(
Chromosome
chromosome
,
Long
machineId
)
{
if
(
chromosome
==
null
||
machineId
==
null
||
chromosome
.
getInitMachines
()
==
null
)
{
return
0
;
}
return
chromosome
.
getInitMachines
().
stream
()
.
filter
(
Objects:
:
nonNull
)
.
filter
(
m
->
m
.
getId
()
==
machineId
)
.
findFirst
()
.
map
(
m
->
m
.
getAvailability
()
==
null
?
0L
:
(
long
)
m
.
getAvailability
().
size
())
.
orElse
(
0L
);
}
private
long
countMachineUsedMaintenanceSegments
(
Chromosome
chromosome
,
Long
machineId
)
{
if
(
chromosome
==
null
||
machineId
==
null
||
chromosome
.
getInitMachines
()
==
null
)
{
return
0
;
}
return
chromosome
.
getInitMachines
().
stream
()
.
filter
(
Objects:
:
nonNull
)
.
filter
(
m
->
m
.
getId
()
==
machineId
)
.
findFirst
()
.
map
(
m
->
m
.
getAvailability
()
==
null
?
0L
:
m
.
getAvailability
().
stream
()
.
filter
(
Objects:
:
nonNull
)
.
filter
(
seg
->
seg
.
getType
()
==
SegmentType
.
MAINTENANCE
&&
seg
.
isUsed
())
.
count
())
.
orElse
(
0L
);
}
private
long
countMachineUsedSegments
(
Chromosome
chromosome
,
Long
machineId
,
SegmentType
type
)
{
if
(
chromosome
==
null
||
machineId
==
null
||
chromosome
.
getInitMachines
()
==
null
)
{
return
0
;
}
return
chromosome
.
getInitMachines
().
stream
()
.
filter
(
Objects:
:
nonNull
)
.
filter
(
m
->
m
.
getId
()
==
machineId
)
.
findFirst
()
.
map
(
m
->
m
.
getAvailability
()
==
null
?
0L
:
m
.
getAvailability
().
stream
()
.
filter
(
Objects:
:
nonNull
)
.
filter
(
TimeSegment:
:
isUsed
)
.
filter
(
seg
->
type
==
null
||
seg
.
getType
()
==
type
)
.
count
())
.
orElse
(
0L
);
}
private
String
machineSegmentSnapshot
(
Chromosome
chromosome
,
Long
machineId
,
int
limit
)
{
if
(
chromosome
==
null
||
machineId
==
null
||
chromosome
.
getInitMachines
()
==
null
)
{
return
"[]"
;
}
Machine
machine
=
chromosome
.
getInitMachines
().
stream
()
.
filter
(
Objects:
:
nonNull
)
.
filter
(
m
->
m
.
getId
()
==
machineId
)
.
findFirst
()
.
orElse
(
null
);
if
(
machine
==
null
||
machine
.
getAvailability
()
==
null
||
machine
.
getAvailability
().
isEmpty
())
{
return
"[]"
;
}
return
machine
.
getAvailability
().
stream
()
.
filter
(
Objects:
:
nonNull
)
.
sorted
(
Comparator
.
comparing
(
TimeSegment:
:
getStart
))
.
limit
(
Math
.
max
(
limit
,
1
))
.
map
(
seg
->
String
.
format
(
"%s|used=%s|%s~%s"
,
seg
.
getType
(),
seg
.
isUsed
(),
seg
.
getStart
(),
seg
.
getEnd
()))
.
collect
(
Collectors
.
joining
(
"; "
));
}
public
Chromosome
Move
(
String
SceneId
,
List
<
Integer
>
opId
,
LocalDateTime
newStartTime
,
public
Chromosome
Move
(
String
SceneId
,
List
<
Integer
>
opId
,
LocalDateTime
newStartTime
,
Long
newMachineId
,
int
lockStartTime
)
{
Long
newMachineId
,
int
lockStartTime
)
{
...
...
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