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
8b96c50c
Commit
8b96c50c
authored
Jun 24, 2024
by
江和松
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
物料清单全部提交时触发批量录入生产计划操作
parent
972a1055
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
191 additions
and
32 deletions
+191
-32
HGPZ005A.xml
src/main/java/com/baosight/hggp/hg/pz/sql/HGPZ005A.xml
+17
-14
HGPZTools.java
src/main/java/com/baosight/hggp/hg/pz/tools/HGPZTools.java
+14
-0
ServiceHGSC004A.java
...java/com/baosight/hggp/hg/sc/service/ServiceHGSC004A.java
+5
-1
HGSC005.xml
src/main/java/com/baosight/hggp/hg/sc/sql/HGSC005.xml
+20
-17
HGSC005A.xml
src/main/java/com/baosight/hggp/hg/sc/sql/HGSC005A.xml
+3
-0
HGSCTools.java
src/main/java/com/baosight/hggp/hg/sc/tools/HGSCTools.java
+132
-0
No files found.
src/main/java/com/baosight/hggp/hg/pz/sql/HGPZ005A.xml
View file @
8b96c50c
...
...
@@ -5,20 +5,20 @@
Version : 1.0
schema : hggp
tableName : HGPZ005A
ID BIGINT NOT NULL primarykey,
ACCOUNT_CODE VARCHAR,
DEP_CODE VARCHAR,
CREATED_BY VARCHAR,
CREATED_NAME VARCHAR,
CREATED_TIME VARCHAR,
UPDATED_BY VARCHAR,
UPDATED_NAME VARCHAR,
UPDATED_TIME VARCHAR,
DELETE_FLAG TINYINT,
PROCESS_CODE VARCHAR NOT NULL,
PROCESS_NAME VARCHAR NOT NULL,
COMPOSING_COEFF VARCHAR,
UNIT_COEFF VARCHAR,
ID BIGINT NOT NULL primarykey,
ACCOUNT_CODE VARCHAR,
DEP_CODE VARCHAR,
CREATED_BY VARCHAR,
CREATED_NAME VARCHAR,
CREATED_TIME VARCHAR,
UPDATED_BY VARCHAR,
UPDATED_NAME VARCHAR,
UPDATED_TIME VARCHAR,
DELETE_FLAG TINYINT,
PROCESS_CODE VARCHAR NOT NULL,
PROCESS_NAME VARCHAR NOT NULL,
COMPOSING_COEFF VARCHAR,
UNIT_COEFF VARCHAR,
PARENT_ID BIGINT
-->
<sqlMap
namespace=
"HGPZ005A"
>
...
...
@@ -85,6 +85,9 @@
<isNotEmpty
prepend=
" AND "
property=
"ids"
>
ID IN
<iterate
close=
")"
open=
"("
conjunction=
","
property=
"ids"
>
#ids[]#
</iterate>
</isNotEmpty>
<isNotEmpty
prepend=
" AND "
property=
"inventCodes"
>
INVENT_CODE IN
<iterate
close=
")"
open=
"("
conjunction=
","
property=
"inventCodes"
>
#inventCodes[]#
</iterate>
</isNotEmpty>
</sql>
<select
id=
"query"
parameterClass=
"java.util.HashMap"
...
...
src/main/java/com/baosight/hggp/hg/pz/tools/HGPZTools.java
View file @
8b96c50c
...
...
@@ -633,6 +633,20 @@ public class HGPZTools {
/**
* 通过存货编码查询存货工序*
*
* @param inventCodes
* @return
*/
public
static
List
<
HGPZ005A
>
queryByInventCodes
(
List
<
String
>
inventCodes
)
{
AssertUtils
.
isTrue
(
inventCodes
.
isEmpty
(),
"存货编码不能为空!"
);
Map
paramMap
=
new
HashMap
();
paramMap
.
put
(
"inventCodes"
,
inventCodes
);
List
<
HGPZ005A
>
results
=
DaoBase
.
getInstance
().
query
(
HGPZ005A
.
QUERY
,
paramMap
);
return
CollectionUtils
.
isEmpty
(
results
)
?
null
:
results
;
}
/**
* 通过存货编码查询存货工序*
*
* @param ids
* @return
*/
...
...
src/main/java/com/baosight/hggp/hg/sc/service/ServiceHGSC004A.java
View file @
8b96c50c
...
...
@@ -321,6 +321,7 @@ public class ServiceHGSC004A extends ServiceBase {
Map
<
String
,
Object
>
mapA
=
new
HashMap
<>();
mapA
.
put
(
"materialId"
,
hgsc004a
.
getMaterialId
());
List
<
HGSC004A
>
hgsc004AList
=
dao
.
query
(
HGSC004A
.
QUERY_BY_MATERIAL_ID
,
mapA
,
0
,
-
999999
);
List
<
HGSC005A
>
hgsc005AList
=
new
LinkedList
<>();
for
(
HGSC004A
hgsc004A
:
hgsc004AList
){
//子表
HGSC005A
hgsc005a
=
new
HGSC005A
();
...
...
@@ -332,7 +333,10 @@ public class ServiceHGSC004A extends ServiceBase {
}
else
{
hgsc005a
.
setProductType
(
ProductTypeEnum
.
PART
.
getCode
());
}
HGSCTools
.
THGSC005A
.
save
(
hgsc005a
);
hgsc005AList
.
add
(
hgsc005a
);
}
if
(
hgsc005AList
!=
null
&&
!
hgsc005AList
.
isEmpty
()){
HGSCTools
.
THGSC005A
.
saveList
(
hgsc005AList
);
}
}
...
...
src/main/java/com/baosight/hggp/hg/sc/sql/HGSC005.xml
View file @
8b96c50c
...
...
@@ -4,23 +4,23 @@
Version : 1.0
schema : hggp
tableName : HGSC005
id BIGINT NOT NULL primarykey,
mat_id BIGINT NOT NULL,
company_code VARCHAR NOT NULL,
company_name VARCHAR NOT NULL,
proj_code VARCHAR,
proj_name VARCHAR,
plan_code VARCHAR,
commit_status TINYINT,
id BIGINT NOT NULL primarykey,
mat_id BIGINT NOT NULL,
company_code VARCHAR NOT NULL,
company_name VARCHAR NOT NULL,
proj_code VARCHAR,
proj_name VARCHAR,
plan_code VARCHAR,
commit_status TINYINT,
finish_date VARCHAR,
account_code VARCHAR NOT NULL,
dep_code VARCHAR,
dep_name VARCHAR,
created_by VARCHAR,
created_name VARCHAR,
created_time VARCHAR,
updated_by VARCHAR,
updated_name VARCHAR,
account_code VARCHAR NOT NULL,
dep_code VARCHAR,
dep_name VARCHAR,
created_by VARCHAR,
created_name VARCHAR,
created_time VARCHAR,
updated_by VARCHAR,
updated_name VARCHAR,
updated_time VARCHAR
-->
<sqlMap
namespace=
"HGSC005"
>
...
...
@@ -85,12 +85,15 @@
<isNotEmpty
prepend=
" AND "
property=
"updatedTime"
>
updated_time = #updatedTime#
</isNotEmpty>
<isNotEmpty
prepend=
" AND "
property=
"matIds"
>
mat_id NOT IN
<iterate
close=
")"
open=
"("
conjunction=
","
property=
"matIds"
>
#matIds[]#
</iterate>
</isNotEmpty>
</sql>
<select
id=
"query"
parameterClass=
"java.util.HashMap"
resultClass=
"com.baosight.hggp.hg.sc.domain.HGSC005"
>
SELECT
id as "id",
id as "id",
mat_id as "matId",
<!-- 物料清单ID -->
company_code as "companyCode",
<!-- 公司编码 -->
company_name as "companyName",
<!-- 公司名称 -->
...
...
src/main/java/com/baosight/hggp/hg/sc/sql/HGSC005A.xml
View file @
8b96c50c
...
...
@@ -151,6 +151,9 @@
<isNotEmpty
prepend=
" AND "
property=
"planCodes"
>
plan_code IN
<iterate
close=
")"
open=
"("
conjunction=
","
property=
"planCodes"
>
#planCodes[]#
</iterate>
</isNotEmpty>
<isNotEmpty
prepend=
" AND "
property=
"productCodes"
>
product_code IN
<iterate
close=
")"
open=
"("
conjunction=
","
property=
"productCodes"
>
#productCodes[]#
</iterate>
</isNotEmpty>
</sql>
<select
id=
"query"
parameterClass=
"java.util.HashMap"
...
...
src/main/java/com/baosight/hggp/hg/sc/tools/HGSCTools.java
View file @
8b96c50c
...
...
@@ -409,6 +409,26 @@ public class HGSCTools {
return
CollectionUtils
.
isEmpty
(
results
)
?
null
:
results
;
}
private
static
List
<
HGSC005A
>
generatorNewPlanDetail
(
List
<
HGSC005A
>
hgsc005aList
){
List
<
String
>
inventCodes
=
hgsc005aList
.
stream
().
map
(
HGSC005A:
:
getProductCode
).
collect
(
Collectors
.
toList
());
//通过存货档案编码查询存货档案工序
List
<
HGPZ005A
>
hgpz005AList
=
HGPZTools
.
HgPz005A
.
queryByInventCodes
(
inventCodes
);
List
<
HGSC005A
>
hgsc005AList
=
new
ArrayList
<>();
hgsc005aList
.
forEach
(
hgsc005a
->{
List
<
HGPZ005A
>
filterHgpz005a
=
hgpz005AList
.
stream
().
filter
(
o
->
o
.
getInventCode
().
equals
(
hgsc005a
.
getProductCode
())).
collect
(
Collectors
.
toList
());
AssertUtils
.
isEmpty
(
filterHgpz005a
,
String
.
format
(
"产品[%s]工序不存在,请先到存货档案配置产品工序!"
,
hgsc005a
.
getProductName
()));
filterHgpz005a
.
forEach
(
pz
->
{
HGSC005A
obj
=
new
HGSC005A
();
BeanUtils
.
copyProperties
(
hgsc005a
,
obj
);
obj
.
setInventProcessId
(
pz
.
getId
());
obj
.
setProcessCode
(
pz
.
getProcessCode
());
obj
.
setProcessName
(
pz
.
getProcessName
());
obj
.
setProcessOrder
(
pz
.
getProcessOrder
());
hgsc005AList
.
add
(
obj
);
});
});
return
hgsc005AList
;
}
private
static
List
<
HGSC005A
>
generatorNewPlanDetail
(
HGSC005A
hgsc005a
){
//通过存货档案编码查询存货档案工序
...
...
@@ -427,6 +447,37 @@ public class HGSCTools {
return
hgsc005AList
;
}
private
static
Map
<
Long
,
Optional
<
HGSC005A
>>
queryOldPlanDetail
(
List
<
HGSC005A
>
hgsc005aList
){
List
<
String
>
productCodes
=
hgsc005aList
.
stream
().
map
(
HGSC005A:
:
getProductCode
).
collect
(
Collectors
.
toList
());
Map
paramMap
=
new
HashMap
();
//因为提交时肯定matid相同,直接取第一个即可
paramMap
.
put
(
HGSC005A
.
FIELD_mat_id
,
hgsc005aList
.
get
(
0
).
getMatId
());
paramMap
.
put
(
"productCodes"
,
productCodes
);
List
<
HGSC005A
>
oldObjList
=
DaoBase
.
getInstance
().
query
(
HGSC005A
.
QUERY
,
paramMap
);
Map
<
Long
,
Optional
<
HGSC005A
>>
returnOldObjMap
=
new
LinkedHashMap
<>();
hgsc005aList
.
forEach
(
hgsc005a
->{
//构建计划物料明细ID唯一
if
(
hgsc005a
.
getProductType
().
compareTo
(
ProductTypeEnum
.
STRUCT
.
getCode
())==
0
){
List
<
HGSC005A
>
oldObjFilterList
=
oldObjList
.
stream
().
filter
(
o
->
o
.
getProductCode
().
equals
(
hgsc005a
.
getProductCode
())
&&
o
.
getMatDetailId
().
compareTo
(
hgsc005a
.
getMatDetailId
())==
0
)
.
collect
(
Collectors
.
toList
());
Map
<
Long
,
Optional
<
HGSC005A
>>
oldObjMap
=
Optional
.
ofNullable
(
oldObjFilterList
).
orElse
(
new
ArrayList
<>()).
stream
()
.
collect
(
Collectors
.
groupingBy
(
HGSC005A:
:
getInventProcessId
,
Collectors
.
maxBy
(
Comparator
.
comparingInt
(
HGSC005A:
:
getQuantity
))));
returnOldObjMap
.
putAll
(
oldObjMap
);
}
else
{
List
<
HGSC005A
>
oldObjFilterList
=
oldObjList
.
stream
().
filter
(
o
->
o
.
getProductCode
().
equals
(
hgsc005a
.
getProductCode
()))
.
collect
(
Collectors
.
toList
());
Map
<
Long
,
Optional
<
HGSC005A
>>
oldObjMap
=
Optional
.
ofNullable
(
oldObjFilterList
).
orElse
(
new
ArrayList
<>()).
stream
()
.
collect
(
Collectors
.
groupingBy
(
HGSC005A:
:
getInventProcessId
,
Collectors
.
maxBy
(
Comparator
.
comparingInt
(
HGSC005A:
:
getQuantity
))));
oldObjMap
.
putAll
(
oldObjMap
);
}
});
return
returnOldObjMap
;
}
private
static
Map
<
Long
,
Optional
<
HGSC005A
>>
queryOldPlanDetail
(
HGSC005A
hgsc005a
){
Map
paramMap
=
new
HashMap
();
paramMap
.
put
(
HGSC005A
.
FIELD_mat_id
,
hgsc005a
.
getMatId
());
...
...
@@ -442,6 +493,36 @@ public class HGSCTools {
return
oldObjMap
;
}
public
static
List
<
HGSC005A
>
saveList
(
List
<
HGSC005A
>
hgsc005aList
){
checkUpdateData
(
hgsc005aList
);
constructObj
(
hgsc005aList
);
List
<
HGSC005A
>
hgsc005AList
=
generatorNewPlanDetail
(
hgsc005aList
);
Map
<
Long
,
Optional
<
HGSC005A
>>
oldObjMap
=
queryOldPlanDetail
(
hgsc005aList
);
List
<
HGSC005A
>
createList
=
new
ArrayList
<>();
List
<
HGSC005A
>
updateList
=
new
ArrayList
<>();
hgsc005AList
.
forEach
(
o
->
{
Optional
<
HGSC005A
>
op
=
oldObjMap
.
get
(
o
.
getInventProcessId
());
if
(
Objects
.
nonNull
(
op
)){
HGSC005A
uo
=
op
.
get
();
uo
.
setQuantity
(
uo
.
getQuantity
()+
o
.
getQuantity
());
uo
.
setUnfinishQuantity
(
uo
.
getUnfinishQuantity
()+
o
.
getQuantity
());
handleWeight
(
o
,
uo
);
updateList
.
add
(
uo
);
}
else
{
handleWeight
(
o
,
o
);
createList
.
add
(
o
);
}
});
if
(
CollectionUtils
.
isNotEmpty
(
createList
)){
DaoUtils
.
insertBatch
(
HGSC005A
.
INSERT
,
createList
);
}
if
(
CollectionUtils
.
isNotEmpty
(
updateList
)){
DaoUtils
.
updateBatch
(
HGSC005A
.
UPDATE
,
updateList
);
}
return
hgsc005aList
;
}
public
static
HGSC005A
save
(
HGSC005A
hgsc005a
){
checkUpdateData
(
hgsc005a
);
constructObj
(
hgsc005a
);
...
...
@@ -550,6 +631,40 @@ public class HGSCTools {
/**
* 校验修改的数据
*
* @param hgsc005aList
*/
private
static
void
checkUpdateData
(
List
<
HGSC005A
>
hgsc005aList
)
{
for
(
HGSC005A
hgsc005a
:
hgsc005aList
){
AssertUtils
.
isTrue
(
Objects
.
isNull
(
hgsc005a
.
getMatId
())||
hgsc005a
.
getMatId
()<=
0
,
"物料清单ID不能为空!"
);
AssertUtils
.
isTrue
(
Objects
.
isNull
(
hgsc005a
.
getMatDetailId
())||
hgsc005a
.
getMatDetailId
()<=
0
,
"物料清单明细ID不能为空!"
);
AssertUtils
.
isEmpty
(
hgsc005a
.
getProductCode
(),
"产品编码不能为空!"
);
AssertUtils
.
isEmpty
(
hgsc005a
.
getProductName
(),
"产品名称不能为空!"
);
AssertUtils
.
isTrue
(
Objects
.
isNull
(
hgsc005a
.
getTechFlowId
())||
hgsc005a
.
getTechFlowId
()<=
0
,
"工艺流程ID不能为空!"
);
AssertUtils
.
isTrue
(
Objects
.
isNull
(
hgsc005a
.
getQuantity
())||
hgsc005a
.
getQuantity
()<=
0
,
"数量不能为空!"
);
}
}
public
static
List
<
HGSC005A
>
constructObj
(
List
<
HGSC005A
>
hgsc005aList
){
HGSC005
hgsc005
=
THGSC005
.
queryByMatId
(
hgsc005aList
.
get
(
0
).
getMatId
());
hgsc005aList
.
forEach
(
hgsc005a
->
{
hgsc005a
.
setPlanCode
(
hgsc005
.
getPlanCode
());
hgsc005a
.
setCompanyCode
(
hgsc005
.
getCompanyCode
());
hgsc005a
.
setCompanyName
(
hgsc005
.
getCompanyName
());
hgsc005a
.
setDepCode
(
hgsc005
.
getDepCode
());
hgsc005a
.
setDepName
(
hgsc005
.
getDepName
());
hgsc005a
.
setProjCode
(
hgsc005
.
getProjCode
());
hgsc005a
.
setProjName
(
hgsc005
.
getProjName
());
hgsc005a
.
setFinishDate
(
hgsc005
.
getFinishDate
());
hgsc005a
.
setUnfinishQuantity
(
hgsc005a
.
getQuantity
());
hgsc005a
.
setFinishQuantity
(
0
);
hgsc005a
.
setUnfinishWeight
(
hgsc005a
.
getTotalWeight
());
});
return
hgsc005aList
;
}
/**
* 校验修改的数据
*
* @param hgsc005a
*/
private
static
void
checkUpdateData
(
HGSC005A
hgsc005a
)
{
...
...
@@ -561,6 +676,23 @@ public class HGSCTools {
AssertUtils
.
isTrue
(
Objects
.
isNull
(
hgsc005a
.
getQuantity
())||
hgsc005a
.
getQuantity
()<=
0
,
"数量不能为空!"
);
}
public
static
List
<
HGSC005A
>
constructObj
(
List
<
HGSC005A
>
hgsc005aList
,
HGSC005
hgsc005
){
hgsc005aList
.
forEach
(
hgsc005a
->{
hgsc005a
.
setPlanCode
(
hgsc005
.
getPlanCode
());
hgsc005a
.
setCompanyCode
(
hgsc005
.
getCompanyCode
());
hgsc005a
.
setCompanyName
(
hgsc005
.
getCompanyName
());
hgsc005a
.
setDepCode
(
hgsc005
.
getDepCode
());
hgsc005a
.
setDepName
(
hgsc005
.
getDepName
());
hgsc005a
.
setProjCode
(
hgsc005
.
getProjCode
());
hgsc005a
.
setProjName
(
hgsc005
.
getProjName
());
hgsc005a
.
setFinishDate
(
hgsc005
.
getFinishDate
());
hgsc005a
.
setUnfinishQuantity
(
hgsc005a
.
getQuantity
());
hgsc005a
.
setFinishQuantity
(
0
);
hgsc005a
.
setUnfinishWeight
(
hgsc005a
.
getTotalWeight
());
});
return
hgsc005aList
;
}
public
static
HGSC005A
constructObj
(
HGSC005A
hgsc005a
){
HGSC005
hgsc005
=
THGSC005
.
queryByMatId
(
hgsc005a
.
getMatId
());
hgsc005a
.
setPlanCode
(
hgsc005
.
getPlanCode
());
...
...
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