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
9c65aa9d
Commit
9c65aa9d
authored
Mar 20, 2026
by
DESKTOP-VKRD9QF\Administration
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
下发修改
parent
f18c43c3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
5 deletions
+35
-5
LanuchServiceImpl.java
src/main/java/com/aps/service/impl/LanuchServiceImpl.java
+35
-5
No files found.
src/main/java/com/aps/service/impl/LanuchServiceImpl.java
View file @
9c65aa9d
...
@@ -335,22 +335,23 @@ public class LanuchServiceImpl implements LanuchService {
...
@@ -335,22 +335,23 @@ public class LanuchServiceImpl implements LanuchService {
// .eq(ProdProcessExec::getSceneId, sceneId)
// .eq(ProdProcessExec::getSceneId, sceneId)
// .list();
// .list();
List
<
Entry
>
entrys
=
chromosome
.
getAllOperations
();
List
<
Entry
>
entrys
=
chromosome
.
getAllOperations
();
// 查询
当前场景已存在的 dispatch 记录
// 查询
全表中已存在的、未删除的 dispatch 记录(不再按场景区分)
List
<
Dispatch
>
existingDispatches
=
dispatchService
.
lambdaQuery
()
List
<
Dispatch
>
existingDispatches
=
dispatchService
.
lambdaQuery
()
.
eq
(
Dispatch:
:
getSceneId
,
sceneId
)
.
eq
(
Dispatch:
:
getIsDeleted
,
0L
)
.
eq
(
Dispatch:
:
getIsDeleted
,
0L
)
.
list
();
.
list
();
// 构建现有记录的映射 (
executeId + routingDetailId 作为
唯一标识)
// 构建现有记录的映射 (
mesCode + routingDetailId 作为全局
唯一标识)
Map
<
String
,
Dispatch
>
existingDispatchMap
=
existingDispatches
.
stream
()
Map
<
String
,
Dispatch
>
existingDispatchMap
=
existingDispatches
.
stream
()
.
collect
(
Collectors
.
toMap
(
.
collect
(
Collectors
.
toMap
(
dispatch
->
dispatch
.
get
ExecuteId
()
+
"_"
+
dispatch
.
getRoutingDetailId
(),
dispatch
->
dispatch
.
get
MesCode
()
+
"_"
+
dispatch
.
getRoutingDetailId
(),
dispatch
->
dispatch
,
dispatch
->
dispatch
,
(
existing
,
replacement
)
->
existing
(
existing
,
replacement
)
->
existing
));
));
List
<
Dispatch
>
toUpdateDispatches
=
new
ArrayList
<>();
List
<
Dispatch
>
toUpdateDispatches
=
new
ArrayList
<>();
List
<
Dispatch
>
toInsertDispatches
=
new
ArrayList
<>();
List
<
Dispatch
>
toInsertDispatches
=
new
ArrayList
<>();
// 记录已经处理过的 key,避免同一个 MES_CODE + ROUTING_DETAIL_ID 在一次下发中生成多条记录
Set
<
String
>
processedDispatchKeys
=
new
HashSet
<>();
// 遍历GAScheduleResult结果并转换为dispatch
// 遍历GAScheduleResult结果并转换为dispatch
for
(
GAScheduleResult
gaResult
:
chromosome
.
getResult
())
{
for
(
GAScheduleResult
gaResult
:
chromosome
.
getResult
())
{
...
@@ -364,7 +365,12 @@ public class LanuchServiceImpl implements LanuchService {
...
@@ -364,7 +365,12 @@ public class LanuchServiceImpl implements LanuchService {
continue
;
continue
;
}
}
String
dispatchKey
=
entry1
.
getId
()
+
"_"
+
entry1
.
getRoutingDetailId
();
// 只根据 MES_CODE(=orderId) + ROUTING_DETAIL_ID 唯一确定一条 dispatch
String
dispatchKey
=
gaResult
.
getOrderId
()
+
"_"
+
entry1
.
getRoutingDetailId
();
// 如果本次下发中已经处理过这个 key,则直接跳过,避免生成重复数据
if
(
processedDispatchKeys
.
contains
(
dispatchKey
))
{
continue
;
}
Dispatch
existingDispatch
=
existingDispatchMap
.
get
(
dispatchKey
);
Dispatch
existingDispatch
=
existingDispatchMap
.
get
(
dispatchKey
);
Dispatch
dispatch
;
Dispatch
dispatch
;
...
@@ -408,6 +414,30 @@ public class LanuchServiceImpl implements LanuchService {
...
@@ -408,6 +414,30 @@ public class LanuchServiceImpl implements LanuchService {
dispatch
.
setPartTaskReadyId
(
partTaskReadyId
);
dispatch
.
setPartTaskReadyId
(
partTaskReadyId
);
}
}
dispatch
.
setShopid
(
entry1
.
getDepartmentId
());
dispatch
.
setShopid
(
entry1
.
getDepartmentId
());
// 标记该 key 已处理,后续相同 key 不再生成新记录
processedDispatchKeys
.
add
(
dispatchKey
);
// 验证时间冲突:查所有场景该设备的dispatch,防止跨场景占用同一时间段
List
<
Dispatch
>
equipDispatches
=
dispatchService
.
lambdaQuery
()
.
eq
(
Dispatch:
:
getIsDeleted
,
0L
)
.
eq
(
Dispatch:
:
getEquipId
,
dispatch
.
getEquipId
())
.
list
();
for
(
Dispatch
existing
:
equipDispatches
)
{
if
(
existing
.
getMesCode
()
!=
null
&&
existing
.
getMesCode
().
equals
(
dispatch
.
getMesCode
()))
{
continue
;
// 同一工单,允许
}
if
(
dispatch
.
getBeginTime
()
!=
null
&&
dispatch
.
getEndTime
()
!=
null
&&
existing
.
getBeginTime
()
!=
null
&&
existing
.
getEndTime
()
!=
null
&&
dispatch
.
getBeginTime
().
isBefore
(
existing
.
getEndTime
())
&&
dispatch
.
getEndTime
().
isAfter
(
existing
.
getBeginTime
()))
{
throw
new
RuntimeException
(
String
.
format
(
"下发失败:设备%d在%s-%s已被工单%s占用,新工单%s无法下发"
,
dispatch
.
getEquipId
(),
existing
.
getBeginTime
(),
existing
.
getEndTime
(),
existing
.
getMesCode
(),
dispatch
.
getMesCode
()));
}
}
}
}
// 批量更新和插入 dispatch
// 批量更新和插入 dispatch
...
...
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