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
2dfa8789
Commit
2dfa8789
authored
Feb 06, 2026
by
DESKTOP-VKRD9QF\Administration
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://39.100.78.207:1213/tongli/hyh.apsj
parents
4275b051
5b14438d
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
196 additions
and
17 deletions
+196
-17
Initialization.java
src/main/java/com/aps/service/Algorithm/Initialization.java
+16
-0
MaterialRequirementService.java
...com/aps/service/Algorithm/MaterialRequirementService.java
+121
-2
ChromosomeDataService.java
...in/java/com/aps/service/common/ChromosomeDataService.java
+29
-10
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 @
2dfa8789
...
...
@@ -152,6 +152,12 @@ chromo.setOrders(new CopyOnWriteArrayList<>(orders));
// 选择“设备当前负载+工序加工时间”最小的机器(全局负载均衡)
List
<
MachineOption
>
optionalMachines
=
op
.
getMachineOptions
();
if
(
optionalMachines
==
null
||
optionalMachines
.
size
()==
0
)
{
throw
new
RuntimeException
(
"工序没有设置设备"
+
op
.
OrderCode
+
":"
+
op
.
getSequence
());
}
MachineOption
minLoadMachine
=
optionalMachines
.
stream
()
.
min
(
Comparator
.
comparingDouble
(
m
->
machineLoad
.
getOrDefault
(
m
.
getMachineId
(),
(
double
)
0
)
+
m
.
getProcessingTime
()))
.
orElseThrow
(()
->
new
NoSuchElementException
(
"MachineOption not found for machine: "
));
...
...
@@ -229,6 +235,11 @@ chromo.setOrders(new CopyOnWriteArrayList<>(orders));
// 选择“当前订单内设备负载+加工时间”最小的机器
List
<
MachineOption
>
optionalMachines
=
op
.
getMachineOptions
();
if
(
optionalMachines
==
null
||
optionalMachines
.
size
()==
0
)
{
throw
new
RuntimeException
(
"工序没有设置设备"
+
op
.
OrderCode
+
":"
+
op
.
getSequence
());
}
MachineOption
minLoadMachine
=
optionalMachines
.
stream
()
.
min
(
Comparator
.
comparingDouble
(
m
->
machineLoad
.
getOrDefault
(
m
.
getMachineId
(),
(
double
)
0
)
+
m
.
getProcessingTime
()))
...
...
@@ -295,6 +306,11 @@ chromo.setOrders(new CopyOnWriteArrayList<>(orders));
// 随机选择一道工序的可选机器(1-based顺序号)
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
;
ms
.
add
(
randomSeq
);
...
...
src/main/java/com/aps/service/Algorithm/MaterialRequirementService.java
View file @
2dfa8789
...
...
@@ -26,6 +26,7 @@ import java.util.*;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
java.util.stream.IntStream
;
...
...
@@ -65,8 +66,10 @@ public class MaterialRequirementService {
@Autowired
private
LanuchService
lanuchService
;
private
LocalDateTime
baseTime
;
@Autowired
private
PlanResourceService
planResourceService
;
@Autowired
private
Equiptype1Service
equiptype1Service
;
private
GlobalParam
globalParam
;
...
...
@@ -372,6 +375,96 @@ public class MaterialRequirementService {
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
<>();
routingDetailConnectwrapper
.
in
(
RoutingDetailConnect:
:
getRoutingHeaderId
,
routingIds
)
...
...
@@ -721,6 +814,7 @@ if(headers1==null)
ProdLaunchOrder
prodOrderMain
=
convertToLaunchOrder
(
order
,
sceneId
);
List
<
RoutingDetailEquip
>
finalRoutingDetailEquips
=
routingDetailEquips
;
Integer
departmentId
=
headers1
.
getDepartmentId
()
!=
null
?
headers1
.
getDepartmentId
()
:
null
;
List
<
ProdProcessExec
>
processExecList
=
RoutingDetails
.
stream
()
...
...
@@ -1443,6 +1537,31 @@ if(headers1==null)
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/common/ChromosomeDataService.java
View file @
2dfa8789
...
...
@@ -35,10 +35,12 @@ import java.util.*;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.stream.Collectors
;
import
java.math.RoundingMode
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.OffsetDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.time.format.DateTimeParseException
;
import
java.time.temporal.ChronoUnit
;
import
com.aps.service.MaterialInfoService
;
import
com.aps.entity.MaterialInfo
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
...
...
@@ -852,10 +854,7 @@ public class ChromosomeDataService {
LocalDateTime
dateTime
=
(
LocalDateTime
)
value
;
// 转换为OffsetDateTime以包含时区信息
OffsetDateTime
offsetDateTime
=
dateTime
.
atOffset
(
ZoneOffset
.
UTC
);
// 格式化时间为指定格式
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
);
String
formattedTime
=
offsetDateTime
.
format
(
formatter
);
formattedMap
.
put
(
key
,
formattedTime
);
formattedMap
.
put
(
key
,
offsetDateTime
);
}
else
{
formattedMap
.
put
(
key
,
value
);
}
...
...
@@ -891,10 +890,7 @@ public class ChromosomeDataService {
LocalDateTime
dateTime
=
(
LocalDateTime
)
value
;
// 转换为OffsetDateTime以包含时区信息
OffsetDateTime
offsetDateTime
=
dateTime
.
atOffset
(
ZoneOffset
.
UTC
);
// 格式化时间为指定格式
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
);
String
formattedTime
=
offsetDateTime
.
format
(
formatter
);
formattedData
.
put
(
field
.
getName
(),
formattedTime
);
formattedData
.
put
(
field
.
getName
(),
offsetDateTime
);
}
else
{
formattedData
.
put
(
field
.
getName
(),
value
);
}
...
...
@@ -1842,7 +1838,19 @@ public class ChromosomeDataService {
Field
field
=
getFieldIgnoreCase
(
item
.
getClass
(),
fn
);
if
(
field
!=
null
)
{
field
.
setAccessible
(
true
);
key
.
add
(
field
.
get
(
item
));
Object
value
=
field
.
get
(
item
);
// 处理日期类型字段,只保留年月日部分
if
(
value
instanceof
LocalDateTime
)
{
LocalDateTime
dateTime
=
(
LocalDateTime
)
value
;
// 截断时间到天,只保留日期部分
LocalDateTime
truncatedDateTime
=
dateTime
.
truncatedTo
(
ChronoUnit
.
DAYS
);
// 格式化时间为只包含日期的格式
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
);
String
formattedDate
=
truncatedDateTime
.
format
(
formatter
);
key
.
add
(
formattedDate
);
}
else
{
key
.
add
(
value
);
}
}
else
{
key
.
add
(
null
);
}
...
...
@@ -2105,8 +2113,12 @@ public class ChromosomeDataService {
// 尝试解析输入的时间字符串
LocalDateTime
inputDateTime
=
parseDateTimeString
(
fieldValue
);
if
(
inputDateTime
!=
null
)
{
// 截断时间到天,只比较日期部分
LocalDateTime
truncatedActualDateTime
=
actualDateTime
.
truncatedTo
(
ChronoUnit
.
DAYS
);
LocalDateTime
truncatedInputDateTime
=
inputDateTime
.
truncatedTo
(
ChronoUnit
.
DAYS
);
// 时间类型比较
int
compareResult
=
actualDateTime
.
compareTo
(
i
nputDateTime
);
int
compareResult
=
truncatedActualDateTime
.
compareTo
(
truncatedI
nputDateTime
);
switch
(
conditionType
)
{
case
Equal:
...
...
@@ -2197,6 +2209,13 @@ public class ChromosomeDataService {
return
LocalDateTime
.
parse
(
trimmed
,
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
));
}
// 处理只包含日期的格式
if
(
trimmed
.
length
()
==
10
&&
trimmed
.
contains
(
"-"
))
{
// 先解析为LocalDate,然后转换为LocalDateTime
LocalDate
localDate
=
LocalDate
.
parse
(
trimmed
,
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
));
return
localDate
.
atStartOfDay
();
}
// 处理ISO格式
return
LocalDateTime
.
parse
(
trimmed
,
DateTimeFormatter
.
ISO_DATE_TIME
);
}
catch
(
Exception
e
)
{
...
...
src/main/java/com/aps/service/impl/LanuchServiceImpl.java
View file @
2dfa8789
package
com
.
aps
.
service
.
impl
;
import
com.aps.common.exception.SceneGenerationException
;
import
com.aps.common.util.GlobalCacheUtil
;
import
com.aps.common.util.R
;
import
com.aps.common.util.SnowFlackIdWorker
;
import
com.aps.entity.*
;
...
...
@@ -27,6 +28,7 @@ import java.time.LocalDate;
import
java.time.LocalDateTime
;
import
java.time.LocalTime
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
...
...
@@ -1030,7 +1032,30 @@ public class LanuchServiceImpl implements LanuchService {
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 {
// return null;
// }
// 预加载数据并转换为Map以提高查询效率
List
<
Equiptype1
>
equipTypes
=
equiptype1Service
.
lambdaQuery
().
eq
(
Equiptype1:
:
getIsdeleted
,
0
).
list
();
List
<
Equiptype1
>
equipTypes
=
GetEquipTypes
();
Map
<
Long
,
Equiptype1
>
equipTypeMap
=
equipTypes
.
stream
()
.
collect
(
Collectors
.
toMap
(
Equiptype1:
:
getId
,
Function
.
identity
()));
List
<
PlanResource
>
list
=
planResourceService
.
lambdaQuery
()
.
eq
(
PlanResource:
:
getIsdeleted
,
0
)
.
list
();
List
<
PlanResource
>
list
=
GetPlanResources
();
Map
<
Integer
,
PlanResource
>
planResourceMap
=
list
.
stream
()
.
collect
(
Collectors
.
toMap
(
PlanResource:
:
getId
,
Function
.
identity
()));
Map
<
Integer
,
PlanResource
>
planResourceByReferenceIdMap
=
list
.
stream
()
...
...
src/test/java/com/aps/demo/PlanResultServiceTest.java
View file @
2dfa8789
...
...
@@ -39,7 +39,7 @@ public class PlanResultServiceTest {
// TestSortService sortService=new TestSortService();
// sortService.test1();
// nsgaiiUtils.Test();
planResultService
.
execute2
(
"
1BC8FFD1A7D54AE7AA75D2CBC7C08080
"
);
planResultService
.
execute2
(
"
72F484E1E19C4F10A56EABE3A48AD6CD
"
);
// planResultService.execute2("00E0C5D3E4AD4F36B56C39395906618D");
// 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