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
5b14438d
Commit
5b14438d
authored
Feb 05, 2026
by
Tong Li
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/tl'
parents
316ec27e
c3efeaed
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
167 additions
and
7 deletions
+167
-7
Initialization.java
src/main/java/com/aps/service/Algorithm/Initialization.java
+16
-0
MaterialRequirementService.java
...com/aps/service/Algorithm/MaterialRequirementService.java
+121
-2
LanuchServiceImpl.java
src/main/java/com/aps/service/impl/LanuchServiceImpl.java
+29
-4
PlanResultServiceTest.java
src/test/java/com/aps/demo/PlanResultServiceTest.java
+1
-1
No files found.
src/main/java/com/aps/service/Algorithm/Initialization.java
View file @
5b14438d
...
@@ -152,6 +152,12 @@ chromo.setOrders(new CopyOnWriteArrayList<>(orders));
...
@@ -152,6 +152,12 @@ chromo.setOrders(new CopyOnWriteArrayList<>(orders));
// 选择“设备当前负载+工序加工时间”最小的机器(全局负载均衡)
// 选择“设备当前负载+工序加工时间”最小的机器(全局负载均衡)
List
<
MachineOption
>
optionalMachines
=
op
.
getMachineOptions
();
List
<
MachineOption
>
optionalMachines
=
op
.
getMachineOptions
();
if
(
optionalMachines
==
null
||
optionalMachines
.
size
()==
0
)
{
throw
new
RuntimeException
(
"工序没有设置设备"
+
op
.
OrderCode
+
":"
+
op
.
getSequence
());
}
MachineOption
minLoadMachine
=
optionalMachines
.
stream
()
MachineOption
minLoadMachine
=
optionalMachines
.
stream
()
.
min
(
Comparator
.
comparingDouble
(
m
->
machineLoad
.
getOrDefault
(
m
.
getMachineId
(),
(
double
)
0
)
+
m
.
getProcessingTime
()))
.
min
(
Comparator
.
comparingDouble
(
m
->
machineLoad
.
getOrDefault
(
m
.
getMachineId
(),
(
double
)
0
)
+
m
.
getProcessingTime
()))
.
orElseThrow
(()
->
new
NoSuchElementException
(
"MachineOption not found for machine: "
));
.
orElseThrow
(()
->
new
NoSuchElementException
(
"MachineOption not found for machine: "
));
...
@@ -229,6 +235,11 @@ chromo.setOrders(new CopyOnWriteArrayList<>(orders));
...
@@ -229,6 +235,11 @@ chromo.setOrders(new CopyOnWriteArrayList<>(orders));
// 选择“当前订单内设备负载+加工时间”最小的机器
// 选择“当前订单内设备负载+加工时间”最小的机器
List
<
MachineOption
>
optionalMachines
=
op
.
getMachineOptions
();
List
<
MachineOption
>
optionalMachines
=
op
.
getMachineOptions
();
if
(
optionalMachines
==
null
||
optionalMachines
.
size
()==
0
)
{
throw
new
RuntimeException
(
"工序没有设置设备"
+
op
.
OrderCode
+
":"
+
op
.
getSequence
());
}
MachineOption
minLoadMachine
=
optionalMachines
.
stream
()
MachineOption
minLoadMachine
=
optionalMachines
.
stream
()
.
min
(
Comparator
.
comparingDouble
(
m
->
machineLoad
.
getOrDefault
(
m
.
getMachineId
(),
(
double
)
0
)
+
m
.
getProcessingTime
()))
.
min
(
Comparator
.
comparingDouble
(
m
->
machineLoad
.
getOrDefault
(
m
.
getMachineId
(),
(
double
)
0
)
+
m
.
getProcessingTime
()))
...
@@ -295,6 +306,11 @@ chromo.setOrders(new CopyOnWriteArrayList<>(orders));
...
@@ -295,6 +306,11 @@ chromo.setOrders(new CopyOnWriteArrayList<>(orders));
// 随机选择一道工序的可选机器(1-based顺序号)
// 随机选择一道工序的可选机器(1-based顺序号)
List
<
MachineOption
>
optionalMachines
=
op
.
getMachineOptions
();
List
<
MachineOption
>
optionalMachines
=
op
.
getMachineOptions
();
if
(
optionalMachines
==
null
||
optionalMachines
.
size
()==
0
)
{
throw
new
RuntimeException
(
"工序没有设置设备"
+
op
.
OrderCode
+
":"
+
op
.
getSequence
());
}
int
randomSeq
=
rnd
.
nextInt
(
optionalMachines
.
size
())
+
1
;
int
randomSeq
=
rnd
.
nextInt
(
optionalMachines
.
size
())
+
1
;
ms
.
add
(
randomSeq
);
ms
.
add
(
randomSeq
);
...
...
src/main/java/com/aps/service/Algorithm/MaterialRequirementService.java
View file @
5b14438d
...
@@ -26,6 +26,7 @@ import java.util.*;
...
@@ -26,6 +26,7 @@ import java.util.*;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
java.util.stream.IntStream
;
import
java.util.stream.IntStream
;
...
@@ -65,8 +66,10 @@ public class MaterialRequirementService {
...
@@ -65,8 +66,10 @@ public class MaterialRequirementService {
@Autowired
@Autowired
private
LanuchService
lanuchService
;
private
LanuchService
lanuchService
;
private
LocalDateTime
baseTime
;
private
LocalDateTime
baseTime
;
@Autowired
private
PlanResourceService
planResourceService
;
@Autowired
private
Equiptype1Service
equiptype1Service
;
private
GlobalParam
globalParam
;
private
GlobalParam
globalParam
;
...
@@ -372,6 +375,96 @@ public class MaterialRequirementService {
...
@@ -372,6 +375,96 @@ public class MaterialRequirementService {
routingDetailEquips
=
lanuchService
.
getRoutingDetailEquip
(
routingIds
);
routingDetailEquips
=
lanuchService
.
getRoutingDetailEquip
(
routingIds
);
List
<
Long
>
routingequipDetailIds
=
routingDetailEquips
.
stream
()
.
map
(
RoutingDetailEquip:
:
getRoutingDetailId
)
.
distinct
()
.
collect
(
Collectors
.
toList
());
List
<
RoutingDetail
>
RoutingDetailsn
=
RoutingDetails
.
stream
()
.
filter
(
t
->!
routingequipDetailIds
.
contains
(
t
.
getId
()))
.
collect
(
Collectors
.
toList
());
if
(
RoutingDetailsn
!=
null
&&
!
RoutingDetailsn
.
isEmpty
())
{
List
<
Equiptype1
>
equipTypes
=
GetEquipTypes
();
Map
<
Long
,
Equiptype1
>
equipTypeMap
=
equipTypes
.
stream
()
.
collect
(
Collectors
.
toMap
(
Equiptype1:
:
getId
,
Function
.
identity
()));
List
<
PlanResource
>
list
=
GetPlanResources
();
Map
<
Integer
,
PlanResource
>
planResourceByReferenceIdMap
=
list
.
stream
()
.
filter
(
pr
->
pr
.
getReferenceId
()
!=
null
)
.
collect
(
Collectors
.
toMap
(
PlanResource:
:
getReferenceId
,
Function
.
identity
()));
List
<
Equipinfo
>
equipinfo
=
GetEquipinfos
();
Map
<
Integer
,
Equipinfo
>
equipinfoMap
=
equipinfo
.
stream
()
.
collect
(
Collectors
.
toMap
(
Equipinfo:
:
getId
,
Function
.
identity
()));
Map
<
Integer
,
List
<
Equipinfo
>>
equipinfoByEquipTypeMap
=
equipinfo
.
stream
()
.
filter
(
e
->
e
.
getEquipType
()
!=
null
)
.
collect
(
Collectors
.
groupingBy
(
Equipinfo:
:
getEquipType
));
for
(
RoutingDetail
exec
:
RoutingDetailsn
)
{
try
{
// 获取machineId
Long
machineId
=
exec
.
getEquipTypeId
();
if
(
machineId
==
null
)
{
continue
;
}
// 使用Map快速查询设备列表
List
<
Equipinfo
>
matchedEquipments
=
equipinfoByEquipTypeMap
.
get
(
machineId
.
intValue
());
if
(
matchedEquipments
==
null
||
matchedEquipments
.
isEmpty
())
{
throw
new
RuntimeException
(
String
.
format
(
"未找到machineId=%d对应的设备信息"
,
machineId
));
}
// 遍历所有匹配的设备,创建ProdEquipment对象
for
(
Equipinfo
equipinfo1
:
matchedEquipments
)
{
RoutingDetailEquip
prodEquipment
=
new
RoutingDetailEquip
();
prodEquipment
.
setRoutingDetailId
(
exec
.
getId
());
prodEquipment
.
setRoutingHeaderId
(
exec
.
getRoutingHeaderId
());
// 使用Map快速查询,替代stream操作
PlanResource
planResource
=
planResourceByReferenceIdMap
.
get
(
equipinfo1
.
getId
());
if
(
planResource
!=
null
)
{
prodEquipment
.
setEquipId
(
planResource
.
getId
().
longValue
());
}
else
{
throw
new
RuntimeException
(
String
.
format
(
"未找到equipinfoId=%d对应的planResource信息"
,
equipinfo1
.
getId
()));
}
prodEquipment
.
setName
(
equipinfo1
.
getEquipName
());
// 使用Map快速查询
Equiptype1
equiptype1
=
equipTypeMap
.
get
(
machineId
);
if
(
equiptype1
!=
null
)
{
prodEquipment
.
setType1
(
equiptype1
.
getId
());
prodEquipment
.
setTypeName
(
equiptype1
.
getEquipTypeId
());
}
prodEquipment
.
setIsdeleted
(
0
);
// 设置其他属性
prodEquipment
.
setEfficiencyValue
(
1.0
);
// 默认效率值
prodEquipment
.
setSetupTime
(
0
);
// 默认准备时间
prodEquipment
.
setDuration
(
exec
.
getRuntime
());
prodEquipment
.
setOutputQuantity
(
exec
.
getSingleOut
());
// 设置execId
routingDetailEquips
.
add
(
prodEquipment
);
}
}
catch
(
Exception
e
)
{
throw
e
;
}
}
}
LambdaQueryWrapper
<
RoutingDetailConnect
>
routingDetailConnectwrapper
=
new
LambdaQueryWrapper
<>();
LambdaQueryWrapper
<
RoutingDetailConnect
>
routingDetailConnectwrapper
=
new
LambdaQueryWrapper
<>();
routingDetailConnectwrapper
.
in
(
RoutingDetailConnect:
:
getRoutingHeaderId
,
routingIds
)
routingDetailConnectwrapper
.
in
(
RoutingDetailConnect:
:
getRoutingHeaderId
,
routingIds
)
...
@@ -721,6 +814,7 @@ if(headers1==null)
...
@@ -721,6 +814,7 @@ if(headers1==null)
ProdLaunchOrder
prodOrderMain
=
convertToLaunchOrder
(
order
,
sceneId
);
ProdLaunchOrder
prodOrderMain
=
convertToLaunchOrder
(
order
,
sceneId
);
List
<
RoutingDetailEquip
>
finalRoutingDetailEquips
=
routingDetailEquips
;
List
<
RoutingDetailEquip
>
finalRoutingDetailEquips
=
routingDetailEquips
;
Integer
departmentId
=
headers1
.
getDepartmentId
()
!=
null
?
headers1
.
getDepartmentId
()
:
null
;
Integer
departmentId
=
headers1
.
getDepartmentId
()
!=
null
?
headers1
.
getDepartmentId
()
:
null
;
List
<
ProdProcessExec
>
processExecList
=
RoutingDetails
.
stream
()
List
<
ProdProcessExec
>
processExecList
=
RoutingDetails
.
stream
()
...
@@ -1443,6 +1537,31 @@ if(headers1==null)
...
@@ -1443,6 +1537,31 @@ if(headers1==null)
return
equipinfoList
;
return
equipinfoList
;
}
}
private
List
<
PlanResource
>
GetPlanResources
()
{
List
<
PlanResource
>
list
=(
List
<
PlanResource
>)
GlobalCacheUtil
.
get
(
"PlanResource"
);
if
(
list
==
null
)
{
list
=
planResourceService
.
lambdaQuery
()
.
eq
(
PlanResource:
:
getIsdeleted
,
0
)
.
list
();
GlobalCacheUtil
.
put
(
"PlanResource"
,
list
,
cachetimeout
,
TimeUnit
.
MINUTES
);
}
return
list
;
}
private
List
<
Equiptype1
>
GetEquipTypes
()
{
List
<
Equiptype1
>
equipTypes
=(
List
<
Equiptype1
>)
GlobalCacheUtil
.
get
(
"equipType"
);
if
(
equipTypes
==
null
)
{
equipTypes
=
equiptype1Service
.
lambdaQuery
().
eq
(
Equiptype1:
:
getIsdeleted
,
0
).
list
();
GlobalCacheUtil
.
put
(
"equipType"
,
equipTypes
,
cachetimeout
,
TimeUnit
.
MINUTES
);
}
return
equipTypes
;
}
...
...
src/main/java/com/aps/service/impl/LanuchServiceImpl.java
View file @
5b14438d
package
com
.
aps
.
service
.
impl
;
package
com
.
aps
.
service
.
impl
;
import
com.aps.common.exception.SceneGenerationException
;
import
com.aps.common.exception.SceneGenerationException
;
import
com.aps.common.util.GlobalCacheUtil
;
import
com.aps.common.util.R
;
import
com.aps.common.util.R
;
import
com.aps.common.util.SnowFlackIdWorker
;
import
com.aps.common.util.SnowFlackIdWorker
;
import
com.aps.entity.*
;
import
com.aps.entity.*
;
...
@@ -27,6 +28,7 @@ import java.time.LocalDate;
...
@@ -27,6 +28,7 @@ import java.time.LocalDate;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.time.LocalTime
;
import
java.time.LocalTime
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.function.Function
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -1030,7 +1032,30 @@ public class LanuchServiceImpl implements LanuchService {
...
@@ -1030,7 +1032,30 @@ public class LanuchServiceImpl implements LanuchService {
return
value
;
return
value
;
}
}
private
int
cachetimeout
=
60
;
private
List
<
Equiptype1
>
GetEquipTypes
()
{
List
<
Equiptype1
>
equipTypes
=(
List
<
Equiptype1
>)
GlobalCacheUtil
.
get
(
"equipType"
);
if
(
equipTypes
==
null
)
{
equipTypes
=
equiptype1Service
.
lambdaQuery
().
eq
(
Equiptype1:
:
getIsdeleted
,
0
).
list
();
GlobalCacheUtil
.
put
(
"equipType"
,
equipTypes
,
cachetimeout
,
TimeUnit
.
MINUTES
);
}
return
equipTypes
;
}
private
List
<
PlanResource
>
GetPlanResources
()
{
List
<
PlanResource
>
list
=(
List
<
PlanResource
>)
GlobalCacheUtil
.
get
(
"PlanResource"
);
if
(
list
==
null
)
{
list
=
planResourceService
.
lambdaQuery
()
.
eq
(
PlanResource:
:
getIsdeleted
,
0
)
.
list
();
GlobalCacheUtil
.
put
(
"PlanResource"
,
list
,
cachetimeout
,
TimeUnit
.
MINUTES
);
}
return
list
;
}
/**
/**
◦ 设备对照表
◦ 设备对照表
...
@@ -1043,13 +1068,13 @@ public class LanuchServiceImpl implements LanuchService {
...
@@ -1043,13 +1068,13 @@ public class LanuchServiceImpl implements LanuchService {
// return null;
// return null;
// }
// }
// 预加载数据并转换为Map以提高查询效率
// 预加载数据并转换为Map以提高查询效率
List
<
Equiptype1
>
equipTypes
=
equiptype1Service
.
lambdaQuery
().
eq
(
Equiptype1:
:
getIsdeleted
,
0
).
list
();
List
<
Equiptype1
>
equipTypes
=
GetEquipTypes
();
Map
<
Long
,
Equiptype1
>
equipTypeMap
=
equipTypes
.
stream
()
Map
<
Long
,
Equiptype1
>
equipTypeMap
=
equipTypes
.
stream
()
.
collect
(
Collectors
.
toMap
(
Equiptype1:
:
getId
,
Function
.
identity
()));
.
collect
(
Collectors
.
toMap
(
Equiptype1:
:
getId
,
Function
.
identity
()));
List
<
PlanResource
>
list
=
planResourceService
.
lambdaQuery
()
List
<
PlanResource
>
list
=
GetPlanResources
();
.
eq
(
PlanResource:
:
getIsdeleted
,
0
)
.
list
();
Map
<
Integer
,
PlanResource
>
planResourceMap
=
list
.
stream
()
Map
<
Integer
,
PlanResource
>
planResourceMap
=
list
.
stream
()
.
collect
(
Collectors
.
toMap
(
PlanResource:
:
getId
,
Function
.
identity
()));
.
collect
(
Collectors
.
toMap
(
PlanResource:
:
getId
,
Function
.
identity
()));
Map
<
Integer
,
PlanResource
>
planResourceByReferenceIdMap
=
list
.
stream
()
Map
<
Integer
,
PlanResource
>
planResourceByReferenceIdMap
=
list
.
stream
()
...
...
src/test/java/com/aps/demo/PlanResultServiceTest.java
View file @
5b14438d
...
@@ -39,7 +39,7 @@ public class PlanResultServiceTest {
...
@@ -39,7 +39,7 @@ public class PlanResultServiceTest {
// TestSortService sortService=new TestSortService();
// TestSortService sortService=new TestSortService();
// sortService.test1();
// sortService.test1();
// nsgaiiUtils.Test();
// nsgaiiUtils.Test();
planResultService
.
execute2
(
"
1BC8FFD1A7D54AE7AA75D2CBC7C08080
"
);
planResultService
.
execute2
(
"
72F484E1E19C4F10A56EABE3A48AD6CD
"
);
// planResultService.execute2("00E0C5D3E4AD4F36B56C39395906618D");
// planResultService.execute2("00E0C5D3E4AD4F36B56C39395906618D");
// planResultService.execute2("726D4C1A712B4B1393175BD44B775B66");
// planResultService.execute2("726D4C1A712B4B1393175BD44B775B66");
...
...
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