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
653269ef
Commit
653269ef
authored
Jan 23, 2026
by
Tong Li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
订单配套
parent
9e01001a
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
326 additions
and
260 deletions
+326
-260
ResourceGanttController.java
...ava/com/aps/controller/gantt/ResourceGanttController.java
+0
-16
Routingsupporting.java
src/main/java/com/aps/entity/Routingsupporting.java
+1
-1
Order.java
src/main/java/com/aps/entity/basic/Order.java
+1
-2
GeneticAlgorithm.java
...main/java/com/aps/service/Algorithm/GeneticAlgorithm.java
+14
-16
GeneticDecoder.java
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
+13
-3
MaterialRequirementService.java
...com/aps/service/Algorithm/MaterialRequirementService.java
+286
-95
ScheduleOperationService.java
...a/com/aps/service/Algorithm/ScheduleOperationService.java
+1
-1
PlanResultService.java
src/main/java/com/aps/service/plan/PlanResultService.java
+9
-125
PlanResultServiceTest.java
src/test/java/com/aps/demo/PlanResultServiceTest.java
+1
-1
No files found.
src/main/java/com/aps/controller/gantt/ResourceGanttController.java
View file @
653269ef
...
...
@@ -116,25 +116,9 @@ public class ResourceGanttController {
}
@GetMapping
(
"/getScene"
)
@Operation
(
summary
=
"获取所有场景ID"
,
description
=
"获取所有场景ID"
)
public
Chromosome
getScene
()
{
// 调用 PlanResultService 获取 ScheduleChromosome 列表
Chromosome
scheduleChromosomes
=
planResultService
.
execute1
();
// 提取所有场景ID
return
scheduleChromosomes
;
}
@GetMapping
(
"/getScene2"
)
@Operation
(
summary
=
"获取所有场景ID"
,
description
=
"获取所有场景ID"
)
public
Chromosome
getScene2
()
{
// 调用 PlanResultService 获取 ScheduleChromosome 列表
Chromosome
scheduleChromosomes
=
planResultService
.
execute2
(
"B571EF6682DB463AB2977B1055A74112"
);
// 提取所有场景ID
return
scheduleChromosomes
;
}
@GetMapping
(
"/SyncMaterials"
)
@Operation
(
summary
=
"更新物料信息缓存"
,
description
=
"更新物料信息缓存"
)
...
...
src/main/java/com/aps/entity/Routingsupporting.java
View file @
653269ef
...
...
@@ -15,7 +15,7 @@ private Long lastmodifieruserid;
private
Long
isdeleted
;
private
LocalDateTime
deletiontime
;
private
Long
deleteruserid
;
private
Long
routingHeaderId
;
private
Integer
routingHeaderId
;
private
Long
routingDetailId
;
private
String
materialId
;
private
String
materialType
;
...
...
src/main/java/com/aps/entity/basic/Order.java
View file @
653269ef
...
...
@@ -52,6 +52,5 @@ private List<Integer> FinishOrderId ;
private
List
<
Integer
>
TargetFinishedOperationId
;
private
double
delayHours
;
//延迟时间
//物料需求
private
List
<
OrderMaterialRequirement
>
materialRequirementList
;
}
\ No newline at end of file
src/main/java/com/aps/service/Algorithm/GeneticAlgorithm.java
View file @
653269ef
...
...
@@ -44,8 +44,10 @@ public class GeneticAlgorithm {
private
SceneService
_sceneService
;
private
String
sceneId
;
public
GeneticAlgorithm
(
GlobalParam
globalParam
,
List
<
Machine
>
machines
,
List
<
Order
>
orders
,
List
<
Material
>
materials
,
MachineSchedulerService
machineScheduler
,
List
<
GroupResult
>
entryRel
,
MaterialRequirementService
_materialRequirementService
,
SceneService
sceneService
)
{
List
<
Material
>
materials
,
MachineSchedulerService
machineScheduler
,
List
<
GroupResult
>
entryRel
,
MaterialRequirementService
_materialRequirementService
,
SceneService
sceneService
,
String
_sceneId
)
{
this
.
machines
=
machines
;
this
.
orders
=
orders
;
this
.
materials
=
materials
;
...
...
@@ -54,7 +56,7 @@ public class GeneticAlgorithm {
_entryRel
=
entryRel
;
materialRequirementService
=
_materialRequirementService
;
_sceneService
=
sceneService
;
sceneId
=
_sceneId
;
}
public
void
Init
(
double
[]
customWeights
,
boolean
pureNSGAIIMode
)
{
...
...
@@ -299,19 +301,15 @@ public class GeneticAlgorithm {
FileHelper
.
writeLogFile
(
String
.
format
(
"排产-----------方案数量---%d-------"
,
0
));
return
population
;
}
// population = population.stream()
// .collect(Collectors.toMap(
// Chromosome::getGeneStr, // key:去重的字段(GeneStr)
// u -> u, // value:Chromosome对象
// (u1, u2) -> u1 // 重复时保留第一个元素
// ))
// .values() // 获取去重后的
// .stream()
// .collect(Collectors.toList());
population
=
population
.
stream
()
.
collect
(
Collectors
.
toMap
(
Chromosome:
:
getGeneStr
,
// key:去重的字段(GeneStr)
u
->
u
,
// value:Chromosome对象
(
u1
,
u2
)
->
u1
// 重复时保留第一个元素
))
.
values
()
// 获取去重后的
.
stream
()
.
collect
(
Collectors
.
toList
());
return
population
;
}
...
...
@@ -372,7 +370,7 @@ return population;
{
FileHelper
.
writeLogFile
(
"解码---------------"
+
population
.
size
()
);
GeneticDecoder
decoder
=
new
GeneticDecoder
(
_GlobalParam
,
param
.
getBaseTime
(),
machines
,
orders
,
materials
,
machineScheduler
,
orderMaterials
);
GeneticDecoder
decoder
=
new
GeneticDecoder
(
_GlobalParam
,
param
.
getBaseTime
(),
machines
,
orders
,
materials
,
machineScheduler
,
materialRequirementService
,
sceneId
);
boolean
ismore
=
true
;
if
(
ismore
)
{
CompletableFuture
.
allOf
(
population
.
stream
()
...
...
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
View file @
653269ef
...
...
@@ -47,13 +47,17 @@ public class GeneticDecoder {
private
GlobalParam
_globalParam
;
private
MachineCalculator
machineCalculator
;
private
List
<
OrderMaterialRequirement
>
orderMaterials
;
private
MaterialRequirementService
materialRequirementService
;
private
DiscreteParameterMatrixService
discreteParameterMatrixService
;
private
String
sceneId
;
public
GeneticDecoder
(
GlobalParam
globalParam
,
LocalDateTime
baseTime
,
List
<
Machine
>
machines
,
List
<
Order
>
orders
,
List
<
Material
>
materials
,
MachineSchedulerService
machineScheduler
,
List
<
OrderMaterialRequirement
>
_orderMaterials
)
{
List
<
Material
>
materials
,
MachineSchedulerService
machineScheduler
,
MaterialRequirementService
_materialRequirementService
,
String
_sceneId
)
{
this
.
baseTime
=
baseTime
;
this
.
machines
=
machines
;
this
.
orders
=
orders
;
...
...
@@ -62,7 +66,8 @@ public class GeneticDecoder {
this
.
machineScheduler
=
machineScheduler
;
_globalParam
=
globalParam
;
machineCalculator
=
new
MachineCalculator
(
baseTime
,
machines
,
machineScheduler
);
orderMaterials
=
_orderMaterials
;
materialRequirementService
=
_materialRequirementService
;
sceneId
=
_sceneId
;
// this.orderMaxID = orders.stream().mapToInt(Order::getId).max().orElse(0);
}
...
...
@@ -71,6 +76,10 @@ public class GeneticDecoder {
// FileHelper.writeLogFile("解码-----------开始-------"+chromosome.getID()+":"+cacheKey );
_allOperations
=
chromosome
.
getAllOperations
();
List
<
OrderMaterialRequirement
>
orderMaterials
=
materialRequirementService
.
buildMultiLevelRequirementNetwork
(
sceneId
,
baseTime
);
if
(
orderMaterials
!=
null
&&
orderMaterials
.
size
()>
0
&&
_globalParam
.
isIsCheckSf
())
{
CreateNewOpSequence
(
chromosome
);
}
...
...
@@ -619,6 +628,7 @@ if(finishedOrder==null||finishedOrder.size()==0)
private
int
getOperationBOMTime
(
Entry
currentOp
,
Chromosome
chromosome
)
{
List
<
OrderMaterialRequirement
>
orderMaterials
=
chromosome
.
getOrderMaterials
();
if
(
orderMaterials
==
null
)
{
return
0
;
...
...
src/main/java/com/aps/service/Algorithm/MaterialRequirementService.java
View file @
653269ef
...
...
@@ -25,6 +25,7 @@ import java.math.BigDecimal;
import
java.math.RoundingMode
;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -97,54 +98,64 @@ public class MaterialRequirementService {
globalParam
=
_GlobalParam
;
}
private
Map
<
String
,
List
<
RoutingHeader
>>
routingHeaderCache
=
new
HashMap
<>();
private
Map
<
String
,
List
<
Routingsupporting
>>
routingsupportingCache
=
new
HashMap
<>();
private
Map
<
String
,
List
<
RoutingSupportingReplace
>>
routingSupportingReplaceCache
=
new
HashMap
<>();
private
Map
<
String
,
List
<
RoutingDetail
>>
allRoutingDetailsCache
=
new
HashMap
<>();
private
Map
<
String
,
List
<
RoutingDetailEquip
>>
allroutingDetailEquipsCache
=
new
HashMap
<>();
private
Map
<
String
,
List
<
RoutingDetailConnect
>>
allroutingDetailconnectionsCache
=
new
HashMap
<>();
private
Map
<
String
,
List
<
RoutingDiscreteParam
>>
allroutingDiscreteParamsCache
=
new
HashMap
<>();
private
static
final
int
cachetimeout
=
60
;
private
String
cacheKey
=
"_MR_"
;
private
String
routingHeaderCacheKey
=
cacheKey
+
"RoutingHeader"
;
private
String
routingsupportingCacheKey
=
cacheKey
+
"Routingsupporting"
;
private
String
routingSupportingReplaceCacheKey
=
cacheKey
+
"RoutingSupportingReplace"
;
public
List
<
Long
>
preloadRoutingCache
(
String
sceneId
,
List
<
Order
>
_orders
,
List
<
Material
>
materials
,
boolean
isIsCheckSf
)
{
private
String
routingDetailCacheKey
=
cacheKey
+
"RoutingDetail"
;
private
String
routingDetailEquipCacheKey
=
cacheKey
+
"RoutingDetailEquip"
;
private
String
routingDetailConnectCacheKey
=
cacheKey
+
"RoutingDetailConnect"
;
private
String
routingDiscreteParamCacheKey
=
cacheKey
+
"RoutingDiscreteParam"
;
public
Map
<
Integer
,
Object
>
preloadRoutingCache
(
String
sceneId
,
List
<
Order
>
_orders
,
List
<
Material
>
materials
,
boolean
isIsCheckSf
)
{
Map
<
Integer
,
Object
>
reslte
=
new
HashMap
<>(
2
);
reslte
.
put
(
1
,
null
);
reslte
.
put
(
2
,
null
);
this
.
_materials
=
materials
;
List
<
Integer
>
routingIds
=
_orders
.
stream
()
.
filter
(
t
->
t
.
getRoutingId
()!=
null
)
.
map
(
Order:
:
getRoutingId
)
.
distinct
()
.
collect
(
Collectors
.
toList
());
List
<
RoutingHeader
>
routingHeaders
=
null
;
if
(!
routingHeaderCache
.
containsKey
(
sceneId
))
{
LambdaQueryWrapper
<
RoutingHeader
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
in
(
RoutingHeader:
:
getId
,
routingIds
);
// .eq(RoutingHeader::getIsDeleted, 0)
// .eq(RoutingHeader::getApprovalStatus, 1);
List
<
RoutingHeader
>
routingHeaders
=
routingHeaderMapper
.
selectList
(
wrapper
);
routingHeaderCache
.
put
(
sceneId
,
routingHeaders
);
}
routingHeaders
=
routingHeaderMapper
.
selectList
(
wrapper
);
List
<
Routingsupporting
>
routingsupportings
=
null
;
// 查询并缓存Routingsupporting
if
(!
routingsupportingCache
.
containsKey
(
sceneId
))
{
LambdaQueryWrapper
<
Routingsupporting
>
routingsupportingwrapper
=
new
LambdaQueryWrapper
<>();
routingsupportingwrapper
.
in
(
Routingsupporting:
:
getRoutingHeaderId
,
routingIds
)
.
eq
(
Routingsupporting:
:
getIsdeleted
,
0
);
routingsupportings
=
routingsupportingMapper
.
selectList
(
routingsupportingwrapper
);
routingsupportingCache
.
put
(
sceneId
,
routingsupportings
);
}
// 查询并缓存RoutingSupportingReplace
List
<
Routing
supporting
>
cachedSupportings
=
routingsupportingCache
.
get
(
sceneId
)
;
if
(
cachedSupportings
!=
null
&&
!
cachedS
upportings
.
isEmpty
())
{
List
<
String
>
routingsupportingids
=
cachedS
upportings
.
stream
()
List
<
Routing
SupportingReplace
>
replaces
=
null
;
if
(
routingsupportings
!=
null
&&
!
routings
upportings
.
isEmpty
())
{
List
<
String
>
routingsupportingids
=
routings
upportings
.
stream
()
.
map
(
Routingsupporting:
:
getStrId
)
.
distinct
()
.
collect
(
Collectors
.
toList
());
if
(!
routingSupportingReplaceCache
.
containsKey
(
sceneId
))
{
LambdaQueryWrapper
<
RoutingSupportingReplace
>
routingsupportingreplacewrapper
=
new
LambdaQueryWrapper
<>();
routingsupportingreplacewrapper
.
in
(
RoutingSupportingReplace:
:
getStrsupid
,
routingsupportingids
)
.
eq
(
RoutingSupportingReplace:
:
getIsdeleted
,
0
);
List
<
RoutingSupportingReplace
>
replaces
=
routingSupportingReplaceMapper
.
selectList
(
routingsupportingreplacewrapper
);
routingSupportingReplaceCache
.
put
(
sceneId
,
replaces
);
}
replaces
=
routingSupportingReplaceMapper
.
selectList
(
routingsupportingreplacewrapper
);
}
List
<
Material
>
useMaterials
=
new
ArrayList
<>();
Set
<
String
>
useMaterialids
=
new
HashSet
<>();
if
(
routingsupportings
!=
null
&&
routingsupportings
.
size
()>
0
)
{
List
<
String
>
materialIds
=
new
ArrayList
<>();
...
...
@@ -164,35 +175,81 @@ public class MaterialRequirementService {
.
findFirst
()
.
orElse
(
null
);
if
(
material
!=
null
)
{
OrderMaterialRequirement
orderMaterial
=
new
OrderMaterialRequirement
();
orderMaterial
.
setRoutingDetailId
(
component
.
getRoutingDetailId
());
orderMaterial
.
setMaterialCode
(
material
.
getCode
());
orderMaterial
.
setMaterialName
(
material
.
getName
());
orderMaterial
.
setMaterialTypeName
(
material
.
getMaterialTypeName
());
orderMaterial
.
setMaterialId
(
material
.
getId
());
materialRequirementList
.
add
(
orderMaterial
);
if
(!
useMaterialids
.
contains
(
materialId
))
{
useMaterials
.
add
(
material
);
useMaterialids
.
add
(
materialId
);
}
// OrderMaterialRequirement orderMaterial = new OrderMaterialRequirement();
// orderMaterial.setRoutingDetailId(component.getRoutingDetailId());
// orderMaterial.setMaterialCode(material.getCode());
// orderMaterial.setMaterialName(material.getName());
// orderMaterial.setMaterialTypeName(material.getMaterialTypeName());
// orderMaterial.setMaterialId(material.getId());
// materialRequirementList.add(orderMaterial);
if
(!
material
.
getMaterialTypeName
().
equals
(
"MP"
)&&
isIsCheckSf
)
{
materialIds
.
add
(
materialId
);
}
}
order
.
setMaterialRequirementList
(
materialRequirementList
);
//
order.setMaterialRequirementList(materialRequirementList);
}
}
}
if
(
replaces
!=
null
&&
replaces
.
size
()>
0
)
{
for
(
RoutingSupportingReplace
routingSupportingReplace
:
replaces
)
{
String
materialID1
=
routingSupportingReplace
.
getMaterialid
();
if
(!
useMaterialids
.
contains
(
materialID1
))
{
Material
material
=
_materials
.
stream
()
.
filter
(
m
->
m
.
getId
().
equals
(
materialID1
))
.
findFirst
()
.
orElse
(
null
);
if
(
material
!=
null
)
{
useMaterials
.
add
(
material
);
useMaterialids
.
add
(
materialID1
);
}
}
}
}
if
(
materialIds
!=
null
&&
materialIds
.
size
()>
0
)
{
List
<
Long
>
routingIds1
=
preloadSfRoutingBomCache
(
materialIds
,
headers
,
routingsupportings
,
routingsupportingreplaces
);
return
preloadSfRoutingCache
(
sceneId
,
routingIds1
);
Map
<
Integer
,
Object
>
reslte1
=
preloadSfRoutingBomCache
(
materialIds
,
routingHeaders
,
routingsupportings
,
replaces
);
List
<
Long
>
routingIds1
=(
List
<
Long
>)
reslte1
.
get
(
1
);
if
(
routingIds1
!=
null
)
{
List
<
Long
>
equipids
=
preloadSfRoutingCache
(
sceneId
,
routingIds1
);
reslte
.
put
(
1
,
equipids
);
}
List
<
Material
>
useMaterials1
=(
List
<
Material
>)
reslte1
.
get
(
2
);
if
(
useMaterials1
!=
null
)
{
for
(
Material
m:
useMaterials1
)
{
String
materialID1
=
m
.
getId
();
if
(!
useMaterialids
.
contains
(
materialID1
))
{
useMaterials
.
add
(
m
);
useMaterialids
.
add
(
materialID1
);
}
}
}
reslte
.
put
(
2
,
useMaterials
);
}
return
null
;
}
return
null
;
SaveBomCache
(
sceneId
,
routingHeaders
,
routingsupportings
,
replaces
);
return
reslte
;
}
private
List
<
Long
>
preloadSfRoutingBomCache
(
List
<
String
>
materialIDs
,
List
<
RoutingHeader
>
headers
,
List
<
Routingsupporting
>
routingsupportings
,
List
<
RoutingSupportingReplace
>
routingsupportingreplaces
)
{
private
Map
<
Integer
,
Object
>
preloadSfRoutingBomCache
(
List
<
String
>
materialIDs
,
List
<
RoutingHeader
>
headers
,
List
<
Routingsupporting
>
routingsupportings
,
List
<
RoutingSupportingReplace
>
routingsupportingreplaces
)
{
Map
<
Integer
,
Object
>
reslte
=
new
HashMap
<>(
2
);
reslte
.
put
(
1
,
null
);
reslte
.
put
(
2
,
null
);
List
<
Material
>
useMaterials
=
new
ArrayList
<>();
Set
<
String
>
useMaterialids
=
new
HashSet
<>();
List
<
Long
>
routingIds
=
new
ArrayList
<>();
List
<
Long
>
routingIds1
=
new
ArrayList
<>();
Long
routingId
=
0
l
;
...
...
@@ -251,21 +308,54 @@ public class MaterialRequirementService {
.
filter
(
m
->
m
.
getId
().
equals
(
materialID1
))
.
findFirst
()
.
orElse
(
null
);
if
(
material
!=
null
&&!
material
.
getMaterialTypeName
().
equals
(
"MP"
))
{
materialIds
.
add
(
materialID1
);
if
(
material
!=
null
)
{
if
(!
useMaterialids
.
contains
(
materialID1
))
{
useMaterials
.
add
(
material
);
useMaterialids
.
add
(
materialID1
);
}
if
(!
material
.
getMaterialTypeName
().
equals
(
"MP"
))
{
materialIds
.
add
(
materialID1
);
}
}
}
for
(
RoutingSupportingReplace
routingSupportingReplace:
routingsupportingreplaces1
)
{
String
materialID1
=
routingSupportingReplace
.
getMaterialid
();
if
(!
useMaterialids
.
contains
(
materialID1
))
{
Material
material
=
_materials
.
stream
()
.
filter
(
m
->
m
.
getId
().
equals
(
materialID1
))
.
findFirst
()
.
orElse
(
null
);
if
(
material
!=
null
)
{
useMaterials
.
add
(
material
);
useMaterialids
.
add
(
materialID1
);
}
}
}
List
<
Long
>
routingIds2
=
preloadSfRoutingBomCache
(
materialIds
,
headers
,
routingsupportings
,
routingsupportingreplaces
);
Map
<
Integer
,
Object
>
r1
=
preloadSfRoutingBomCache
(
materialIds
,
headers
,
routingsupportings
,
routingsupportingreplaces
);
List
<
Long
>
routingIds2
=(
List
<
Long
>)
r1
.
get
(
1
);
List
<
Material
>
useMaterials2
=(
List
<
Material
>)
r1
.
get
(
2
);
if
(
routingIds2
!=
null
)
{
routingIds
.
addAll
(
routingIds2
);
}
if
(
useMaterials2
!=
null
&&
useMaterials2
.
size
()>
0
)
{
for
(
Material
m:
useMaterials2
)
{
String
materialID1
=
m
.
getId
();
if
(!
useMaterialids
.
contains
(
materialID1
))
{
useMaterials
.
add
(
m
);
useMaterialids
.
add
(
materialID1
);
}
}
}
}
if
(
routingIds1
!=
null
)
{
routingIds
.
addAll
(
routingIds1
);
}
return
routingIds
;
reslte
.
put
(
1
,
routingIds
);
reslte
.
put
(
2
,
useMaterials
);
return
reslte
;
}
...
...
@@ -275,35 +365,37 @@ public class MaterialRequirementService {
List
<
RoutingDetail
>
RoutingDetails
=
null
;
List
<
RoutingDetailEquip
>
routingDetailEquips
=
null
;
List
<
RoutingDetailConnect
>
connections
=
null
;
if
(
routingIds
==
null
||
routingIds
.
size
()
==
0
)
{
List
<
RoutingDiscreteParam
>
routingDiscreteParams
=
null
;
if
(
routingIds
!=
null
||
routingIds
.
size
()
>
0
)
{
RoutingDetails
=
lanuchService
.
getRoutingDetails
(
routingIds
);
if
(
RoutingDetails
==
null
&&
RoutingDetails
.
size
()
==
0
)
{
return
null
;
}
allRoutingDetailsCache
.
put
(
sceneId
,
RoutingDetails
);
routingDetailEquips
=
lanuchService
.
getRoutingDetailEquip
(
routingIds
);
allroutingDetailEquipsCache
.
put
(
sceneId
,
routingDetailEquips
);
LambdaQueryWrapper
<
RoutingDetailConnect
>
routingDetailConnectwrapper
=
new
LambdaQueryWrapper
<>();
routingDetailConnectwrapper
.
in
(
RoutingDetailConnect:
:
getRoutingHeaderId
,
routingIds
)
.
eq
(
RoutingDetailConnect:
:
getIsdeleted
,
0
);
// 添加 isdeleted=0 过滤条件
connections
=
routingDetailConnectService
.
list
(
routingDetailConnectwrapper
);
allroutingDetailconnectionsCache
.
put
(
sceneId
,
connections
);
List
<
Long
>
routingDetailIds
=
RoutingDetails
.
stream
()
.
map
(
RoutingDetail:
:
getId
)
.
distinct
()
.
collect
(
Collectors
.
toList
());
List
<
RoutingDiscreteParam
>
routingDiscreteParams
=
_routingDiscreteParamService
.
lambdaQuery
()
routingDiscreteParams
=
_routingDiscreteParamService
.
lambdaQuery
()
.
in
(
RoutingDiscreteParam:
:
getRoutingDetailId
,
routingDetailIds
)
.
eq
(
RoutingDiscreteParam:
:
getIsDeleted
,
0
)
.
list
();
allroutingDiscreteParamsCache
.
put
(
sceneId
,
routingDiscreteParams
);
SaveDetailCache
(
sceneId
,
RoutingDetails
,
routingDetailEquips
,
connections
,
routingDiscreteParams
);
if
(
routingDetailEquips
!=
null
&&
routingDetailEquips
.
size
()
>
0
)
{
...
...
@@ -313,7 +405,6 @@ public class MaterialRequirementService {
.
collect
(
Collectors
.
toList
());
return
equipIds
;
}
}
return
null
;
}
...
...
@@ -323,7 +414,7 @@ public class MaterialRequirementService {
* 构建多级BOM需求网络
* @return 所有物料需求列表
*/
public
List
<
OrderMaterialRequirement
>
buildMultiLevelRequirementNetwork
(
LocalDateTime
_baseTime
)
{
public
List
<
OrderMaterialRequirement
>
buildMultiLevelRequirementNetwork
(
String
sceneId
,
LocalDateTime
_baseTime
)
{
baseTime
=
_baseTime
;
List
<
OrderMaterialRequirement
>
allRequirements
=
new
ArrayList
<>();
List
<
Order
>
childorders
=
new
ArrayList
<>();
...
...
@@ -334,36 +425,10 @@ public class MaterialRequirementService {
.
map
(
Entry:
:
getRoutingId
)
.
distinct
()
.
collect
(
Collectors
.
toList
());
if
(
routingIds
.
size
()==
0
)
{
return
null
;
}
LambdaQueryWrapper
<
RoutingHeader
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
in
(
RoutingHeader:
:
getId
,
routingIds
)
.
eq
(
RoutingHeader:
:
getIsDeleted
,
0
)
.
eq
(
RoutingHeader:
:
getApprovalStatus
,
1
);
// 添加 is_deleted=0 过滤条件
headers
=
routingHeaderMapper
.
selectList
(
wrapper
);
LambdaQueryWrapper
<
Routingsupporting
>
routingsupportingwrapper
=
new
LambdaQueryWrapper
<>();
routingsupportingwrapper
.
in
(
Routingsupporting:
:
getRoutingHeaderId
,
routingIds
)
.
eq
(
Routingsupporting:
:
getIsdeleted
,
0
);
routingsupportings
=
routingsupportingMapper
.
selectList
(
routingsupportingwrapper
);
if
(
routingsupportings
==
null
||
routingsupportings
.
size
()==
0
)
if
(
routingIds
.
size
()==
0
)
{
return
null
;
return
null
;
}
List
<
String
>
routingsupportingids
=
routingsupportings
.
stream
()
.
map
(
Routingsupporting:
:
getStrId
)
.
distinct
()
.
collect
(
Collectors
.
toList
());
LambdaQueryWrapper
<
RoutingSupportingReplace
>
routingsupportingreplacewrapper
=
new
LambdaQueryWrapper
<>();
routingsupportingreplacewrapper
.
in
(
RoutingSupportingReplace:
:
getStrsupid
,
routingsupportingids
)
.
eq
(
RoutingSupportingReplace:
:
getIsdeleted
,
0
);
routingsupportingreplaces
=
routingSupportingReplaceMapper
.
selectList
(
routingsupportingreplacewrapper
);
for
(
Order
demand
:
orders
)
{
...
...
@@ -408,6 +473,7 @@ if(routingIds.size()==0)
public
BOMBuildResult
buildOrderBOM
(
int
parent
,
String
materialID
,
String
mainorderId
,
String
childorderId
,
double
parentQuantity
,
int
level
,
Order
forder
,
int
finishOpertionID
)
{
forder
.
setCreateBom
(
true
);
RoutingHeader
routingHeaders
=
headers
.
stream
()
.
filter
(
t
->
t
.
getId
()==
parent
||
t
.
getMaterialId
().
equals
(
materialID
))
.
findFirst
()
...
...
@@ -416,7 +482,7 @@ if(routingIds.size()==0)
// 若未找到产品,返回空结果(根据业务可调整为抛出异常)
if
(
routingHeaders
==
null
)
{
return
null
;
}
List
<
OrderMaterialRequirement
>
materialRequirements
=
new
ArrayList
<>();
...
...
@@ -666,6 +732,7 @@ if(routingIds.size()==0)
List
<
Order
>
_childorders
=
new
ArrayList
<>();
List
<
Entry
>
_newEntrys
=
new
ArrayList
<>();
List
<
Machine
>
_newMachines
=
new
ArrayList
<>();
List
<
Routingsupporting
>
MaterialRequirements
=
routingsupportings
.
stream
()
.
filter
(
t
->
t
.
getRoutingDetailId
().
equals
(
operation
.
getRoutingDetailId
()))
.
collect
(
Collectors
.
toList
());
...
...
@@ -673,7 +740,6 @@ if(routingIds.size()==0)
if
(
MaterialRequirements
!=
null
&&
MaterialRequirements
.
size
()>
0
)
{
for
(
Routingsupporting
component
:
MaterialRequirements
)
{
double
allneeded
=
parentQuantity
*
component
.
getMainQty
().
doubleValue
();
double
needed
=
allneeded
;
...
...
@@ -890,16 +956,7 @@ if(routingIds.size()==0)
orderMaterial
.
setOperationId
(
operation
.
getId
());
orderMaterial
.
setChildOrderId
(
StringUtils
.
isBlank
(
childorderId
)
?
orderId
:
childorderId
);
orderMaterial
.
setRequiredQuantity
(
allneeded
);
if
(
material
==
null
)
{
material
=
_materials
.
stream
()
.
filter
(
m
->
m
.
getId
().
equals
(
materialId
))
.
findFirst
()
.
orElse
(
null
);
if
(
material
==
null
)
{
return
null
;
}
}
double
availableNow
=
material
.
getCurrentStock
();
orderMaterial
.
setMaterialCode
(
material
.
getCode
());
orderMaterial
.
setMaterialName
(
material
.
getName
());
...
...
@@ -954,14 +1011,148 @@ if(routingIds.size()==0)
orderMaterial
.
setArrivalTime
(
earliestTime
);
}
public
void
clearCache
()
{
routingHeaderCache
.
clear
();
routingsupportingCache
.
clear
();
routingSupportingReplaceCache
.
clear
();
// 清空其他缓存集合(如allRoutingDetails等)
allRoutingDetailsCache
.
clear
();
allroutingDetailEquipsCache
.
clear
();
allroutingDetailconnectionsCache
.
clear
();
allroutingDiscreteParamsCache
.
clear
();
private
void
SaveBomCache
(
String
sceneId
,
List
<
RoutingHeader
>
routingHeaders
,
List
<
Routingsupporting
>
routingsupportings
,
List
<
RoutingSupportingReplace
>
replaces
)
{
redisUtils
.
set
(
sceneId
+
routingHeaderCacheKey
,
routingHeaders
);
GlobalCacheUtil
.
put
(
sceneId
+
routingHeaderCacheKey
,
routingHeaders
,
cachetimeout
,
TimeUnit
.
MINUTES
);
redisUtils
.
set
(
sceneId
+
routingsupportingCacheKey
,
routingsupportings
);
GlobalCacheUtil
.
put
(
sceneId
+
routingsupportingCacheKey
,
routingsupportings
,
cachetimeout
,
TimeUnit
.
MINUTES
);
redisUtils
.
set
(
sceneId
+
routingSupportingReplaceCacheKey
,
replaces
);
GlobalCacheUtil
.
put
(
sceneId
+
routingSupportingReplaceCacheKey
,
replaces
,
cachetimeout
,
TimeUnit
.
MINUTES
);
}
private
void
SaveDetailCache
(
String
sceneId
,
List
<
RoutingDetail
>
RoutingDetails
,
List
<
RoutingDetailEquip
>
routingDetailEquips
,
List
<
RoutingDetailConnect
>
connections
,
List
<
RoutingDiscreteParam
>
routingDiscreteParams
)
{
redisUtils
.
set
(
sceneId
+
routingDetailCacheKey
,
RoutingDetails
);
GlobalCacheUtil
.
put
(
sceneId
+
routingDetailCacheKey
,
RoutingDetails
,
cachetimeout
,
TimeUnit
.
MINUTES
);
redisUtils
.
set
(
sceneId
+
routingDetailEquipCacheKey
,
routingDetailEquips
);
GlobalCacheUtil
.
put
(
sceneId
+
routingDetailEquipCacheKey
,
routingDetailEquips
,
cachetimeout
,
TimeUnit
.
MINUTES
);
redisUtils
.
set
(
sceneId
+
routingDetailConnectCacheKey
,
connections
);
GlobalCacheUtil
.
put
(
sceneId
+
routingDetailConnectCacheKey
,
connections
,
cachetimeout
,
TimeUnit
.
MINUTES
);
redisUtils
.
set
(
sceneId
+
routingDiscreteParamCacheKey
,
routingDiscreteParams
);
GlobalCacheUtil
.
put
(
sceneId
+
routingDiscreteParamCacheKey
,
routingDiscreteParams
,
cachetimeout
,
TimeUnit
.
MINUTES
);
}
private
List
<
RoutingHeader
>
GetRoutingHeader
(
String
sceneId
)
{
List
<
RoutingHeader
>
RoutingHeaders
=(
List
<
RoutingHeader
>)
GlobalCacheUtil
.
get
(
sceneId
+
routingHeaderCacheKey
);
if
(
RoutingHeaders
==
null
)
{
RoutingHeaders
=(
List
<
RoutingHeader
>)
redisUtils
.
get
(
sceneId
+
routingHeaderCacheKey
);
if
(
RoutingHeaders
!=
null
)
{
GlobalCacheUtil
.
put
(
sceneId
+
routingHeaderCacheKey
,
RoutingHeaders
,
cachetimeout
,
TimeUnit
.
MINUTES
);
}
}
return
RoutingHeaders
;
}
private
List
<
Routingsupporting
>
GetRoutingsupportings
(
String
sceneId
)
{
List
<
Routingsupporting
>
Routingsupportings
=(
List
<
Routingsupporting
>)
GlobalCacheUtil
.
get
(
sceneId
+
routingsupportingCacheKey
);
if
(
Routingsupportings
==
null
)
{
Routingsupportings
=(
List
<
Routingsupporting
>)
redisUtils
.
get
(
sceneId
+
routingsupportingCacheKey
);
if
(
Routingsupportings
!=
null
)
{
GlobalCacheUtil
.
put
(
sceneId
+
routingsupportingCacheKey
,
Routingsupportings
,
cachetimeout
,
TimeUnit
.
MINUTES
);
}
}
return
Routingsupportings
;
}
private
List
<
RoutingSupportingReplace
>
GetRoutingSupportingReplaces
(
String
sceneId
)
{
List
<
RoutingSupportingReplace
>
RoutingSupportingReplaces
=(
List
<
RoutingSupportingReplace
>)
GlobalCacheUtil
.
get
(
sceneId
+
routingSupportingReplaceCacheKey
);
if
(
RoutingSupportingReplaces
==
null
)
{
RoutingSupportingReplaces
=(
List
<
RoutingSupportingReplace
>)
redisUtils
.
get
(
sceneId
+
routingSupportingReplaceCacheKey
);
if
(
RoutingSupportingReplaces
!=
null
)
{
GlobalCacheUtil
.
put
(
sceneId
+
routingSupportingReplaceCacheKey
,
RoutingSupportingReplaces
,
cachetimeout
,
TimeUnit
.
MINUTES
);
}
}
return
RoutingSupportingReplaces
;
}
private
List
<
RoutingDetail
>
GetRoutingDetails
(
String
sceneId
)
{
List
<
RoutingDetail
>
RoutingDetails
=(
List
<
RoutingDetail
>)
GlobalCacheUtil
.
get
(
sceneId
+
routingDetailCacheKey
);
if
(
RoutingDetails
==
null
)
{
RoutingDetails
=(
List
<
RoutingDetail
>)
redisUtils
.
get
(
sceneId
+
routingDetailCacheKey
);
if
(
RoutingDetails
!=
null
)
{
GlobalCacheUtil
.
put
(
sceneId
+
routingDetailCacheKey
,
RoutingDetails
,
cachetimeout
,
TimeUnit
.
MINUTES
);
}
}
return
RoutingDetails
;
}
private
List
<
RoutingDetailEquip
>
GetRoutingDetailEquips
(
String
sceneId
)
{
List
<
RoutingDetailEquip
>
RoutingDetailEquips
=(
List
<
RoutingDetailEquip
>)
GlobalCacheUtil
.
get
(
sceneId
+
routingDetailEquipCacheKey
);
if
(
RoutingDetailEquips
==
null
)
{
RoutingDetailEquips
=(
List
<
RoutingDetailEquip
>)
redisUtils
.
get
(
sceneId
+
routingDetailEquipCacheKey
);
if
(
RoutingDetailEquips
!=
null
)
{
GlobalCacheUtil
.
put
(
sceneId
+
routingDetailEquipCacheKey
,
RoutingDetailEquips
,
cachetimeout
,
TimeUnit
.
MINUTES
);
}
}
return
RoutingDetailEquips
;
}
private
List
<
RoutingDetailConnect
>
GetRoutingDetailConnect
(
String
sceneId
)
{
List
<
RoutingDetailConnect
>
RoutingDetailConnects
=(
List
<
RoutingDetailConnect
>)
GlobalCacheUtil
.
get
(
sceneId
+
routingDetailConnectCacheKey
);
if
(
RoutingDetailConnects
==
null
)
{
RoutingDetailConnects
=(
List
<
RoutingDetailConnect
>)
redisUtils
.
get
(
sceneId
+
routingDetailConnectCacheKey
);
if
(
RoutingDetailConnects
!=
null
)
{
GlobalCacheUtil
.
put
(
sceneId
+
routingDetailConnectCacheKey
,
RoutingDetailConnects
,
cachetimeout
,
TimeUnit
.
MINUTES
);
}
}
return
RoutingDetailConnects
;
}
private
List
<
RoutingDiscreteParam
>
GetRoutingDiscreteParam
(
String
sceneId
)
{
List
<
RoutingDiscreteParam
>
RoutingDiscreteParams
=(
List
<
RoutingDiscreteParam
>)
GlobalCacheUtil
.
get
(
sceneId
+
routingDiscreteParamCacheKey
);
if
(
RoutingDiscreteParams
==
null
)
{
RoutingDiscreteParams
=(
List
<
RoutingDiscreteParam
>)
redisUtils
.
get
(
sceneId
+
routingDiscreteParamCacheKey
);
if
(
RoutingDiscreteParams
!=
null
)
{
GlobalCacheUtil
.
put
(
sceneId
+
routingDiscreteParamCacheKey
,
RoutingDiscreteParams
,
cachetimeout
,
TimeUnit
.
MINUTES
);
}
}
return
RoutingDiscreteParams
;
}
public
void
clearCache
(
String
sceneId
)
{
redisUtils
.
del
(
sceneId
+
routingHeaderCacheKey
);
GlobalCacheUtil
.
remove
(
sceneId
+
routingHeaderCacheKey
);
redisUtils
.
del
(
sceneId
+
routingsupportingCacheKey
);
GlobalCacheUtil
.
remove
(
sceneId
+
routingsupportingCacheKey
);
redisUtils
.
del
(
sceneId
+
routingSupportingReplaceCacheKey
);
GlobalCacheUtil
.
remove
(
sceneId
+
routingSupportingReplaceCacheKey
);
redisUtils
.
del
(
sceneId
+
routingDetailCacheKey
);
GlobalCacheUtil
.
remove
(
sceneId
+
routingDetailCacheKey
);
redisUtils
.
del
(
sceneId
+
routingDetailEquipCacheKey
);
GlobalCacheUtil
.
remove
(
sceneId
+
routingDetailEquipCacheKey
);
redisUtils
.
del
(
sceneId
+
routingDetailConnectCacheKey
);
GlobalCacheUtil
.
remove
(
sceneId
+
routingDetailConnectCacheKey
);
redisUtils
.
del
(
sceneId
+
routingDiscreteParamCacheKey
);
GlobalCacheUtil
.
remove
(
sceneId
+
routingDiscreteParamCacheKey
);
}
}
src/main/java/com/aps/service/Algorithm/ScheduleOperationService.java
View file @
653269ef
...
...
@@ -1181,7 +1181,7 @@ if(targetOp.getSequence()>1) {
chromosome
.
setMachines
(
ProductionDeepCopyUtil
.
deepCopyList
(
chromosome
.
getInitMachines
(),
Machine
.
class
)
);
GeneticDecoder
decoder
=
new
GeneticDecoder
(
globalParam
,
baseTime
,
chromosome
.
getMachines
(),
chromosome
.
getOrders
(),
null
,
machineScheduler
,
chromosome
.
getOrderMaterials
());
chromosome
.
getOrders
(),
null
,
machineScheduler
,
null
,
chromosome
.
getScenarioID
());
chromosome
.
setResultOld
(
ProductionDeepCopyUtil
.
deepCopyList
(
chromosome
.
getResult
(),
GAScheduleResult
.
class
));
chromosome
.
getResult
().
clear
();
...
...
src/main/java/com/aps/service/plan/PlanResultService.java
View file @
653269ef
...
...
@@ -128,124 +128,8 @@ public class PlanResultService {
public
Chromosome
execute1
()
{
try
{
//List<ScheduleResultDetail> details=new ArrayList<>();
// ScheduleResultDetail detail1=new ScheduleResultDetail();
//
// detail1.setOneTime(100);//单件工时
//
//
// ScheduleResultDetail detail2=new ScheduleResultDetail();
//
// detail2.setOneTime(200);//单件工时
// details.add(detail1);
// details.add(detail2);
// mergeSegmentsWithDifferentOneTime(details, 50);
// 1. 读取数据
List
<
Machine
>
machines
=
loadData
(
"machines.json"
,
Machine
.
class
);
List
<
Product
>
products
=
loadData
(
"products.json"
,
Product
.
class
);
List
<
Order
>
orders
=
loadData
(
"orders.json"
,
Order
.
class
);
// 设置机器信息到班次中
for
(
Machine
machine
:
machines
)
{
if
(
machine
.
getShifts
()
!=
null
)
{
for
(
Shift
shift
:
machine
.
getShifts
())
{
shift
.
setMachineId
(
machine
.
getId
());
shift
.
setMachineName
(
machine
.
getName
());
}
}
// 调试:打印机器和班次信息
System
.
out
.
println
(
"Machine: "
+
machine
.
getId
()
+
", Name: "
+
machine
.
getName
());
if
(
machine
.
getShifts
()
!=
null
)
{
for
(
Shift
shift
:
machine
.
getShifts
())
{
System
.
out
.
println
(
" Shift: "
+
shift
.
getStartTime
()
+
" - "
+
shift
.
getEndTime
()
+
", Status: "
+
shift
.
getStatus
()
+
", MachineId: "
+
shift
.
getMachineId
()
+
", MachineName: "
+
shift
.
getMachineName
());
}
}
}
ScheduleParams
param
=
new
ScheduleParams
();
param
.
setBaseTime
(
LocalDateTime
.
of
(
2025
,
11
,
1
,
0
,
0
,
0
));
// List<MesHoliday> holidays= _MesHolidayService.list();
// 创建节假日
// 将节假日添加到所有设备中
// addHolidaysToAllMachines(machines);
// 3. 创建调度服务
MachineSchedulerService
machineScheduler
=
new
MachineSchedulerService
(
param
.
getBaseTime
());
// 4. 初始化机器时间线
for
(
Machine
machine
:
machines
)
{
MachineTimeline
timeline
=
machineScheduler
.
getOrCreateTimeline
(
machine
);
machine
.
setAvailability
(
timeline
.
getSegments
());
}
// 3. 构建订单-工序数据
List
<
Entry
>
allOperations
=
new
ArrayList
<>();
Random
rnd
=
new
Random
();
// 注意:此处变量声明但未使用,可根据实际需求保留或移除
int
id
=
1
;
for
(
Order
order
:
orders
)
{
order
.
setDueDate
(
LocalDateTime
.
of
(
2025
,
12
,
1
,
0
,
0
,
0
));
// 假设products是一个List<Product>,根据Product的Id查找对应的产品
Product
product
=
products
.
stream
()
.
filter
(
p
->
p
.
getId
()
==
order
.
getProductId
())
.
findFirst
()
.
orElseThrow
(()
->
new
IllegalArgumentException
(
"未找到对应产品: "
+
order
.
getProductId
()));
int
sequence
=
1
;
for
(
Operation
o
:
product
.
getOperations
())
{
// 假设Product类有getOperations()方法返回工序列表
Entry
entry
=
new
Entry
();
entry
.
setId
(
id
);
// entry.setGroupId(order.getId());
entry
.
setSequence
(
sequence
);
entry
.
setMachineOptions
(
o
.
getMachineOptions
());
// 假设Operation类有获取机器选项的方法
entry
.
setPriority
(
order
.
getPriority
());
entry
.
setQuantity
(
order
.
getQuantity
());
// entry.setMaterialRequirements(o.getMaterialRequirements()); // 假设Operation类有获取物料需求的方法
if
(
sequence
!=
1
)
{
OperationDependency
od
=
new
OperationDependency
();
od
.
setPrevOperationId
(
id
-
1
);
entry
.
getPrevEntryIds
().
add
(
od
);
// 假设Entry类有getPrevEntryIds()返回List<Integer>
}
allOperations
.
add
(
entry
);
sequence
++;
id
++;
}
}
GlobalParam
globalParam
=
new
GlobalParam
();
// 5. 执行调度算法
param
.
initAdaptiveParams
(
allOperations
.
size
());
GeneticAlgorithm
scheduler
=
new
GeneticAlgorithm
(
globalParam
,
machines
,
orders
,
null
,
machineScheduler
,
null
,
materialRequirementService
,
_sceneService
);
//new GeneticAlgorithm(products, machines, orders, machineScheduler);
Chromosome
Chromosomes
=
scheduler
.
Run
(
param
,
allOperations
);
WriteScheduleSummary
(
Chromosomes
);
ScheduleOperationService
ScheduleOperation
=
new
ScheduleOperationService
();
LocalDateTime
ds
=
LocalDateTime
.
of
(
2025
,
12
,
7
,
23
,
59
);
// ScheduleOperation.moveOperation(Chromosomes,3, (int)ChronoUnit.SECONDS.between(param.getBaseTime(), ds),(Long)2,param.getBaseTime(), globalParam);
WriteScheduleSummary
(
Chromosomes
);
return
Chromosomes
;
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"调度执行失败"
,
e
);
}
}
public
Chromosome
execute2
(
String
SceneId
)
{
try
{
...
...
@@ -284,14 +168,14 @@ order.setDueDate(LocalDateTime.of(2025, 12, 1,0,0,0));
List
<
GroupResult
>
entryRel
=(
List
<
GroupResult
>)
list
.
get
(
2
);
Map
<
Long
,
Double
>
machineIds
=(
Map
<
Long
,
Double
>)
list
.
get
(
3
);
Map
<
Integer
,
Object
>
reslte
=
materialRequirementService
.
preloadRoutingCache
(
SceneId
,
orders
,
Materials
,
globalParam
.
isIsCheckSf
());
List
<
Long
>
equipIDs
=(
List
<
Long
>)
reslte
.
get
(
1
);
// List<Long> equipIDs= materialRequirementService.preloadRoutingCache(SceneId,orders,Materials,globalParam.isIsCheckSf());
Set
machineIds1
=
machineIds
.
keySet
();
// if(equipIDs!=null&&equipIDs.size()>0)
// {
// machineIds1.addAll(equipIDs);
// }
List
<
Long
>
machineIds1
=
machineIds
.
keySet
().
stream
().
collect
(
Collectors
.
toList
());
if
(
equipIDs
!=
null
&&
equipIDs
.
size
()>
0
)
{
machineIds1
.
addAll
(
equipIDs
);
}
machines
=
machines
.
stream
().
filter
(
t
->
machineIds1
.
contains
(
t
.
getId
())).
collect
(
Collectors
.
toList
());
...
...
@@ -313,7 +197,7 @@ order.setDueDate(LocalDateTime.of(2025, 12, 1,0,0,0));
// 5. 执行调度算法
GeneticAlgorithm
scheduler
=
new
GeneticAlgorithm
(
globalParam
,
machines
,
orders
,
Materials
,
machineScheduler
,
entryRel
,
materialRequirementService
,
_sceneService
);
//new GeneticAlgorithm(products, machines, orders, machineScheduler);
GeneticAlgorithm
scheduler
=
new
GeneticAlgorithm
(
globalParam
,
machines
,
orders
,
Materials
,
machineScheduler
,
entryRel
,
materialRequirementService
,
_sceneService
,
SceneId
);
//new GeneticAlgorithm(products, machines, orders, machineScheduler);
param
.
initAdaptiveParams
(
entrys
.
size
());
double
[]
customWeights
=
new
double
[]
{
0.4
,
0.1
,
0.1
,
0.1
,
0.3
};
// 延迟时间权重提升到0.5
//完工时间、总流程时间、总换型时间、机器负载标准差、延迟时间
...
...
@@ -866,7 +750,7 @@ order.setDueDate(LocalDateTime.of(2025, 12, 1,0,0,0));
machines
=
machines
.
stream
().
filter
(
t
->
machineIds
.
contains
(
t
.
getId
())).
collect
(
Collectors
.
toList
());
// 5. 执行调度算法
GeneticAlgorithm
scheduler
=
new
GeneticAlgorithm
(
globalParam
,
machines
,
orders
,
Materials
,
machineScheduler
,
entryRel
,
materialRequirementService
,
_sceneService
);
//new GeneticAlgorithm(products, machines, orders, machineScheduler);
GeneticAlgorithm
scheduler
=
new
GeneticAlgorithm
(
globalParam
,
machines
,
orders
,
Materials
,
machineScheduler
,
entryRel
,
materialRequirementService
,
_sceneService
,
SceneId
);
//new GeneticAlgorithm(products, machines, orders, machineScheduler);
param
.
initAdaptiveParams
(
entrys
.
size
());
double
[]
customWeights
=
new
double
[]
{
0.4
,
0.1
,
0.1
,
0.1
,
0.3
};
// 延迟时间权重提升到0.5
//完工时间、总流程时间、总换型时间、机器负载标准差、延迟时间
...
...
src/test/java/com/aps/demo/PlanResultServiceTest.java
View file @
653269ef
...
...
@@ -37,7 +37,7 @@ public class PlanResultServiceTest {
// NSGAIIUtils nsgaiiUtils=new NSGAIIUtils();
// nsgaiiUtils.Test();
planResultService
.
execute2
(
"
0DCB1301C57C48B68154789B0FAB8B98
"
);
planResultService
.
execute2
(
"
83D729F5E0694F25A71614B1991D7457
"
);
// planResultService.execute2("726D4C1A712B4B1393175BD44B775B66");
// planResultService.execute2("265F24B6DF3C40E4B17D193B0CC8AAF2");
// LocalDateTime t= LocalDateTime.of(2026, 02, 14, 1, 25, 52);
...
...
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