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
3c0b67c4
Commit
3c0b67c4
authored
Jan 22, 2026
by
Tong Li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
效率系数
parent
06ae8e1c
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
350 additions
and
33 deletions
+350
-33
OrderMaterialRequirement.java
...va/com/aps/entity/Algorithm/OrderMaterialRequirement.java
+1
-0
Order.java
src/main/java/com/aps/entity/basic/Order.java
+4
-0
GeneticAlgorithm.java
...main/java/com/aps/service/Algorithm/GeneticAlgorithm.java
+10
-10
GeneticDecoder.java
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
+6
-2
MachineCalculator.java
...ain/java/com/aps/service/Algorithm/MachineCalculator.java
+35
-8
MaterialRequirementService.java
...com/aps/service/Algorithm/MaterialRequirementService.java
+235
-5
LanuchService.java
src/main/java/com/aps/service/LanuchService.java
+6
-0
LanuchServiceImpl.java
src/main/java/com/aps/service/impl/LanuchServiceImpl.java
+30
-0
PlanResultService.java
src/main/java/com/aps/service/plan/PlanResultService.java
+19
-4
PlanResultServiceTest.java
src/test/java/com/aps/demo/PlanResultServiceTest.java
+4
-4
No files found.
src/main/java/com/aps/entity/Algorithm/OrderMaterialRequirement.java
View file @
3c0b67c4
...
@@ -18,6 +18,7 @@ public class OrderMaterialRequirement {
...
@@ -18,6 +18,7 @@ public class OrderMaterialRequirement {
private
String
orderId
;
private
String
orderId
;
private
int
operationId
;
private
int
operationId
;
private
String
childOrderId
;
private
String
childOrderId
;
private
Long
routingDetailId
;
private
String
materialId
;
private
String
materialId
;
private
String
materialCode
;
private
String
materialCode
;
private
String
materialName
;
private
String
materialName
;
...
...
src/main/java/com/aps/entity/basic/Order.java
View file @
3c0b67c4
package
com
.
aps
.
entity
.
basic
;
package
com
.
aps
.
entity
.
basic
;
import
com.aps.entity.Algorithm.OrderMaterialRequirement
;
import
lombok.Data
;
import
lombok.Data
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
...
@@ -50,4 +51,7 @@ private List<Integer> FinishOrderId ;
...
@@ -50,4 +51,7 @@ private List<Integer> FinishOrderId ;
/// </summary>
/// </summary>
private
List
<
Integer
>
TargetFinishedOperationId
;
private
List
<
Integer
>
TargetFinishedOperationId
;
private
double
delayHours
;
//延迟时间
private
double
delayHours
;
//延迟时间
//物料需求
private
List
<
OrderMaterialRequirement
>
materialRequirementList
;
}
}
\ No newline at end of file
src/main/java/com/aps/service/Algorithm/GeneticAlgorithm.java
View file @
3c0b67c4
...
@@ -74,16 +74,16 @@ public class GeneticAlgorithm {
...
@@ -74,16 +74,16 @@ public class GeneticAlgorithm {
throw
new
RuntimeException
(
"没有待排产工单"
);
throw
new
RuntimeException
(
"没有待排产工单"
);
}
}
if
(
materials
!=
null
&&
materials
.
size
()>
0
)
{
//
if(materials!=null&&materials.size()>0) {
//
materialRequirementService
.
init
(
materials
,
orders
,
allOperations
,
_entryRel
,
machineScheduler
,
machines
,
_GlobalParam
);
//
materialRequirementService.init(materials, orders, allOperations, _entryRel, machineScheduler, machines,_GlobalParam);
//
orderMaterials
=
materialRequirementService
.
buildMultiLevelRequirementNetwork
(
param
.
getBaseTime
());
//
orderMaterials = materialRequirementService.buildMultiLevelRequirementNetwork(param.getBaseTime());
Set
<
Long
>
existIds
=
new
HashSet
<>();
//
Set<Long> existIds = new HashSet<>();
machines
=
machines
.
stream
()
//
machines=machines.stream()
.
filter
(
t
->
existIds
.
add
(
t
.
getId
()))
//HashSet.add() 方法:添加成功返回 true,重复返回 false;
//
.filter(t->existIds.add(t.getId()))//HashSet.add() 方法:添加成功返回 true,重复返回 false;
.
collect
(
Collectors
.
toList
());
//
.collect(Collectors.toList());
}
//
}
LocalDateTime
starttime
=
LocalDateTime
.
now
();
LocalDateTime
starttime
=
LocalDateTime
.
now
();
FileHelper
.
writeLogFile
(
"排产-----------开始-----------"
+
allOperations
.
get
(
0
).
getSceneId
());
FileHelper
.
writeLogFile
(
"排产-----------开始-----------"
+
allOperations
.
get
(
0
).
getSceneId
());
...
...
src/main/java/com/aps/service/Algorithm/GeneticDecoder.java
View file @
3c0b67c4
...
@@ -375,8 +375,8 @@ if(finishedOrder==null||finishedOrder.size()==0)
...
@@ -375,8 +375,8 @@ if(finishedOrder==null||finishedOrder.size()==0)
{
{
processingTimeTotal
=(
int
)
Math
.
ceil
(
processingTime
);
processingTimeTotal
=(
int
)
Math
.
ceil
(
processingTime
);
}
else
{
}
else
{
BigDecimal
t
=
machineOption
.
getSingleOut
().
divide
(
machineOption
.
getRuntime
()).
multiply
(
BigDecimal
.
valueOf
(
operation
.
getQuantity
()
));
double
t
=
machineOption
.
getRuntime
().
doubleValue
()/
machineOption
.
getSingleOut
().
doubleValue
()*(
operation
.
getQuantity
(
));
processingTimeTotal
=(
int
)
Math
.
ceil
(
t
.
doubleValue
()
);
processingTimeTotal
=(
int
)
Math
.
ceil
(
t
);
}
}
if
(
machine
==
null
||
operation
.
getMachineOptions
()==
null
)
if
(
machine
==
null
||
operation
.
getMachineOptions
()==
null
)
...
@@ -447,6 +447,10 @@ if(finishedOrder==null||finishedOrder.size()==0)
...
@@ -447,6 +447,10 @@ if(finishedOrder==null||finishedOrder.size()==0)
operation
.
setChangeLineTime
(
setupTime
);
operation
.
setChangeLineTime
(
setupTime
);
geneDetails
=(
CopyOnWriteArrayList
<
ScheduleResultDetail
>)
result
.
get
(
2
);
geneDetails
=(
CopyOnWriteArrayList
<
ScheduleResultDetail
>)
result
.
get
(
2
);
}
}
}
else
{
geneDetails
=
machineCalculator
.
getNextAvailableTime
(
machine
,
earliestStartTime
,
-
1
,
processingTimeTotal
,
machineTasks
,
operation
.
IsInterrupt
!=
1
,
true
,
processingTime
,
operation
.
getQuantity
(),
true
);
}
}
// FileHelper.writeLogFile(" 开始 "+operation.getGroupId()+" : "+operation.getId()+",处理时间: " + processingTime + ", 后处理: " + teardownTime +
// FileHelper.writeLogFile(" 开始 "+operation.getGroupId()+" : "+operation.getId()+",处理时间: " + processingTime + ", 后处理: " + teardownTime +
...
...
src/main/java/com/aps/service/Algorithm/MachineCalculator.java
View file @
3c0b67c4
...
@@ -103,6 +103,7 @@ public class MachineCalculator {
...
@@ -103,6 +103,7 @@ public class MachineCalculator {
//判断换型开始时间是否在工作时间段内,要占用工作时间,分割工作时间
//判断换型开始时间是否在工作时间段内,要占用工作时间,分割工作时间
if
(
setupStartTime1
.
compareTo
(
shiftStart1
)>
0
)
if
(
setupStartTime1
.
compareTo
(
shiftStart1
)>
0
)
{
{
//换型时间不考虑效率系数
ScheduleResultDetail
time
=
new
ScheduleResultDetail
();
ScheduleResultDetail
time
=
new
ScheduleResultDetail
();
time
.
setStartTime
((
int
)
ChronoUnit
.
SECONDS
.
between
(
baseTime
,
setupStartTime1
));
time
.
setStartTime
((
int
)
ChronoUnit
.
SECONDS
.
between
(
baseTime
,
setupStartTime1
));
time
.
setEndTime
((
int
)
ChronoUnit
.
SECONDS
.
between
(
baseTime
,
shift1
.
getEnd
()));
time
.
setEndTime
((
int
)
ChronoUnit
.
SECONDS
.
between
(
baseTime
,
shift1
.
getEnd
()));
...
@@ -213,9 +214,21 @@ public class MachineCalculator {
...
@@ -213,9 +214,21 @@ public class MachineCalculator {
?
slot
.
getStart
()
?
slot
.
getStart
()
:
startTime
;
:
startTime
;
LocalDateTime
endCandidate
=
startCandidate
.
plusSeconds
(
processingTime
);
if
(
endCandidate
.
isAfter
(
slot
.
getEnd
()))
{
// LocalDateTime endCandidate = startCandidate.plusSeconds(processingTime);
long
availableSeconds
=
ChronoUnit
.
SECONDS
.
between
(
startCandidate
,
slot
.
getEnd
());
//实际可用时间
long
availableSeconds_e
=
Math
.
round
(
availableSeconds
*
slot
.
getEfficiency
())
;
// if (endCandidate.isAfter(slot.getEnd())) {
if
(
processingTime
>
availableSeconds_e
)
{
CopyOnWriteArrayList
<
TimeSegment
>
timeSegments1
=
timeSegments
.
stream
()
CopyOnWriteArrayList
<
TimeSegment
>
timeSegments1
=
timeSegments
.
stream
()
.
filter
(
t
->
t
.
getStart
().
compareTo
(
startCandidate
)>=
0
)
.
filter
(
t
->
t
.
getStart
().
compareTo
(
startCandidate
)>=
0
)
.
collect
(
Collectors
.
toCollection
(
CopyOnWriteArrayList:
:
new
));
.
collect
(
Collectors
.
toCollection
(
CopyOnWriteArrayList:
:
new
));
...
@@ -223,6 +236,10 @@ public class MachineCalculator {
...
@@ -223,6 +236,10 @@ public class MachineCalculator {
machine
,
processingTime
,
startTime
,
machine
,
processingTime
,
startTime
,
timeSegments1
,
oneTime
,
quantity
);
timeSegments1
,
oneTime
,
quantity
);
}
else
{
}
else
{
double
e
=
(
double
)
processingTime
/
slot
.
getEfficiency
();
LocalDateTime
endCandidate
=
startCandidate
.
plusSeconds
((
int
)
Math
.
ceil
(
e
));
ScheduleResultDetail
time
=
new
ScheduleResultDetail
();
ScheduleResultDetail
time
=
new
ScheduleResultDetail
();
time
.
setKey
(
slot
.
getKey
());
time
.
setKey
(
slot
.
getKey
());
time
.
setStartTime
((
int
)
ChronoUnit
.
SECONDS
.
between
(
baseTime
,
startCandidate
));
time
.
setStartTime
((
int
)
ChronoUnit
.
SECONDS
.
between
(
baseTime
,
startCandidate
));
...
@@ -268,15 +285,25 @@ public class MachineCalculator {
...
@@ -268,15 +285,25 @@ public class MachineCalculator {
LocalDateTime
startCandidate
=
slot
.
getStart
().
isAfter
(
prevTimeDateTime
!=
null
?
prevTimeDateTime
:
currentTime
)
LocalDateTime
startCandidate
=
slot
.
getStart
().
isAfter
(
prevTimeDateTime
!=
null
?
prevTimeDateTime
:
currentTime
)
?
slot
.
getStart
()
?
slot
.
getStart
()
:
(
prevTimeDateTime
!=
null
?
prevTimeDateTime
:
currentTime
);
:
(
prevTimeDateTime
!=
null
?
prevTimeDateTime
:
currentTime
);
if
(
slot
.
getStart
().
isBefore
(
startCandidate
))
{
int
i
=
0
;
}
LocalDateTime
endCandidate
=
startCandidate
.
plusSeconds
(
processingTime
);
if
(
endCandidate
.
isAfter
(
slot
.
getEnd
()))
{
// LocalDateTime endCandidate = startCandidate.plusSeconds(processingTime);
long
availableSeconds
=
ChronoUnit
.
SECONDS
.
between
(
startCandidate
,
slot
.
getEnd
());
//实际可用时间
long
availableSeconds_e
=
Math
.
round
(
availableSeconds
*
slot
.
getEfficiency
())
;
// if (endCandidate.isAfter(slot.getEnd())) {
if
(
processingTime
>
availableSeconds_e
)
{
return
CaldEarliestStart
(
machine
,
processingTime
,
currentTime
,
prevtime
,
machineTasks
,
oneTime
,
quantity
,
checkprevtime
,
islockMachineTime
,
isInterrupt
);
return
CaldEarliestStart
(
machine
,
processingTime
,
currentTime
,
prevtime
,
machineTasks
,
oneTime
,
quantity
,
checkprevtime
,
islockMachineTime
,
isInterrupt
);
}
else
{
}
else
{
double
e
=
(
double
)
processingTime
/
slot
.
getEfficiency
();
LocalDateTime
endCandidate
=
startCandidate
.
plusSeconds
((
int
)
Math
.
ceil
(
e
));
ScheduleResultDetail
time
=
new
ScheduleResultDetail
();
ScheduleResultDetail
time
=
new
ScheduleResultDetail
();
time
.
setKey
(
slot
.
getKey
());
time
.
setKey
(
slot
.
getKey
());
time
.
setStartTime
((
int
)
ChronoUnit
.
SECONDS
.
between
(
baseTime
,
startCandidate
));
time
.
setStartTime
((
int
)
ChronoUnit
.
SECONDS
.
between
(
baseTime
,
startCandidate
));
...
...
src/main/java/com/aps/service/Algorithm/MaterialRequirementService.java
View file @
3c0b67c4
...
@@ -83,8 +83,6 @@ public class MaterialRequirementService {
...
@@ -83,8 +83,6 @@ public class MaterialRequirementService {
private
MachineSchedulerService
machineScheduler
;
private
MachineSchedulerService
machineScheduler
;
private
GlobalParam
globalParam
;
private
GlobalParam
globalParam
;
public
void
init
(
List
<
Material
>
materials
,
List
<
Order
>
_orders
,
List
<
Entry
>
allOperations
,
List
<
GroupResult
>
entryRel
,
MachineSchedulerService
_machineScheduler
,
List
<
Machine
>
machines
,
GlobalParam
_GlobalParam
)
public
void
init
(
List
<
Material
>
materials
,
List
<
Order
>
_orders
,
List
<
Entry
>
allOperations
,
List
<
GroupResult
>
entryRel
,
MachineSchedulerService
_machineScheduler
,
List
<
Machine
>
machines
,
GlobalParam
_GlobalParam
)
...
@@ -99,10 +97,232 @@ public class MaterialRequirementService {
...
@@ -99,10 +97,232 @@ public class MaterialRequirementService {
globalParam
=
_GlobalParam
;
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
<>();
public
List
<
Long
>
preloadRoutingCache
(
String
sceneId
,
List
<
Order
>
_orders
,
List
<
Material
>
materials
,
boolean
isIsCheckSf
)
{
List
<
Integer
>
routingIds
=
_orders
.
stream
()
.
filter
(
t
->
t
.
getRoutingId
()!=
null
)
.
map
(
Order:
:
getRoutingId
)
.
distinct
()
.
collect
(
Collectors
.
toList
());
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
);
}
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
<
Routingsupporting
>
cachedSupportings
=
routingsupportingCache
.
get
(
sceneId
);
if
(
cachedSupportings
!=
null
&&
!
cachedSupportings
.
isEmpty
())
{
List
<
String
>
routingsupportingids
=
cachedSupportings
.
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
);
}
}
if
(
routingsupportings
!=
null
&&
routingsupportings
.
size
()>
0
)
{
List
<
String
>
materialIds
=
new
ArrayList
<>();
for
(
Order
order
:
_orders
)
{
Integer
routingid
=
order
.
getRoutingId
();
List
<
Routingsupporting
>
MaterialRequirements
=
routingsupportings
.
stream
()
.
filter
(
t
->
t
.
getRoutingHeaderId
().
equals
(
routingid
))
.
collect
(
Collectors
.
toList
());
if
(
MaterialRequirements
!=
null
)
{
List
<
OrderMaterialRequirement
>
materialRequirementList
=
new
ArrayList
<>();
for
(
Routingsupporting
component
:
MaterialRequirements
)
{
// 查找物料(流式处理替代First)
String
materialId
=
component
.
getMaterialId
();
Material
material
=
materials
.
stream
()
.
filter
(
m
->
m
.
getId
().
equals
(
materialId
))
.
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
(!
material
.
getMaterialTypeName
().
equals
(
"MP"
)&&
isIsCheckSf
)
{
materialIds
.
add
(
materialId
);
}
}
order
.
setMaterialRequirementList
(
materialRequirementList
);
}
}
}
if
(
materialIds
!=
null
&&
materialIds
.
size
()>
0
)
{
List
<
Long
>
routingIds1
=
preloadSfRoutingBomCache
(
materialIds
,
headers
,
routingsupportings
,
routingsupportingreplaces
);
return
preloadSfRoutingCache
(
sceneId
,
routingIds1
);
}
return
null
;
}
return
null
;
}
private
List
<
Long
>
preloadSfRoutingBomCache
(
List
<
String
>
materialIDs
,
List
<
RoutingHeader
>
headers
,
List
<
Routingsupporting
>
routingsupportings
,
List
<
RoutingSupportingReplace
>
routingsupportingreplaces
)
{
List
<
Long
>
routingIds
=
new
ArrayList
<>();
List
<
Long
>
routingIds1
=
new
ArrayList
<>();
Long
routingId
=
0
l
;
List
<
Routingsupporting
>
routingsupportings1
=
new
ArrayList
<>();
List
<
RoutingSupportingReplace
>
routingsupportingreplaces1
=
new
ArrayList
<>();
for
(
String
materialID:
materialIDs
)
{
RoutingHeader
headers1
=
headers
.
stream
()
.
filter
(
t
->
t
.
getMaterialId
().
equals
(
materialID
))
.
findFirst
().
orElse
(
null
);
if
(
headers1
==
null
)
{
LambdaQueryWrapper
<
RoutingHeader
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
RoutingHeader:
:
getMaterialId
,
materialID
)
.
eq
(
RoutingHeader:
:
getIsDeleted
,
0
);
// .eq(RoutingHeader::getApprovalStatus, 1); // 添加 is_deleted=0 过滤条件
headers1
=
routingHeaderMapper
.
selectList
(
wrapper
).
stream
().
findFirst
().
orElse
(
null
);
if
(
headers1
!=
null
)
{
headers
.
add
(
headers1
);
routingId
=
headers1
.
getId
().
longValue
();
routingIds
.
add
(
routingId
);
}
}
else
{
routingIds1
.
add
(
headers1
.
getId
().
longValue
());
}
}
if
(
routingIds
!=
null
&&
routingIds
.
size
()>
0
)
{
LambdaQueryWrapper
<
Routingsupporting
>
routingsupportingwrapper
=
new
LambdaQueryWrapper
<>();
routingsupportingwrapper
.
in
(
Routingsupporting:
:
getRoutingHeaderId
,
routingIds
)
.
eq
(
Routingsupporting:
:
getIsdeleted
,
0
);
routingsupportings1
=
routingsupportingMapper
.
selectList
(
routingsupportingwrapper
);
routingsupportings
.
addAll
(
routingsupportings1
);
List
<
String
>
routingsupportingids
=
routingsupportings1
.
stream
()
.
map
(
Routingsupporting:
:
getStrId
)
.
distinct
()
.
collect
(
Collectors
.
toList
());
LambdaQueryWrapper
<
RoutingSupportingReplace
>
routingsupportingreplacewrapper
=
new
LambdaQueryWrapper
<>();
routingsupportingreplacewrapper
.
in
(
RoutingSupportingReplace:
:
getStrsupid
,
routingsupportingids
)
.
eq
(
RoutingSupportingReplace:
:
getIsdeleted
,
0
);
routingsupportingreplaces1
=
routingSupportingReplaceMapper
.
selectList
(
routingsupportingreplacewrapper
);
routingsupportingreplaces
.
addAll
(
routingsupportingreplaces1
);
List
<
String
>
materialIds
=
new
ArrayList
<>();
for
(
Routingsupporting
routingsupporting:
routingsupportings1
)
{
String
materialID1
=
routingsupporting
.
getMaterialId
();
Material
material
=
_materials
.
stream
()
.
filter
(
m
->
m
.
getId
().
equals
(
materialID1
))
.
findFirst
()
.
orElse
(
null
);
if
(
material
!=
null
&&!
material
.
getMaterialTypeName
().
equals
(
"MP"
))
{
materialIds
.
add
(
materialID1
);
}
}
List
<
Long
>
routingIds2
=
preloadSfRoutingBomCache
(
materialIds
,
headers
,
routingsupportings
,
routingsupportingreplaces
);
if
(
routingIds2
!=
null
)
{
routingIds
.
addAll
(
routingIds2
);
}
}
if
(
routingIds1
!=
null
)
{
routingIds
.
addAll
(
routingIds1
);
}
return
routingIds
;
}
private
List
<
Long
>
preloadSfRoutingCache
(
String
sceneId
,
List
<
Long
>
routingIds
)
{
List
<
RoutingDetail
>
RoutingDetails
=
null
;
List
<
RoutingDetailEquip
>
routingDetailEquips
=
null
;
List
<
RoutingDetailConnect
>
connections
=
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
()
.
in
(
RoutingDiscreteParam:
:
getRoutingDetailId
,
routingDetailIds
)
.
eq
(
RoutingDiscreteParam:
:
getIsDeleted
,
0
)
.
list
();
allroutingDiscreteParamsCache
.
put
(
sceneId
,
routingDiscreteParams
);
if
(
routingDetailEquips
!=
null
&&
routingDetailEquips
.
size
()
>
0
)
{
List
<
Long
>
equipIds
=
routingDetailEquips
.
stream
()
.
map
(
RoutingDetailEquip:
:
getEquipId
)
.
distinct
()
// 提取Exec_ID
.
collect
(
Collectors
.
toList
());
return
equipIds
;
}
}
return
null
;
}
/**
/**
* 构建多级BOM需求网络
* 构建多级BOM需求网络
* @return 所有物料需求列表
* @return 所有物料需求列表
*/
*/
public
List
<
OrderMaterialRequirement
>
buildMultiLevelRequirementNetwork
(
LocalDateTime
_baseTime
)
{
public
List
<
OrderMaterialRequirement
>
buildMultiLevelRequirementNetwork
(
LocalDateTime
_baseTime
)
{
baseTime
=
_baseTime
;
baseTime
=
_baseTime
;
List
<
OrderMaterialRequirement
>
allRequirements
=
new
ArrayList
<>();
List
<
OrderMaterialRequirement
>
allRequirements
=
new
ArrayList
<>();
...
@@ -734,4 +954,14 @@ if(routingIds.size()==0)
...
@@ -734,4 +954,14 @@ if(routingIds.size()==0)
orderMaterial
.
setArrivalTime
(
earliestTime
);
orderMaterial
.
setArrivalTime
(
earliestTime
);
}
}
public
void
clearCache
()
{
routingHeaderCache
.
clear
();
routingsupportingCache
.
clear
();
routingSupportingReplaceCache
.
clear
();
// 清空其他缓存集合(如allRoutingDetails等)
allRoutingDetailsCache
.
clear
();
allroutingDetailEquipsCache
.
clear
();
allroutingDetailconnectionsCache
.
clear
();
allroutingDiscreteParamsCache
.
clear
();
}
}
}
src/main/java/com/aps/service/LanuchService.java
View file @
3c0b67c4
...
@@ -36,8 +36,14 @@ public interface LanuchService {
...
@@ -36,8 +36,14 @@ public interface LanuchService {
List
<
RoutingDetail
>
getRoutingDetails
(
Integer
routingHeaderId
);
List
<
RoutingDetail
>
getRoutingDetails
(
Integer
routingHeaderId
);
List
<
RoutingDetail
>
getRoutingDetails
(
List
<
Long
>
routingHeaderIds
);
List
<
RoutingDetailEquip
>
getRoutingDetailEquip
(
Integer
routingHeaderId
,
String
routingCode
);
List
<
RoutingDetailEquip
>
getRoutingDetailEquip
(
Integer
routingHeaderId
,
String
routingCode
);
List
<
RoutingDetailEquip
>
getRoutingDetailEquip
(
List
<
Long
>
routingHeaderId
);
ProdProcessExec
createProcessExec
(
ProdLaunchOrder
prodOrderMain
,
ProdProcessExec
createProcessExec
(
ProdLaunchOrder
prodOrderMain
,
RoutingDetail
detail
,
RoutingDetail
detail
,
String
sceneId
,
List
<
RoutingDetailEquip
>
routingDetailEquip
);
String
sceneId
,
List
<
RoutingDetailEquip
>
routingDetailEquip
);
...
...
src/main/java/com/aps/service/impl/LanuchServiceImpl.java
View file @
3c0b67c4
...
@@ -644,6 +644,22 @@ public class LanuchServiceImpl implements LanuchService {
...
@@ -644,6 +644,22 @@ public class LanuchServiceImpl implements LanuchService {
return
routingDetails
;
return
routingDetails
;
}
}
public
List
<
RoutingDetail
>
getRoutingDetails
(
List
<
Long
>
routingHeaderIds
)
{
LambdaQueryWrapper
<
RoutingDetail
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
in
(
RoutingDetail:
:
getRoutingHeaderId
,
routingHeaderIds
)
.
eq
(
RoutingDetail:
:
getIsDeleted
,
0
)
// 添加 is_deleted=0 过滤条件
.
orderByAsc
(
RoutingDetail:
:
getTaskSeq
);
List
<
RoutingDetail
>
routingDetails
=
routingDetailMapper
.
selectList
(
wrapper
);
if
(
CollectionUtils
.
isEmpty
(
routingDetails
))
{
log
.
error
(
"工艺下无工序信息: {}"
,
routingHeaderIds
);
throw
new
RuntimeException
(
"工艺下无工序信息: "
+
routingHeaderIds
);
}
return
routingDetails
;
}
/**
/**
◦ 批量插入工序执行记录
◦ 批量插入工序执行记录
...
@@ -1080,6 +1096,20 @@ if (connection.getDestoperationid() !=null && connection.getSourceoperationid()
...
@@ -1080,6 +1096,20 @@ if (connection.getDestoperationid() !=null && connection.getSourceoperationid()
.
eq
(
RoutingDetailEquip:
:
getIsdeleted
,
0
)
.
eq
(
RoutingDetailEquip:
:
getIsdeleted
,
0
)
.
list
();
// 添加 is_deleted=0 过滤条件
.
list
();
// 添加 is_deleted=0 过滤条件
// if (CollectionUtils.isEmpty(detailEquips)) {
// log.error("工艺下无设备信息: {}", routingHeaderId);
// throw new RuntimeException("工艺下无设备信息: " + routingCode);
// }
return
detailEquips
;
}
public
List
<
RoutingDetailEquip
>
getRoutingDetailEquip
(
List
<
Long
>
routingHeaderId
)
{
List
<
RoutingDetailEquip
>
detailEquips
=
routingDetailEquipService
.
lambdaQuery
()
.
in
(
RoutingDetailEquip:
:
getRoutingHeaderId
,
routingHeaderId
)
.
eq
(
RoutingDetailEquip:
:
getIsdeleted
,
0
)
.
list
();
// 添加 is_deleted=0 过滤条件
// if (CollectionUtils.isEmpty(detailEquips)) {
// if (CollectionUtils.isEmpty(detailEquips)) {
// log.error("工艺下无设备信息: {}", routingHeaderId);
// log.error("工艺下无设备信息: {}", routingHeaderId);
// throw new RuntimeException("工艺下无设备信息: " + routingCode);
// throw new RuntimeException("工艺下无设备信息: " + routingCode);
...
...
src/main/java/com/aps/service/plan/PlanResultService.java
View file @
3c0b67c4
...
@@ -284,16 +284,24 @@ order.setDueDate(LocalDateTime.of(2025, 12, 1,0,0,0));
...
@@ -284,16 +284,24 @@ order.setDueDate(LocalDateTime.of(2025, 12, 1,0,0,0));
Map
<
Long
,
Double
>
machineIds
=(
Map
<
Long
,
Double
>)
list
.
get
(
3
);
Map
<
Long
,
Double
>
machineIds
=(
Map
<
Long
,
Double
>)
list
.
get
(
3
);
machines
=
machines
.
stream
().
filter
(
t
->
machineIds
.
containsKey
(
t
.
getId
())).
collect
(
Collectors
.
toList
());
// List<Long> equipIDs= materialRequirementService.preloadRoutingCache(SceneId,orders,Materials,globalParam.isIsCheckSf());
Set
machineIds1
=
machineIds
.
keySet
();
// if(equipIDs!=null&&equipIDs.size()>0)
// {
// machineIds1.addAll(equipIDs);
// }
machines
=
machines
.
stream
().
filter
(
t
->
machineIds1
.
contains
(
t
.
getId
())).
collect
(
Collectors
.
toList
());
for
(
Machine
machine
:
machines
){
for
(
Machine
machine
:
machines
){
Long
machineId
=
machine
.
getId
();
Long
machineId
=
machine
.
getId
();
if
(
machineIds
.
get
(
machineId
)>
3600
*
24
*
200
)
{
if
(
machineIds
.
get
(
machineId
)
!=
null
&&
machineIds
.
get
(
machineId
)
>
3600
*
24
*
200
)
{
int
day
=
(
int
)
(
machineIds
.
get
(
machineId
)
/
3600
/
24
)+
100
;
int
day
=
(
int
)
(
machineIds
.
get
(
machineId
)
/
3600
/
24
)+
100
;
List
<
TimeSegment
>
segments
=
machineScheduler
.
generateTimeSegment
(
machine
,
null
,
day
);
List
<
TimeSegment
>
segments
=
machineScheduler
.
generateTimeSegment
(
machine
,
null
,
day
);
machineScheduler
.
addSegmentsWithDeduplication
(
machine
,
segments
);
machineScheduler
.
addSegmentsWithDeduplication
(
machine
,
segments
);
}
}
}
}
...
@@ -1286,7 +1294,6 @@ private GlobalParam InitGlobalParam()
...
@@ -1286,7 +1294,6 @@ private GlobalParam InitGlobalParam()
}
}
}
}
GlobalCacheUtil
.
put
(
"material"
,
materials
,
10
,
TimeUnit
.
MINUTES
);
FileHelper
.
writeLogFile
(
"初始化物料-----------结束-------"
);
FileHelper
.
writeLogFile
(
"初始化物料-----------结束-------"
);
return
materials
;
return
materials
;
...
@@ -1418,6 +1425,7 @@ private GlobalParam InitGlobalParam()
...
@@ -1418,6 +1425,7 @@ private GlobalParam InitGlobalParam()
// });
// });
}
}
redisUtils
.
set
(
"material"
,
materials
);
redisUtils
.
set
(
"material"
,
materials
);
GlobalCacheUtil
.
put
(
"material"
,
materials
,
10
,
TimeUnit
.
MINUTES
);
return
materials
;
return
materials
;
}
}
...
@@ -1429,6 +1437,13 @@ private GlobalParam InitGlobalParam()
...
@@ -1429,6 +1437,13 @@ private GlobalParam InitGlobalParam()
return
entrys
;
return
entrys
;
}
}
private
void
InitRouting
(
String
SceneId
,
List
<
Order
>
ProdLaunchOrders
)
{
FileHelper
.
writeLogFile
(
"初始化工艺-----------开始-------"
);
FileHelper
.
writeLogFile
(
"初始化工艺-----------结束-------"
);
}
public
GenVO
convertGeneToGenVO
(
Gene
gene
,
LocalDateTime
baseTime
)
{
public
GenVO
convertGeneToGenVO
(
Gene
gene
,
LocalDateTime
baseTime
)
{
...
...
src/test/java/com/aps/demo/PlanResultServiceTest.java
View file @
3c0b67c4
...
@@ -37,16 +37,16 @@ public class PlanResultServiceTest {
...
@@ -37,16 +37,16 @@ public class PlanResultServiceTest {
// NSGAIIUtils nsgaiiUtils=new NSGAIIUtils();
// NSGAIIUtils nsgaiiUtils=new NSGAIIUtils();
// nsgaiiUtils.Test();
// nsgaiiUtils.Test();
// planResultService.execute2("FFAC5AA2E0B943D292933B28BDAB9068
");
planResultService
.
execute2
(
"FCB16D2535F24078BAD79729894C38D1
"
);
// planResultService.execute2("726D4C1A712B4B1393175BD44B775B66");
// planResultService.execute2("726D4C1A712B4B1393175BD44B775B66");
// planResultService.execute2("265F24B6DF3C40E4B17D193B0CC8AAF2");
// planResultService.execute2("265F24B6DF3C40E4B17D193B0CC8AAF2");
// LocalDateTime t= LocalDateTime.of(2026, 02, 14, 1, 25, 52);
// LocalDateTime t= LocalDateTime.of(2026, 02, 14, 1, 25, 52);
List
<
Integer
>
opids
=
new
ArrayList
<>();
//BCA6FA43FFA444D3952CF8F6E1EA291B
//
List<Integer> opids=new ArrayList<>();//BCA6FA43FFA444D3952CF8F6E1EA291B
opids
.
add
(
7
);
//
opids.add(7);
// planResultService.Move("27065EA0ECD14A81B7FAAFEF52273F93",opids,t,1265l,0);
// planResultService.Move("27065EA0ECD14A81B7FAAFEF52273F93",opids,t,1265l,0);
// planResultService.Redecode("27065EA0ECD14A81B7FAAFEF52273F93");
// planResultService.Redecode("27065EA0ECD14A81B7FAAFEF52273F93");
// planResultService.Redecode("CA71321FE55B4437A3900315692F9220");
// planResultService.Redecode("CA71321FE55B4437A3900315692F9220");
planResultService
.
Drag
(
"27065EA0ECD14A81B7FAAFEF52273F93"
,
opids
,
6
,
false
,
0
l
);
//
planResultService.Drag("27065EA0ECD14A81B7FAAFEF52273F93",opids,6,false,0l);
// 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));
...
...
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