Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
hg-smart
Overview
Overview
Details
Activity
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
platform
hg-smart
Commits
8f52b7af
Commit
8f52b7af
authored
Jun 27, 2024
by
liuyang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
http://git.pseer.com:8800/platform/hg-smart
into dev-ly
parents
e5a6ba39
ac4c1c7c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
0 deletions
+78
-0
HGSC005A.java
src/main/java/com/baosight/hggp/hg/sc/domain/HGSC005A.java
+12
-0
HGSCTools.java
src/main/java/com/baosight/hggp/hg/sc/tools/HGSCTools.java
+66
-0
No files found.
src/main/java/com/baosight/hggp/hg/sc/domain/HGSC005A.java
View file @
8f52b7af
...
...
@@ -6,6 +6,7 @@ import com.baosight.iplat4j.core.data.DaoEPBase;
import
java.math.BigDecimal
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
com.baosight.iplat4j.core.util.StringUtils
;
...
...
@@ -142,6 +143,17 @@ public class HGSC005A extends DaoEPBase {
private
String
updatedName
=
" "
;
/* 修改人名称*/
private
String
updatedTime
=
" "
;
/* 更新时间*/
private
List
<
HGSC005A
>
partList
;
public
List
<
HGSC005A
>
getPartList
()
{
return
partList
;
}
public
void
setPartList
(
List
<
HGSC005A
>
partList
)
{
this
.
partList
=
partList
;
}
/**
* initialize the metadata.
*/
...
...
src/main/java/com/baosight/hggp/hg/sc/tools/HGSCTools.java
View file @
8f52b7af
...
...
@@ -36,6 +36,7 @@ import org.apache.commons.lang3.StringUtils;
import
java.math.BigDecimal
;
import
java.util.*
;
import
java.util.concurrent.atomic.AtomicReference
;
import
java.util.stream.Collector
;
import
java.util.stream.Collectors
;
import
static
com
.
baosight
.
hggp
.
common
.
AssignStatusEnum
.*;
...
...
@@ -478,6 +479,25 @@ public class HGSCTools {
return
returnOldObjMap
;
}
private
static
Map
<
String
,
HGSC005A
>
queryOldPartPlanDetail
(
List
<
HGSC005A
>
hgsc005aList
){
if
(
CollectionUtils
.
isNotEmpty
(
hgsc005aList
))
{
List
<
String
>
productCodes
=
hgsc005aList
.
stream
().
map
(
HGSC005A:
:
getProductCode
).
distinct
().
collect
(
Collectors
.
toList
());
Map
paramMap
=
new
HashMap
();
//因为提交时肯定matid相同,直接取第一个即可
paramMap
.
put
(
HGSC005A
.
FIELD_mat_id
,
hgsc005aList
.
get
(
0
).
getMatId
());
paramMap
.
put
(
"productCodes"
,
productCodes
);
paramMap
.
put
(
HGSC005A
.
FIELD_product_type
,
ProductTypeEnum
.
PART
.
getCode
());
List
<
HGSC005A
>
oldObjList
=
DaoBase
.
getInstance
().
query
(
HGSC005A
.
QUERY
,
paramMap
);
return
Optional
.
ofNullable
(
oldObjList
).
orElse
(
new
ArrayList
<>()).
stream
()
.
collect
(
Collectors
.
groupingBy
(
o
->
{
return
o
.
getProductCode
()
+
"#"
+
o
.
getInventProcessId
();
},
Collectors
.
collectingAndThen
(
Collectors
.
maxBy
(
Comparator
.
comparingInt
(
HGSC005A:
:
getQuantity
)),
Optional:
:
get
)));
}
return
null
;
}
private
static
Map
<
Long
,
Optional
<
HGSC005A
>>
queryOldPlanDetail
(
HGSC005A
hgsc005a
){
Map
paramMap
=
new
HashMap
();
paramMap
.
put
(
HGSC005A
.
FIELD_mat_id
,
hgsc005a
.
getMatId
());
...
...
@@ -617,6 +637,52 @@ public class HGSCTools {
if
(
CollectionUtils
.
isNotEmpty
(
updateList
)){
DaoUtils
.
updateBatch
(
HGSC005A
.
UPDATE
,
updateList
);
}
if
(
hgsc005a
.
getProductType
().
compareTo
(
ProductTypeEnum
.
STRUCT
.
getCode
())==
0
&&
CollectionUtils
.
isNotEmpty
(
hgsc005a
.
getPartList
())){
deletePartList
(
hgsc005a
.
getPartList
());
}
}
public
static
void
deletePartList
(
List
<
HGSC005A
>
hgsc005aList
){
List
<
Long
>
deleteIds
=
new
ArrayList
<>();
List
<
HGSC005A
>
updateList
=
new
ArrayList
<>();
if
(
CollectionUtils
.
isNotEmpty
(
hgsc005aList
))
{
Map
<
String
,
HGSC005A
>
hgsc005aMap
=
hgsc005aList
.
stream
().
collect
(
Collectors
.
toMap
(
HGSC005A:
:
getProductCode
,
o
->
o
,
(
o1
,
o2
)
->
{
o1
.
setQuantity
(
o1
.
getQuantity
()
+
o2
.
getQuantity
());
o1
.
setTotalWeight
(
o1
.
getSingleWeight
().
multiply
(
new
BigDecimal
(
o1
.
getQuantity
())));
return
o1
;
}));
checkUpdateData
(
hgsc005aList
);
Map
<
String
,
HGSC005A
>
oldObjMap
=
queryOldPartPlanDetail
(
hgsc005aList
);
if
(
Objects
.
nonNull
(
oldObjMap
))
{
oldObjMap
.
forEach
((
k
,
oldObj
)
->
{
if
(
Objects
.
nonNull
(
oldObj
))
{
HGSC005A
hgsc005a
=
hgsc005aMap
.
get
(
k
.
split
(
"#"
)[
0
]);
if
(
oldObj
.
getQuantity
()
-
hgsc005a
.
getQuantity
()
<=
0
)
{
handleWeight
(
hgsc005a
,
oldObj
);
deleteIds
.
add
(
oldObj
.
getId
());
}
else
{
oldObj
.
setQuantity
(
oldObj
.
getQuantity
()
-
hgsc005a
.
getQuantity
());
oldObj
.
setUnfinishQuantity
(
oldObj
.
getQuantity
()
-
oldObj
.
getFinishQuantity
());
handleWeight
(
hgsc005a
,
oldObj
);
updateList
.
add
(
oldObj
);
}
}
});
}
}
if
(
CollectionUtils
.
isNotEmpty
(
deleteIds
)){
Long
matId
=
hgsc005aList
.
get
(
0
).
getMatId
();
List
<
HGSC005A
>
dbList
=
queryByMatId
(
matId
);
//如果全部删除则删除主表
if
(
deleteIds
.
size
()
==
dbList
.
size
()){
DaoUtils
.
update
(
HGSC005
.
DELETE_BY_MAT_ID
,
new
HashMap
<
String
,
Object
>(){{
put
(
HGSC005
.
FIELD_mat_id
,
matId
);}});
}
DaoUtils
.
update
(
HGSC005A
.
BATCH_DELETE
,
new
HashMap
<
String
,
Object
>(){{
put
(
"ids"
,
deleteIds
);}});
}
if
(
CollectionUtils
.
isNotEmpty
(
updateList
)){
DaoUtils
.
updateBatch
(
HGSC005A
.
UPDATE
,
updateList
);
}
}
private
static
void
handleWeight
(
HGSC005A
hgsc005a
,
HGSC005A
target
){
...
...
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