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
de289521
Commit
de289521
authored
Dec 19, 2025
by
DESKTOP-VKRD9QF\Administration
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master' into jdt
parents
19269290
0b047fab
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
152 additions
and
72 deletions
+152
-72
ParamValidator.java
src/main/java/com/aps/common/util/ParamValidator.java
+22
-0
ResourceGanttController.java
...ava/com/aps/controller/gantt/ResourceGanttController.java
+4
-2
GeneticAlgorithm.java
...main/java/com/aps/service/Algorithm/GeneticAlgorithm.java
+2
-3
GeneticDecoder.java
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
+17
-15
GeneticOperations.java
...ain/java/com/aps/service/Algorithm/GeneticOperations.java
+3
-1
Initialization.java
src/main/java/com/aps/service/Algorithm/Initialization.java
+7
-6
KpiCalculator.java
src/main/java/com/aps/service/Algorithm/KpiCalculator.java
+2
-1
ScheduleOperationService.java
...a/com/aps/service/Algorithm/ScheduleOperationService.java
+84
-39
PlanResultService.java
src/main/java/com/aps/service/plan/PlanResultService.java
+4
-3
PlanResultServiceTest.java
src/test/java/com/aps/demo/PlanResultServiceTest.java
+7
-2
No files found.
src/main/java/com/aps/common/util/ParamValidator.java
View file @
de289521
...
...
@@ -12,6 +12,7 @@ import java.time.format.DateTimeFormatter;
import
java.time.format.DateTimeParseException
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
@Slf4j
@UtilityClass
...
...
@@ -262,4 +263,25 @@ public class ParamValidator {
})
.
toArray
(
Double
[]::
new
);
}
public
static
List
<
Integer
>
convertToIntArray
(
List
<?>
sourceList
,
String
fieldName
)
{
requireNotEmpty
(
sourceList
,
fieldName
);
return
sourceList
.
stream
()
.
map
(
item
->
{
if
(
item
instanceof
Number
)
{
return
((
Integer
)
item
);
}
else
if
(
item
instanceof
String
)
{
try
{
return
Integer
.
parseInt
(((
String
)
item
).
trim
());
}
catch
(
NumberFormatException
e
)
{
throw
new
IllegalArgumentException
(
fieldName
+
"包含无效的数字: "
+
item
);
}
}
else
{
throw
new
IllegalArgumentException
(
fieldName
+
"包含不支持的数据类型: "
+
(
item
!=
null
?
item
.
getClass
().
getSimpleName
()
:
"null"
));
}
})
.
collect
(
Collectors
.
toList
());
}
}
\ No newline at end of file
src/main/java/com/aps/controller/gantt/ResourceGanttController.java
View file @
de289521
...
...
@@ -144,15 +144,17 @@ public class ResourceGanttController {
// 1. 提取参数
String
sceneId
=
ParamValidator
.
getString
(
params
,
"sceneId"
,
"场景ID"
);
Integer
opid
=
ParamValidator
.
getInteger
(
params
,
"id"
,
"操作ID"
);
List
<?>
opid
=
ParamValidator
.
getList
(
params
,
"id"
,
"操作ID"
);
LocalDateTime
newStartTime
=
ParamValidator
.
getDateTime
(
params
,
"newStartTime"
,
"新的开始时间"
);
Long
newMachineId
=
ParamValidator
.
getLong
(
params
,
"newMachineId"
,
"新机器ID"
);
// 2. 验证场景
ParamValidator
.
validateSceneExists
(
sceneService
,
sceneId
);
List
<
Integer
>
opids
=
ParamValidator
.
convertToIntArray
(
opid
,
"操作IDS"
);
// 3. 执行业务
Chromosome
result
=
planResultService
.
Move
(
sceneId
,
opid
,
newStartTime
,
newMachineId
);
Chromosome
result
=
planResultService
.
Move
(
sceneId
,
opid
s
,
newStartTime
,
newMachineId
);
return
R
.
ok
(
"移动成功"
);
}
...
...
src/main/java/com/aps/service/Algorithm/GeneticAlgorithm.java
View file @
de289521
...
...
@@ -66,7 +66,7 @@ public class GeneticAlgorithm {
}
System
.
out
.
println
(
"开始"
);
Initialization
initialization
=
new
Initialization
(
_GlobalParam
,
allOperations
,
orders
);
Initialization
initialization
=
new
Initialization
(
_GlobalParam
,
allOperations
,
orders
,
machines
);
GeneticOperations
geneticOps
=
new
GeneticOperations
(
_GlobalParam
,
allOperations
,
param
);
...
...
@@ -183,8 +183,7 @@ public class GeneticAlgorithm {
}
}
best
.
setBaseTime
(
param
.
getBaseTime
());
best
.
setInitMachines
(
ProductionDeepCopyUtil
.
deepCopyList
(
machines
));
best
.
setOrders
(
orders
);
best
.
setOrderMaterials
(
orderMaterials
);
best
.
setOperatRel
(
_entryRel
);
// 步骤3:返回最优解
...
...
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
View file @
de289521
...
...
@@ -41,14 +41,8 @@ public class GeneticDecoder {
private
List
<
OrderMaterialRequirement
>
orderMaterials
;
// 添加静态实例引用
private
static
DiscreteParameterMatrixService
staticDiscreteParameterMatrixService
;
// 设置静态服务实例的方法
public
static
void
setDiscreteParameterMatrixService
(
DiscreteParameterMatrixService
service
)
{
staticDiscreteParameterMatrixService
=
service
;
}
private
DiscreteParameterMatrixService
discreteParameterMatrixService
;
public
GeneticDecoder
(
GlobalParam
globalParam
,
LocalDateTime
baseTime
,
List
<
Machine
>
machines
,
List
<
Order
>
orders
,
List
<
Material
>
materials
,
MachineSchedulerService
machineScheduler
,
List
<
OrderMaterialRequirement
>
_orderMaterials
)
{
this
.
baseTime
=
baseTime
;
...
...
@@ -84,7 +78,7 @@ public class GeneticDecoder {
chromosome
.
setTotalChangeoverTime
(
cachedResult
.
getTotalChangeoverTime
());
chromosome
.
setMachineLoadStd
(
cachedResult
.
getMachineLoadStd
());
chromosome
.
setDelayTime
(
cachedResult
.
getDelayTime
());
chromosome
.
setResult
(
ProductionDeepCopyUtil
.
deepCopyList
(
cachedResult
.
getResult
(),
GAScheduleResult
.
class
));
chromosome
.
setResult
(
ProductionDeepCopyUtil
.
deepCopyList
(
cachedResult
.
getResult
(),
GAScheduleResult
.
class
));
// Chromosome chromosomen= ProductionDeepCopyUtil.deepCopy(cachedResult);
return
chromosome
;
...
...
@@ -364,7 +358,8 @@ public class GeneticDecoder {
int
preTime
=
machineOption
.
getPreTime
();
int
setupTime
=
calculateSetupTime
(
chromosome
.
getResult
(),
operation
,
machine
,
machineOption
);
System
.
out
.
println
(
" 处理时间: "
+
processingTime
+
", 后处理: "
+
teardownTime
+
", 前处理: "
+
preTime
+
", 换型: "
+
setupTime
);
// 确定任务的最早开始时间(基于前一道工序的完整结束时间,包含后处理)
...
...
@@ -404,16 +399,21 @@ public class GeneticDecoder {
earliestStartTime
=
Math
.
max
(
earliestStartTime
,
machineAvailableTime
);
}
System
.
out
.
println
(
" 最终最早开始时间: "
+
earliestStartTime
+
" (前序工序结束含后处理: "
+
prevOperationEndTime
+
", 设备可用: "
+
(
lastGeneOnMachine
!=
null
?
lastGeneOnMachine
.
getEndTime
()
:
0
)
+
", 换型: "
+
setupTime
+
")"
);
// 根据换型模式调整处理时间
// int processingTimeForScheduling;
if
(
_globalParam
.
is_smoothSetup
())
{
// 平滑模式:只需要安排主处理时间
// processingTimeForScheduling = processingTimeTotal;
System
.
out
.
println
(
" 平滑模式:安排主处理时间 "
+
processingTime
+
" 分钟"
);
}
else
{
// 标准模式:需要安排主处理时间+换型时间
processingTimeTotal
=
processingTimeTotal
+
setupTime
;
System
.
out
.
println
(
" 标准模式:安排主处理+"
+
setupTime
+
"分钟换型="
+
processingTimeTotal
+
"分钟"
);
}
GAScheduleResult
existingResult
=
chromosome
.
getResultOld
().
stream
().
filter
(
r
->
r
.
getOperationId
()
==
operation
.
Id
).
findFirst
().
orElse
(
null
);
...
...
@@ -807,6 +807,7 @@ public class GeneticDecoder {
.
orElse
(
null
);
if
(
lastGeneOnMachine
==
null
)
{
System
.
out
.
println
(
"设备 "
+
machine
.
getId
()
+
" 上无历史任务,换型时间为0"
);
return
0
;
}
Entry
prev
=
_allOperations
.
stream
().
...
...
@@ -818,12 +819,13 @@ public class GeneticDecoder {
//离散参数
// prev.getDiscreteParameter()
setupTime
=
(
prev
.
getProductId
()
!=
operation
.
getProductId
())
?
(
int
)
discreteParameterMatrixService
.
getDiscreteParameterMatrixValue
(
prev
,
operation
)
:
0
;
if
(
staticDiscreteParameterMatrixService
!=
null
)
{
setupTime
=
(
int
)
staticDiscreteParameterMatrixService
.
getDiscreteParameterMatrixValue
(
prev
,
operation
);
}
else
{
// 添加兜底处理,避免空指针异常
setupTime
=
0
;
if
(
setupTime
>
0
)
{
System
.
out
.
println
(
"设备 "
+
machine
.
getId
()
+
" 需要换型,因为产品从 "
+
prev
.
getProductId
()
+
" 变更为 "
+
operation
.
getProductId
());
}
}
...
...
src/main/java/com/aps/service/Algorithm/GeneticOperations.java
View file @
de289521
...
...
@@ -63,7 +63,7 @@ public class GeneticOperations {
.
findFirst
()
// 处理空列表情况(避免NoSuchElementException)
.
orElse
(
null
);
selected
.
add
(
ProductionDeepCopyUtil
.
deepCopy
(
best
));
selected
.
add
(
ProductionDeepCopyUtil
.
deepCopy
(
best
,
Chromosome
.
class
));
}
return
selected
;
}
...
...
@@ -136,11 +136,13 @@ public class GeneticOperations {
Chromosome
child1
=
new
Chromosome
();
child1
.
setOrders
(
parent1
.
getOrders
());
child1
.
setMachines
(
parent1
.
getMachines
());
child1
.
setMachineSelection
(
child1Ms
);
child1
.
setOperationSequencing
(
child1Os
);
Chromosome
child2
=
new
Chromosome
();
child2
.
setOrders
(
parent1
.
getOrders
());
child2
.
setMachines
(
parent1
.
getMachines
());
child2
.
setMachineSelection
(
child2Ms
);
child2
.
setOperationSequencing
(
child2Os
);
...
...
src/main/java/com/aps/service/Algorithm/Initialization.java
View file @
de289521
package
com
.
aps
.
service
.
Algorithm
;
import
com.aps.common.util.ProductionDeepCopyUtil
;
import
com.aps.entity.Algorithm.Chromosome
;
import
com.aps.entity.Algorithm.GlobalOperationInfo
;
import
com.aps.entity.Algorithm.ScheduleParams
;
import
com.aps.entity.basic.Entry
;
import
com.aps.entity.basic.GlobalParam
;
import
com.aps.entity.basic.MachineOption
;
import
com.aps.entity.basic.Order
;
import
com.aps.entity.basic.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
...
...
@@ -22,10 +20,13 @@ public class Initialization {
private
static
List
<
Order
>
orders
;
public
Initialization
(
GlobalParam
globalParam
,
List
<
Entry
>
allOperations
,
List
<
Order
>
_orders
)
{
private
static
List
<
Machine
>
machines
;
public
Initialization
(
GlobalParam
globalParam
,
List
<
Entry
>
allOperations
,
List
<
Order
>
_orders
,
List
<
Machine
>
_machines
)
{
Initialization
.
allOperations
=
allOperations
;
_globalParam
=
globalParam
;
orders
=
_orders
;
machines
=
_machines
;
}
/**
* 预生成全局工序列表(按“订单0→订单1→…+订单内工序1→2→…”排序,分配GlobalOpId)
...
...
@@ -59,7 +60,7 @@ int populationSize=param.getPopulationSize();
.
parallel
()
// 开启并行
.
forEach
(
i
->
{
Chromosome
chromo
=
new
Chromosome
();
// 初始化染色体
chromo
.
setInitMachines
(
ProductionDeepCopyUtil
.
deepCopyList
(
machines
));
chromo
.
setOrders
(
orders
);
// 全局选择(GS):按GlobalOpId顺序生成MachineSelection
if
(
i
<
gsCount
)
{
...
...
src/main/java/com/aps/service/Algorithm/KpiCalculator.java
View file @
de289521
package
com
.
aps
.
service
.
Algorithm
;
import
com.aps.common.util.ProductionDeepCopyUtil
;
import
com.aps.entity.Algorithm.Chromosome
;
import
com.aps.entity.Algorithm.GAScheduleResult
;
import
com.aps.entity.basic.Machine
;
...
...
@@ -128,7 +129,7 @@ public class KpiCalculator {
private
void
calculateMachine
()
{
// 按设备ID分组工序列表(对应C# GroupBy + ToList)
List
<
GAScheduleResult
>
list
=
chromosome
.
getResult
();
List
<
GAScheduleResult
>
list
=
chromosome
.
getResult
()
;
Map
<
Long
,
List
<
GAScheduleResult
>>
machineTasks
=
list
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
GAScheduleResult:
:
getMachineId
));
...
...
src/main/java/com/aps/service/Algorithm/ScheduleOperationService.java
View file @
de289521
...
...
@@ -27,55 +27,100 @@ public class ScheduleOperationService {
/**
* 移动工序方法
* 移动工序方法
* @param chromosome 染色体对象
* @param opId 工序ID
* @param opId
s
工序ID
* @param newStartTime 新开始时间
* @param newMachineId 新设备ID
*/
public
void
moveOperation
(
Chromosome
chromosome
,
int
opId
,
int
newStartTime
,
public
void
moveOperation
(
Chromosome
chromosome
,
List
<
Integer
>
opIds
,
int
newStartTime
,
Long
newMachineId
,
GlobalParam
globalParam
)
{
List
<
Entry
>
allOperations
=
chromosome
.
getAllOperations
();
// 获取目标结果和工序
GAScheduleResult
targetResult
=
chromosome
.
getResult
().
stream
()
.
filter
(
r
->
r
.
getOperationId
()
==
opId
)
.
findFirst
()
.
orElseThrow
(()
->
new
NoSuchElementException
(
"Operation not found: "
+
opId
));
int
newStartTime1
=
newStartTime
;
Map
<
Integer
,
Integer
>
opTimeMap
=
chromosome
.
getResult
().
stream
()
.
collect
(
Collectors
.
toMap
(
GAScheduleResult:
:
getOperationId
,
r
->
r
.
getStartTime
()
));
Integer
newMachineId1
=
newMachineId
.
intValue
();
for
(
Integer
opId:
opIds
)
{
Entry
targetOp
=
allOperations
.
stream
()
.
filter
(
o
->
o
.
getId
()
==
opId
)
.
findFirst
()
.
orElseThrow
(()
->
new
NoSuchElementException
(
"Operation not found: "
+
opId
));
int
machineOptionIndex
=
targetOp
.
getMachineOptions
().
stream
()
.
map
(
MachineOption:
:
getMachineId
)
.
collect
(
Collectors
.
toList
())
.
indexOf
(
newMachineId
)
+
1
;
// 获取目标结果和工序
GAScheduleResult
targetResult
=
chromosome
.
getResult
().
stream
()
.
filter
(
r
->
r
.
getOperationId
()
==
opId
)
.
findFirst
()
.
orElseThrow
(()
->
new
NoSuchElementException
(
"Operation not found: "
+
opId
));
if
(
machineOptionIndex
==
0
)
{
throw
new
NoSuchElementException
(
"Machine not found: "
+
newMachineId
);
}
Entry
targetOp
=
allOperations
.
stream
()
.
filter
(
o
->
o
.
getId
()
==
opId
)
.
findFirst
()
.
orElseThrow
(()
->
new
NoSuchElementException
(
"Operation not found: "
+
opId
));
// 设置约束
targetResult
.
setDesignatedStartTime
(
newStartTime
);
targetResult
.
setForcedMachineId
(
newMachineId
);
if
(
newMachineId1
!=
0
)
{
int
machineOptionIndex
=
targetOp
.
getMachineOptions
().
stream
()
.
map
(
MachineOption:
:
getMachineId
)
.
collect
(
Collectors
.
toList
())
.
indexOf
(
newMachineId
)
+
1
;
// 更新设备选择序列
int
globalOpIndex
=
chromosome
.
getGlobalOpList
().
stream
()
.
filter
(
g
->
g
.
getOp
().
getId
()
==
opId
)
.
findFirst
()
.
map
(
GlobalOperationInfo:
:
getGlobalOpId
)
.
orElseThrow
(()
->
new
NoSuchElementException
(
"Global operation not found: "
+
opId
));
if
(
machineOptionIndex
==
0
)
{
throw
new
NoSuchElementException
(
"Machine not found: "
+
newMachineId
);
}
// 更新设备选择序列
int
globalOpIndex
=
chromosome
.
getGlobalOpList
().
stream
()
.
filter
(
g
->
g
.
getOp
().
getId
()
==
opId
)
.
findFirst
()
.
map
(
GlobalOperationInfo:
:
getGlobalOpId
)
.
orElseThrow
(()
->
new
NoSuchElementException
(
"Global operation not found: "
+
opId
));
chromosome
.
getMachineSelection
().
set
(
globalOpIndex
,
machineOptionIndex
);
targetResult
.
setForcedMachineId
(
newMachineId
);
}
else
{
newMachineId1
=(
int
)
targetResult
.
getMachineId
();
}
// 设置约束
targetResult
.
setDesignatedStartTime
(
newStartTime
);
if
(
targetOp
.
getSequence
()==
1
)
{
opTimeMap
.
put
(
opId
,
newStartTime
);
}
else
{
Entry
targetOp1
=
allOperations
.
stream
()
.
filter
(
o
->
o
.
getGroupId
()
==
targetOp
.
getGroupId
()
&&
o
.
getSequence
()==
targetOp
.
getSequence
()-
1
)
.
findFirst
()
.
orElseThrow
(()
->
new
NoSuchElementException
(
"Operation not found: "
+
opId
));
GAScheduleResult
targetResult1
=
chromosome
.
getResult
().
stream
()
.
filter
(
r
->
r
.
getOperationId
()
==
targetOp1
.
getId
())
.
findFirst
()
.
orElseThrow
(()
->
new
NoSuchElementException
(
"Operation not found: "
+
opId
));
if
(
targetResult1
.
getStartTime
()<
newStartTime
)
{
opTimeMap
.
put
(
opId
,
newStartTime
);
}
else
{
opTimeMap
.
put
(
opId
,
targetResult1
.
getStartTime
()+
1
);
}
}
newStartTime
=
newStartTime
+
1
;
}
chromosome
.
getMachineSelection
().
set
(
globalOpIndex
,
machineOptionIndex
);
Long
newMachineId2
=
newMachineId1
.
longValue
();
GAScheduleResult
FirstMachineResult
=
chromosome
.
getResult
().
stream
()
.
filter
(
r
->
r
.
getMachineId
()
==
newMachineId2
&&
r
.
getStartTime
()
>=
newStartTime1
)
.
findFirst
()
.
orElse
(
null
);
if
(
FirstMachineResult
!=
null
)
{
opTimeMap
.
put
(
FirstMachineResult
.
getOperationId
(),
newStartTime
);
}
// 生成新的工序顺序
Map
<
Integer
,
Integer
>
opTimeMap
=
chromosome
.
getResult
().
stream
()
.
collect
(
Collectors
.
toMap
(
GAScheduleResult:
:
getOperationId
,
r
->
r
.
getOperationId
()
==
opId
?
newStartTime
:
r
.
getStartTime
()
));
List
<
Integer
>
operationSequencing
=
allOperations
.
stream
()
.
sorted
((
op1
,
op2
)
->
{
...
...
@@ -96,7 +141,6 @@ public class ScheduleOperationService {
}
public
void
SpiltOperation
(
Chromosome
chromosome
,
int
opId
,
Double
[]
splitCounts
,
GlobalParam
globalParam
)
{
List
<
Entry
>
allOperations
=
chromosome
.
getAllOperations
();
...
...
@@ -211,7 +255,7 @@ public class ScheduleOperationService {
}
}
else
{
//不存在创建新的
Entry
newOp
=
ProductionDeepCopyUtil
.
deepCopy
(
targetOp
);
Entry
newOp
=
ProductionDeepCopyUtil
.
deepCopy
(
targetOp
,
Entry
.
class
);
newOp
.
setId
(
nodeInfo
.
getGlobalSerial
());
newOp
.
setSequence
(
nodeInfo
.
getGroupSerial
());
newOp
.
setExecId
(
nodeInfo
.
getOriginalId
());
...
...
@@ -293,7 +337,7 @@ public class ScheduleOperationService {
List
<
String
>
newChildIdList
=
new
ArrayList
<>();
for
(
int
i
=
1
;
i
<
splitCounts
.
length
;
i
++)
{
maxorderId
++;
Order
neworder
=
ProductionDeepCopyUtil
.
deepCopy
(
order
);
Order
neworder
=
ProductionDeepCopyUtil
.
deepCopy
(
order
,
Order
.
class
);
neworder
.
setOrderId
(
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
));
if
(
splitCounts
[
0
]!=
0
&&
i
==
1
)
{
// 数组第一个是0,为复制
order
.
setQuantity
(
splitCounts
[
0
]);
...
...
@@ -308,7 +352,7 @@ public class ScheduleOperationService {
}
String
newId
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
Entry
newOp
=
ProductionDeepCopyUtil
.
deepCopy
(
entry
);
Entry
newOp
=
ProductionDeepCopyUtil
.
deepCopy
(
entry
,
Entry
.
class
);
newOp
.
setExecId
(
newId
);
newOp
.
setOrderId
(
neworder
.
getOrderId
());
newOp
.
setGroupId
(
maxorderId
);
...
...
@@ -693,9 +737,10 @@ public class ScheduleOperationService {
public
void
redecode
(
Chromosome
chromosome
,
LocalDateTime
baseTime
,
GlobalParam
globalParam
)
{
MachineSchedulerService
machineScheduler
=
new
MachineSchedulerService
(
baseTime
);
chromosome
.
setMachines
(
chromosome
.
getInitMachines
());
GeneticDecoder
decoder
=
new
GeneticDecoder
(
globalParam
,
baseTime
,
chromosome
.
getInitMachines
(),
chromosome
.
getOrders
(),
null
,
machineScheduler
,
chromosome
.
getOrderMaterials
());
chromosome
.
setMachines
(
chromosome
.
getInitMachines
());
chromosome
.
setResultOld
(
ProductionDeepCopyUtil
.
deepCopyList
(
chromosome
.
getResult
()));
chromosome
.
getResult
().
clear
();
...
...
src/main/java/com/aps/service/plan/PlanResultService.java
View file @
de289521
...
...
@@ -301,6 +301,7 @@ order.setDueDate(LocalDateTime.of(2025, 12, 1,0,0,0));
public
Chromosome
execute2
(
String
SceneId
)
{
try
{
SceneId
=
"6AF8001449FC4D20A3C9992EC24CBF05"
;
ScheduleParams
param
=
new
ScheduleParams
();
param
.
setBaseTime
(
LocalDateTime
.
of
(
2025
,
11
,
1
,
0
,
0
,
0
));
...
...
@@ -325,7 +326,7 @@ order.setDueDate(LocalDateTime.of(2025, 12, 1,0,0,0));
// 3. 构建订单-工序数据
List
<
Order
>
orders
=
InitOrder
(
ProdLaunchOrders
);
List
<
Material
>
Materials
=
InitMaterial
();
List
<
Material
>
Materials
=
null
;
//
InitMaterial();
Map
<
Integer
,
Object
>
list
=
InitEntrys
(
SceneId
,
ProdEquipments
,
orders
);
List
<
Entry
>
entrys
=(
List
<
Entry
>)
list
.
get
(
1
);
...
...
@@ -404,7 +405,7 @@ order.setDueDate(LocalDateTime.of(2025, 12, 1,0,0,0));
return
chromosome
;
}
public
Chromosome
Move
(
String
SceneId
,
int
opId
,
LocalDateTime
newStartTime
,
public
Chromosome
Move
(
String
SceneId
,
List
<
Integer
>
opId
,
LocalDateTime
newStartTime
,
Long
newMachineId
)
{
...
...
@@ -604,7 +605,7 @@ order.setDueDate(LocalDateTime.of(2025, 12, 1,0,0,0));
public
void
WriteScheduleSummary
(
Chromosome
schedule
)
{
// 写入日志
FileHelper
.
writeLogFile
(
String
.
format
(
"\n=== Schedule Summary === %f"
,
schedule
.
getFitness
())
);
FileHelper
.
writeLogFile
(
"\n=== Schedule Summary === "
);
FileHelper
.
writeLogFile
(
String
.
format
(
"Operation: %s"
,
schedule
.
getOperationStr
()));
FileHelper
.
writeLogFile
(
String
.
format
(
"Makespan: %f minutes"
,
schedule
.
getMakespan
()));
FileHelper
.
writeLogFile
(
String
.
format
(
"Total Tardiness: %f hours"
,
schedule
.
getDelayTime
()));
...
...
src/test/java/com/aps/demo/PlanResultServiceTest.java
View file @
de289521
...
...
@@ -26,9 +26,14 @@ public class PlanResultServiceTest {
@Test
public
void
testExecute
()
{
LocalDateTime
t
=
LocalDateTime
.
of
(
2025
,
10
,
31
,
6
,
51
,
11
);
// planResultService.execute2(""
);
planResultService
.
Move
(
"86ED02C9BAB54BB6B8F413938A3F2869"
,
1
,
t
,
3402L
);
LocalDateTime
t
=
LocalDateTime
.
of
(
2025
,
11
,
15
,
6
,
51
,
11
);
List
<
Integer
>
opids
=
new
ArrayList
<>();
opids
.
add
(
1
);
planResultService
.
Move
(
"B571EF6682DB463AB2977B1055A74112"
,
opids
,
t
,
3403L
);
// planResultService.Move("B571EF6682DB463AB2977B1055A74112",2,t,3243L);
}
@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