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
94b84404
Commit
94b84404
authored
Jan 08, 2026
by
Tong Li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除
parent
a3632e76
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
14 deletions
+38
-14
GeneticAlgorithm.java
...main/java/com/aps/service/Algorithm/GeneticAlgorithm.java
+1
-1
GeneticDecoder.java
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
+1
-1
MachineCalculator.java
...ain/java/com/aps/service/Algorithm/MachineCalculator.java
+4
-4
ScheduleOperationService.java
...a/com/aps/service/Algorithm/ScheduleOperationService.java
+29
-6
PlanResultServiceTest.java
src/test/java/com/aps/demo/PlanResultServiceTest.java
+3
-2
No files found.
src/main/java/com/aps/service/Algorithm/GeneticAlgorithm.java
View file @
94b84404
...
@@ -292,7 +292,7 @@ public class GeneticAlgorithm {
...
@@ -292,7 +292,7 @@ public class GeneticAlgorithm {
GeneticDecoder
decoder
=
new
GeneticDecoder
(
_GlobalParam
,
param
.
getBaseTime
(),
machines
,
orders
,
materials
,
machineScheduler
,
orderMaterials
);
GeneticDecoder
decoder
=
new
GeneticDecoder
(
_GlobalParam
,
param
.
getBaseTime
(),
machines
,
orders
,
materials
,
machineScheduler
,
orderMaterials
);
if
(
population
!=
null
&&
population
.
size
()>
0
)
{
if
(
population
!=
null
&&
population
.
size
()>
0
)
{
population
.
forEach
(
chromosome
->
{
population
.
parallelStream
().
forEach
(
chromosome
->
{
chromosome
.
setResult
(
new
ArrayList
<>());
chromosome
.
setResult
(
new
ArrayList
<>());
// 假设Machine类有拷贝方法,或使用MapStruct等工具进行映射
// 假设Machine类有拷贝方法,或使用MapStruct等工具进行映射
...
...
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
View file @
94b84404
...
@@ -70,7 +70,7 @@ public class GeneticDecoder {
...
@@ -70,7 +70,7 @@ public class GeneticDecoder {
FileHelper
.
writeLogFile
(
"解码-----------开始-------"
+
chromosome
.
getID
()+
":"
+
cacheKey
);
FileHelper
.
writeLogFile
(
"解码-----------开始-------"
+
chromosome
.
getID
()+
":"
+
cacheKey
);
_allOperations
=
chromosome
.
getAllOperations
();
_allOperations
=
chromosome
.
getAllOperations
();
if
(
orderMaterials
!=
null
&&
orderMaterials
.
size
()>
0
)
{
if
(
orderMaterials
!=
null
&&
orderMaterials
.
size
()>
0
&&
_globalParam
.
isIsCheckSf
()
)
{
CreateNewOpSequence
(
chromosome
);
CreateNewOpSequence
(
chromosome
);
}
}
...
...
src/main/java/com/aps/service/Algorithm/MachineCalculator.java
View file @
94b84404
...
@@ -189,9 +189,6 @@ public class MachineCalculator {
...
@@ -189,9 +189,6 @@ public class MachineCalculator {
LocalDateTime
shiftStart
=
shift
.
getStart
();
LocalDateTime
shiftStart
=
shift
.
getStart
();
LocalDateTime
shiftEnd
=
shift
.
getEnd
();
LocalDateTime
shiftEnd
=
shift
.
getEnd
();
// 计算有效时间
// 计算有效时间
LocalDateTime
effectiveStart
=
st
.
isAfter
(
shiftStart
)
?
st
:
shiftStart
;
LocalDateTime
effectiveStart
=
st
.
isAfter
(
shiftStart
)
?
st
:
shiftStart
;
long
availableSeconds
=
ChronoUnit
.
SECONDS
.
between
(
effectiveStart
,
shiftEnd
);
long
availableSeconds
=
ChronoUnit
.
SECONDS
.
between
(
effectiveStart
,
shiftEnd
);
...
@@ -237,7 +234,10 @@ i++;
...
@@ -237,7 +234,10 @@ i++;
boolean
requireContinuous
)
{
boolean
requireContinuous
)
{
List
<
TimeSegment
>
availableSegments
=
new
ArrayList
<>();
List
<
TimeSegment
>
availableSegments
=
new
ArrayList
<>();
LocalDateTime
current
=
start
;
LocalDateTime
current
=
start
;
if
(
requiredMinutes
>
3600
*
3999
)
{
int
i
=
0
;
}
// 预先排序设备可用片段,避免后续遍历混乱
// 预先排序设备可用片段,避免后续遍历混乱
List
<
TimeSegment
>
allUseTimeSegment
=
machine
.
getAvailability
().
stream
()
List
<
TimeSegment
>
allUseTimeSegment
=
machine
.
getAvailability
().
stream
()
.
filter
(
slot
->
!
slot
.
isUsed
()
&&
slot
.
getType
()
!=
SegmentType
.
MAINTENANCE
)
.
filter
(
slot
->
!
slot
.
isUsed
()
&&
slot
.
getType
()
!=
SegmentType
.
MAINTENANCE
)
...
...
src/main/java/com/aps/service/Algorithm/ScheduleOperationService.java
View file @
94b84404
...
@@ -12,6 +12,7 @@ import org.springframework.context.annotation.ScopeMetadata;
...
@@ -12,6 +12,7 @@ import org.springframework.context.annotation.ScopeMetadata;
import
javax.xml.transform.Result
;
import
javax.xml.transform.Result
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
java.util.stream.IntStream
;
import
java.util.stream.IntStream
;
...
@@ -740,6 +741,7 @@ Integer newMachineId1=newMachineId.intValue();
...
@@ -740,6 +741,7 @@ Integer newMachineId1=newMachineId.intValue();
GroupResult
groupResult
=
OperatRels
.
get
(
targetOp
.
GroupId
-
1
);
GroupResult
groupResult
=
OperatRels
.
get
(
targetOp
.
GroupId
-
1
);
List
<
NodeInfo
>
nodeInfoList
=
groupResult
.
getNodeInfoList
();
List
<
NodeInfo
>
nodeInfoList
=
groupResult
.
getNodeInfoList
();
List
<
GlobalOperationInfo
>
globalOpList
=
chromosome
.
getGlobalOpList
();
nodeInfoList
=
groupResult
.
getNodeInfoList
();
nodeInfoList
=
groupResult
.
getNodeInfoList
();
for
(
Entry
entry
:
entrys
)
{
for
(
Entry
entry
:
entrys
)
{
...
@@ -779,7 +781,11 @@ Integer newMachineId1=newMachineId.intValue();
...
@@ -779,7 +781,11 @@ Integer newMachineId1=newMachineId.intValue();
if
(
info
!=
null
)
{
if
(
info
!=
null
)
{
info
.
setSequence
(
node
.
getGroupSerial
());
info
.
setSequence
(
node
.
getGroupSerial
());
info
.
setOp
(
entry
);
}
}
}
else
{
}
else
{
if
(
StringUtils
.
isBlank
(
entry
.
getMainId
()))
{
if
(
StringUtils
.
isBlank
(
entry
.
getMainId
()))
{
//拆分的工序数量补齐到其他的
//拆分的工序数量补齐到其他的
...
@@ -789,6 +795,11 @@ Integer newMachineId1=newMachineId.intValue();
...
@@ -789,6 +795,11 @@ Integer newMachineId1=newMachineId.intValue();
.
orElse
(
null
);
.
orElse
(
null
);
if
(
main
!=
null
)
{
if
(
main
!=
null
)
{
main
.
setQuantity
(
main
.
getQuantity
()
+
entry
.
getQuantity
());
main
.
setQuantity
(
main
.
getQuantity
()
+
entry
.
getQuantity
());
GlobalOperationInfo
operationInfo
=
globalOpList
.
stream
()
.
filter
(
i
->
i
.
getOp
().
getId
()
==
main
.
getId
())
.
findFirst
()
.
orElseThrow
(()
->
new
NoSuchElementException
(
"Global operation not found: "
+
entry
.
getId
()));
operationInfo
.
setOp
(
main
);
}
}
}
}
...
@@ -803,7 +814,6 @@ Integer newMachineId1=newMachineId.intValue();
...
@@ -803,7 +814,6 @@ Integer newMachineId1=newMachineId.intValue();
chromosome
.
getOperationSequencing
().
remove
(
OperationIndex
.
getAsInt
());
chromosome
.
getOperationSequencing
().
remove
(
OperationIndex
.
getAsInt
());
List
<
GlobalOperationInfo
>
globalOpList
=
chromosome
.
getGlobalOpList
();
int
globalOpIndex
=
IntStream
.
range
(
0
,
globalOpList
.
size
())
int
globalOpIndex
=
IntStream
.
range
(
0
,
globalOpList
.
size
())
.
filter
(
i
->
globalOpList
.
get
(
i
).
getOp
().
getId
()
==
opId
)
.
filter
(
i
->
globalOpList
.
get
(
i
).
getOp
().
getId
()
==
opId
)
...
@@ -814,6 +824,15 @@ Integer newMachineId1=newMachineId.intValue();
...
@@ -814,6 +824,15 @@ Integer newMachineId1=newMachineId.intValue();
chromosome
.
getMachineSelection
().
remove
(
globalOpIndex
);
chromosome
.
getMachineSelection
().
remove
(
globalOpIndex
);
globalOpList
.
remove
(
globalOpIndex
);
globalOpList
.
remove
(
globalOpIndex
);
AtomicInteger
globalOpId
=
new
AtomicInteger
(
0
);
globalOpList
.
forEach
(
t
->
{
t
.
setGlobalOpId
(
globalOpId
.
getAndIncrement
());
});
List
<
Entry
>
operations
=
chromosome
.
getAllOperations
();
List
<
Entry
>
operations
=
chromosome
.
getAllOperations
();
IntStream
.
range
(
0
,
operations
.
size
())
IntStream
.
range
(
0
,
operations
.
size
())
...
@@ -876,11 +895,15 @@ Integer newMachineId1=newMachineId.intValue();
...
@@ -876,11 +895,15 @@ Integer newMachineId1=newMachineId.intValue();
ScheduleResults
.
remove
(
OperationIndex1
.
getAsInt
());
ScheduleResults
.
remove
(
OperationIndex1
.
getAsInt
());
}
}
int
i
=
0
;
for
(
GlobalOperationInfo
globalOp
:
globalOpList
)
{
globalOp
.
setGlobalOpId
(
i
);
AtomicInteger
globalOpId
=
new
AtomicInteger
(
0
);
i
++;
globalOpList
.
forEach
(
t
->
{
}
t
.
setGlobalOpId
(
globalOpId
.
getAndIncrement
());
});
// chromosome.getOperatRel().remove(GroupId-1);
// chromosome.getOperatRel().remove(GroupId-1);
orders
.
remove
(
sourceorder
);
orders
.
remove
(
sourceorder
);
redecode
(
chromosome
,
chromosome
.
getBaseTime
(),
globalParam
);
redecode
(
chromosome
,
chromosome
.
getBaseTime
(),
globalParam
);
...
...
src/test/java/com/aps/demo/PlanResultServiceTest.java
View file @
94b84404
...
@@ -38,17 +38,18 @@ public class PlanResultServiceTest {
...
@@ -38,17 +38,18 @@ public class PlanResultServiceTest {
// nsgaiiUtils.Test();
// nsgaiiUtils.Test();
//planResultService.execute2("C5FB5EF2A7334A0A92F826F4937E1008");
//planResultService.execute2("C5FB5EF2A7334A0A92F826F4937E1008");
//
planResultService.execute2("F79370487E4C455B8C4CF9BA41541CA9");
//
planResultService.execute2("F79370487E4C455B8C4CF9BA41541CA9");
// LocalDateTime t= LocalDateTime.of(2025, 11, 15, 6, 51, 11);
// LocalDateTime t= LocalDateTime.of(2025, 11, 15, 6, 51, 11);
// List<Integer> opids=new ArrayList<>();
// List<Integer> opids=new ArrayList<>();
// opids.add(1);
// opids.add(1);
// planResultService.Move("B571EF6682DB463AB2977B1055A74112",opids,t,3403L);
// planResultService.Move("B571EF6682DB463AB2977B1055A74112",opids,t,3403L);
//
planResultService.Redecode("B6AE363FF5044DDF8DECE32D5FE0F7EA");
//
planResultService.Redecode("B6AE363FF5044DDF8DECE32D5FE0F7EA");
// MaintenanceWindow maintenanceWindow=new MaintenanceWindow();
// MaintenanceWindow maintenanceWindow=new MaintenanceWindow();
// maintenanceWindow.setStartTime(LocalDateTime.of(2025, 10, 21, 0, 0, 0));
// maintenanceWindow.setStartTime(LocalDateTime.of(2025, 10, 21, 0, 0, 0));
// maintenanceWindow.setEndTime(LocalDateTime.of(2025, 10, 31, 0, 0, 0));
// maintenanceWindow.setEndTime(LocalDateTime.of(2025, 10, 31, 0, 0, 0));
// planResultService.AddMaintenanceWindow("B6AE363FF5044DDF8DECE32D5FE0F7EA",1245l,maintenanceWindow);
// planResultService.AddMaintenanceWindow("B6AE363FF5044DDF8DECE32D5FE0F7EA",1245l,maintenanceWindow);
planResultService
.
DelOperation
(
"B6AE363FF5044DDF8DECE32D5FE0F7EA"
,
3
);
// planResultService.SpiltOrder("A41D662EE0764D008173C5A0E42B15F6","5f9d5383-b89a-4a4f-8805-2f617c711968",new Double[]{500d, 500d});
// planResultService.SpiltOrder("A41D662EE0764D008173C5A0E42B15F6","5f9d5383-b89a-4a4f-8805-2f617c711968",new Double[]{500d, 500d});
}
}
...
...
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