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
87592467
Commit
87592467
authored
Apr 24, 2026
by
DESKTOP-VKRD9QF\Administration
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
工单批量插入
parent
44e2b1c2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
135 additions
and
19 deletions
+135
-19
LanuchServiceImpl.java
src/main/java/com/aps/service/impl/LanuchServiceImpl.java
+135
-19
No files found.
src/main/java/com/aps/service/impl/LanuchServiceImpl.java
View file @
87592467
...
@@ -551,11 +551,9 @@ public class LanuchServiceImpl implements LanuchService {
...
@@ -551,11 +551,9 @@ public class LanuchServiceImpl implements LanuchService {
.
filter
(
Objects:
:
nonNull
)
.
filter
(
Objects:
:
nonNull
)
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
// 批量插入
// 批量插入,避免每个工单一次数据库往返
if
(!
launchOrderList
.
isEmpty
())
{
if
(!
launchOrderList
.
isEmpty
())
{
for
(
ProdLaunchOrder
order
:
launchOrderList
)
{
prodLaunchOrderService
.
saveBatch
(
launchOrderList
,
500
);
prodLaunchOrderService
.
save
(
order
);
// 单条插入
}
}
}
log
.
info
(
"成功处理{}条订单数据"
,
prodOrderMainList
.
size
());
log
.
info
(
"成功处理{}条订单数据"
,
prodOrderMainList
.
size
());
...
@@ -783,8 +781,68 @@ public class LanuchServiceImpl implements LanuchService {
...
@@ -783,8 +781,68 @@ public class LanuchServiceImpl implements LanuchService {
return
;
return
;
}
}
Set
<
Integer
>
routingIds
=
order
.
stream
()
.
map
(
ProdLaunchOrder:
:
getRoutingId
)
.
filter
(
Objects:
:
nonNull
)
.
collect
(
Collectors
.
toSet
());
if
(
routingIds
.
isEmpty
())
{
throw
new
SceneGenerationException
(
"新建场景失败:工单未配置工艺路线"
);
}
List
<
RoutingHeader
>
routingHeaders
=
routingHeaderMapper
.
selectList
(
new
LambdaQueryWrapper
<
RoutingHeader
>()
.
in
(
RoutingHeader:
:
getId
,
routingIds
)
.
eq
(
RoutingHeader:
:
getIsDeleted
,
0
));
Map
<
Integer
,
RoutingHeader
>
routingHeaderMap
=
routingHeaders
.
stream
()
.
collect
(
Collectors
.
toMap
(
RoutingHeader:
:
getId
,
Function
.
identity
(),
(
existing
,
replacement
)
->
existing
));
List
<
Long
>
routingHeaderIds
=
routingIds
.
stream
()
.
map
(
Integer:
:
longValue
)
.
collect
(
Collectors
.
toList
());
Map
<
Long
,
List
<
RoutingDetail
>>
routingDetailsByHeaderId
=
getRoutingDetails
(
routingHeaderIds
).
stream
()
.
collect
(
Collectors
.
groupingBy
(
RoutingDetail:
:
getRoutingHeaderId
));
routingDetailsByHeaderId
.
values
().
forEach
(
list
->
list
.
sort
(
Comparator
.
comparing
(
RoutingDetail:
:
getTaskSeq
)));
Map
<
Long
,
List
<
RoutingDetailEquip
>>
routingDetailEquipByHeaderId
=
getRoutingDetailEquip
(
routingHeaderIds
).
stream
()
.
collect
(
Collectors
.
groupingBy
(
RoutingDetailEquip:
:
getRoutingHeaderId
));
List
<
Equipinfo
>
equipinfoList
=
equipinfoService
.
lambdaQuery
()
.
eq
(
Equipinfo:
:
getIsdeleted
,
0
)
.
list
();
Map
<
Long
,
Equiptype1
>
equipTypeMap
=
GetEquipTypes
().
stream
()
.
collect
(
Collectors
.
toMap
(
Equiptype1:
:
getId
,
Function
.
identity
(),
(
existing
,
replacement
)
->
existing
));
List
<
ProdProcessExec
>
allProcessExecList
=
new
ArrayList
<>();
List
<
ProdEquipment
>
allProdEquipments
=
new
ArrayList
<>();
for
(
ProdLaunchOrder
prodOrderMain
:
order
)
{
for
(
ProdLaunchOrder
prodOrderMain
:
order
)
{
convertToProcessExec
(
prodOrderMain
,
sceneId
);
RoutingHeader
routingHeader
=
routingHeaderMap
.
get
(
prodOrderMain
.
getRoutingId
());
if
(
routingHeader
==
null
)
{
log
.
error
(
"未找到对应工艺: {}"
,
prodOrderMain
.
getRoutingId
());
throw
new
RuntimeException
(
"未找到对应工艺: "
+
prodOrderMain
.
getRoutingId
());
}
List
<
RoutingDetail
>
routingDetails
=
routingDetailsByHeaderId
.
get
(
routingHeader
.
getId
().
longValue
());
if
(
CollectionUtils
.
isEmpty
(
routingDetails
))
{
log
.
error
(
"工艺下无工序信息: {}"
,
routingHeader
.
getId
());
throw
new
RuntimeException
(
"工艺下无工序信息: "
+
routingHeader
.
getId
());
}
List
<
RoutingDetailEquip
>
routingDetailEquip
=
routingDetailEquipByHeaderId
.
getOrDefault
(
routingHeader
.
getId
().
longValue
(),
Collections
.
emptyList
());
List
<
ProdProcessExec
>
processExecList
=
routingDetails
.
stream
()
.
map
(
detail
->
createProcessExec
(
prodOrderMain
,
detail
,
sceneId
,
routingDetailEquip
,
routingHeader
,
equipTypeMap
))
.
collect
(
Collectors
.
toList
());
allProcessExecList
.
addAll
(
processExecList
);
allProdEquipments
.
addAll
(
batchInsertEquipMent
(
routingDetailEquip
,
sceneId
,
processExecList
,
false
,
equipinfoList
));
}
if
(!
CollectionUtils
.
isEmpty
(
allProcessExecList
))
{
prodProcessExecService
.
saveBatch
(
allProcessExecList
,
500
);
}
if
(!
CollectionUtils
.
isEmpty
(
allProdEquipments
))
{
prodEquipmentService
.
saveBatch
(
allProdEquipments
,
500
);
}
}
log
.
info
(
"完成{}个工单的工序转换"
,
order
.
size
());
log
.
info
(
"完成{}个工单的工序转换"
,
order
.
size
());
...
@@ -936,9 +994,17 @@ public class LanuchServiceImpl implements LanuchService {
...
@@ -936,9 +994,17 @@ public class LanuchServiceImpl implements LanuchService {
*/
*/
public
ProdProcessExec
createProcessExec
(
ProdLaunchOrder
prodOrderMain
,
public
ProdProcessExec
createProcessExec
(
ProdLaunchOrder
prodOrderMain
,
RoutingDetail
detail
,
RoutingDetail
detail
,
String
sceneId
,
List
<
RoutingDetailEquip
>
routingDetailEquip
,
String
sceneId
,
List
<
RoutingDetailEquip
>
routingDetailEquip
,
RoutingHeader
routingHeader
)
{
RoutingHeader
routingHeader
)
{
return
createProcessExec
(
prodOrderMain
,
detail
,
sceneId
,
routingDetailEquip
,
routingHeader
,
null
);
}
private
ProdProcessExec
createProcessExec
(
ProdLaunchOrder
prodOrderMain
,
RoutingDetail
detail
,
String
sceneId
,
List
<
RoutingDetailEquip
>
routingDetailEquip
,
RoutingHeader
routingHeader
,
Map
<
Long
,
Equiptype1
>
equipTypeMap
)
{
validateProcessDurationLimit
(
prodOrderMain
,
detail
,
routingDetailEquip
);
validateProcessDurationLimit
(
prodOrderMain
,
detail
,
routingDetailEquip
);
ProdProcessExec
prodProcessExec
=
new
ProdProcessExec
();
ProdProcessExec
prodProcessExec
=
new
ProdProcessExec
();
...
@@ -970,7 +1036,9 @@ public class LanuchServiceImpl implements LanuchService {
...
@@ -970,7 +1036,9 @@ public class LanuchServiceImpl implements LanuchService {
prodProcessExec
.
setSingleOut
(
detail
.
getSingleOut
());
prodProcessExec
.
setSingleOut
(
detail
.
getSingleOut
());
if
(
detail
.
getEquipTypeId
()
!=
null
)
if
(
detail
.
getEquipTypeId
()
!=
null
)
{
{
Equiptype1
equipType
=
equiptype1Service
.
lambdaQuery
().
eq
(
Equiptype1:
:
getId
,
detail
.
getEquipTypeId
()).
one
();
Equiptype1
equipType
=
equipTypeMap
==
null
?
equiptype1Service
.
lambdaQuery
().
eq
(
Equiptype1:
:
getId
,
detail
.
getEquipTypeId
()).
one
()
:
equipTypeMap
.
get
(
detail
.
getEquipTypeId
());
if
(
equipType
!=
null
)
{
if
(
equipType
!=
null
)
{
prodProcessExec
.
setEquipTypeName
(
equipType
.
getEquipTypeName
());
prodProcessExec
.
setEquipTypeName
(
equipType
.
getEquipTypeName
());
...
@@ -1162,16 +1230,26 @@ public class LanuchServiceImpl implements LanuchService {
...
@@ -1162,16 +1230,26 @@ public class LanuchServiceImpl implements LanuchService {
return
;
return
;
}
}
Set
<
Integer
>
routingIds
=
prodOrderMains
.
stream
()
.
map
(
ProdLaunchOrder:
:
getRoutingId
)
.
filter
(
Objects:
:
nonNull
)
.
collect
(
Collectors
.
toSet
());
List
<
RoutingDetailConnect
>
allConnections
=
routingIds
.
isEmpty
()
?
new
ArrayList
<>()
:
routingDetailConnectService
.
lambdaQuery
()
.
in
(
RoutingDetailConnect:
:
getRoutingHeaderId
,
routingIds
)
.
eq
(
RoutingDetailConnect:
:
getIsdeleted
,
0
)
.
list
();
Map
<
Long
,
List
<
RoutingDetailConnect
>>
connectionsByRoutingId
=
allConnections
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
RoutingDetailConnect:
:
getRoutingHeaderId
));
// 先批量获取所有需要的ProdProcessExec对象
// 先批量获取所有需要的ProdProcessExec对象
Set
<
Long
>
routingDetailIds
=
new
HashSet
<>();
Set
<
Long
>
routingDetailIds
=
new
HashSet
<>();
for
(
ProdLaunchOrder
order
:
prodOrderMains
)
{
for
(
RoutingDetailConnect
connection
:
allConnections
)
{
List
<
RoutingDetailConnect
>
connections
=
routingDetailConnectService
.
lambdaQuery
()
if
(
connection
.
getSourceoperationid
()
!=
null
)
{
.
eq
(
RoutingDetailConnect:
:
getRoutingHeaderId
,
order
.
getRoutingId
())
.
eq
(
RoutingDetailConnect:
:
getIsdeleted
,
0
)
.
list
();
for
(
RoutingDetailConnect
connection
:
connections
)
{
routingDetailIds
.
add
(
connection
.
getSourceoperationid
());
routingDetailIds
.
add
(
connection
.
getSourceoperationid
());
}
if
(
connection
.
getDestoperationid
()
!=
null
)
{
routingDetailIds
.
add
(
connection
.
getDestoperationid
());
routingDetailIds
.
add
(
connection
.
getDestoperationid
());
}
}
}
}
...
@@ -1191,7 +1269,7 @@ public class LanuchServiceImpl implements LanuchService {
...
@@ -1191,7 +1269,7 @@ public class LanuchServiceImpl implements LanuchService {
ProdProcessExec:
:
getExecId
,
ProdProcessExec:
:
getExecId
,
(
existing
,
replacement
)
->
existing
));
// 处理重复key的情况
(
existing
,
replacement
)
->
existing
));
// 处理重复key的情况
generateProcessRelations
(
prodOrderMains
,
sceneId
,
routingDetailIdToExecIdMap
);
generateProcessRelations
(
prodOrderMains
,
sceneId
,
routingDetailIdToExecIdMap
,
connectionsByRoutingId
);
...
@@ -1208,6 +1286,27 @@ public class LanuchServiceImpl implements LanuchService {
...
@@ -1208,6 +1286,27 @@ public class LanuchServiceImpl implements LanuchService {
*/
*/
public
void
generateProcessRelations
(
List
<
ProdLaunchOrder
>
prodOrderMains
,
String
sceneId
,
Map
<
String
,
String
>
routingDetailIdToExecIdMap
)
{
public
void
generateProcessRelations
(
List
<
ProdLaunchOrder
>
prodOrderMains
,
String
sceneId
,
Map
<
String
,
String
>
routingDetailIdToExecIdMap
)
{
Set
<
Integer
>
routingIds
=
Optional
.
ofNullable
(
prodOrderMains
)
.
orElse
(
Collections
.
emptyList
())
.
stream
()
.
map
(
ProdLaunchOrder:
:
getRoutingId
)
.
filter
(
Objects:
:
nonNull
)
.
collect
(
Collectors
.
toSet
());
Map
<
Long
,
List
<
RoutingDetailConnect
>>
connectionsByRoutingId
=
routingIds
.
isEmpty
()
?
new
HashMap
<>()
:
routingDetailConnectService
.
lambdaQuery
()
.
in
(
RoutingDetailConnect:
:
getRoutingHeaderId
,
routingIds
)
.
eq
(
RoutingDetailConnect:
:
getIsdeleted
,
0
)
.
list
()
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
RoutingDetailConnect:
:
getRoutingHeaderId
));
generateProcessRelations
(
prodOrderMains
,
sceneId
,
routingDetailIdToExecIdMap
,
connectionsByRoutingId
);
}
private
void
generateProcessRelations
(
List
<
ProdLaunchOrder
>
prodOrderMains
,
String
sceneId
,
Map
<
String
,
String
>
routingDetailIdToExecIdMap
,
Map
<
Long
,
List
<
RoutingDetailConnect
>>
connectionsByRoutingId
)
{
if
(
CollectionUtils
.
isEmpty
(
prodOrderMains
))
{
if
(
CollectionUtils
.
isEmpty
(
prodOrderMains
))
{
return
;
return
;
}
}
...
@@ -1215,7 +1314,10 @@ public class LanuchServiceImpl implements LanuchService {
...
@@ -1215,7 +1314,10 @@ public class LanuchServiceImpl implements LanuchService {
List
<
ProdOrderProcess
>
processRelations
=
new
java
.
util
.
ArrayList
<>();
List
<
ProdOrderProcess
>
processRelations
=
new
java
.
util
.
ArrayList
<>();
for
(
ProdLaunchOrder
prodOrderMain
:
prodOrderMains
)
{
for
(
ProdLaunchOrder
prodOrderMain
:
prodOrderMains
)
{
List
<
ProdOrderProcess
>
relations
=
createProcessRelations
(
prodOrderMain
,
sceneId
,
routingDetailIdToExecIdMap
);
List
<
RoutingDetailConnect
>
connections
=
prodOrderMain
.
getRoutingId
()
==
null
?
Collections
.
emptyList
()
:
connectionsByRoutingId
.
get
(
prodOrderMain
.
getRoutingId
().
longValue
());
List
<
ProdOrderProcess
>
relations
=
createProcessRelations
(
prodOrderMain
,
sceneId
,
routingDetailIdToExecIdMap
,
connections
);
processRelations
.
addAll
(
relations
);
processRelations
.
addAll
(
relations
);
}
}
...
@@ -1263,6 +1365,20 @@ public class LanuchServiceImpl implements LanuchService {
...
@@ -1263,6 +1365,20 @@ public class LanuchServiceImpl implements LanuchService {
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
}
}
private
List
<
ProdOrderProcess
>
createProcessRelations
(
ProdLaunchOrder
prodOrderMain
,
String
sceneId
,
Map
<
String
,
String
>
routingDetailIdToExecIdMap
,
List
<
RoutingDetailConnect
>
connections
)
{
if
(
CollectionUtils
.
isEmpty
(
connections
))
{
return
new
ArrayList
<>();
}
return
connections
.
stream
()
.
filter
(
connection
->
connection
.
getSourceoperationid
()
!=
null
)
.
map
(
connection
->
createProcessRelation
(
prodOrderMain
,
connection
,
sceneId
,
routingDetailIdToExecIdMap
))
.
collect
(
Collectors
.
toList
());
}
/**
/**
◦ 创建单个工序关系
◦ 创建单个工序关系
...
...
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