Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
sso
Project
Project
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
曲欣亮
sso
Commits
889bc525
Commit
889bc525
authored
Jul 05, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://gitlab.egolm.com/key/sso.git
parents
357edd91
85584a96
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
185 additions
and
1 deletion
+185
-1
MaterialMasterServiceImpl.java
...com/egolm/sso/service/impl/MaterialMasterServiceImpl.java
+185
-1
No files found.
src/main/java/com/egolm/sso/service/impl/MaterialMasterServiceImpl.java
View file @
889bc525
package
com
.
egolm
.
sso
.
service
.
impl
;
package
com
.
egolm
.
sso
.
service
.
impl
;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
javax.jws.WebService
;
import
javax.jws.WebService
;
import
org.dom4j.Document
;
import
org.dom4j.DocumentException
;
import
org.dom4j.DocumentHelper
;
import
org.dom4j.Element
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
com.alibaba.fastjson.JSON
;
import
com.egolm.sso.service.CommonService
;
import
com.egolm.sso.service.CommonService
;
import
com.egolm.sso.service.MaterialMasterService
;
import
com.egolm.sso.service.MaterialMasterService
;
...
@@ -19,10 +33,180 @@ public class MaterialMasterServiceImpl implements MaterialMasterService {
...
@@ -19,10 +33,180 @@ public class MaterialMasterServiceImpl implements MaterialMasterService {
@Autowired
@Autowired
CommonService
common
;
CommonService
common
;
private
static
DateFormat
datef
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
private
static
DateFormat
datetimef
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
private
static
DateFormat
timef
=
new
SimpleDateFormat
(
"HHmmss"
);
@Override
@Override
public
void
execute
(
String
xml
)
{
public
void
execute
(
String
xml
)
{
System
.
out
.
println
(
common
.
getNextval
(
"Test"
));
System
.
out
.
println
(
common
.
getNextval
(
"Test"
));
System
.
out
.
println
(
xml
);
System
.
out
.
println
(
xml
);
Element
record
=
getRecordElement
(
xml
);
Map
<
String
,
String
>
header
=
new
HashMap
<>();
Element
headerSending
=
record
.
element
(
"HEADER_SENDING"
);
String
DIS_CODE
=
headerSending
.
elementText
(
"KUNNR"
);
String
DATUM
=
headerSending
.
elementText
(
"DATUM"
);
String
UZEIT
=
headerSending
.
elementText
(
"UZEIT"
);
List
<
Map
<
String
,
String
>>
items
=
new
ArrayList
<>();
List
<
Element
>
itemList
=
record
.
elements
(
"ITEM"
);
try
{
for
(
Element
element
:
itemList
)
{
String
GOODS_CODE
=
element
.
elementText
(
"MATNR"
);
Map
<
String
,
Object
>
goods
=
getGoods
(
DIS_CODE
,
GOODS_CODE
);
if
(
goods
==
null
)
{
goods
=
new
HashMap
<>();
}
/***************header**************/
goods
.
put
(
"DIS_CODE"
,
DIS_CODE
);
goods
.
put
(
"DATUM"
,
datef
.
parse
(
DATUM
));
goods
.
put
(
"UZEIT"
,
timef
.
parse
(
UZEIT
));
/***************header**************/
/***************item**************/
goods
.
put
(
"GOODS_CODE"
,
GOODS_CODE
);
goods
.
put
(
"ROUGH_WEIGHT"
,
element
.
elementText
(
"BRGEW"
));
goods
.
put
(
"NET_WEIGHT"
,
element
.
elementText
(
"NTGEW"
));
goods
.
put
(
"WETGHT_UNIT"
,
element
.
elementText
(
"GEWEI"
));
goods
.
put
(
"CATEGORY_CODE"
,
element
.
elementText
(
"PLINE"
));
goods
.
put
(
"CREATION_DATE"
,
datef
.
parse
(
element
.
elementText
(
"ERSDA"
)));
goods
.
put
(
"LAST_CHANGE_DATE"
,
datef
.
parse
(
element
.
elementText
(
"LAEDA"
)));
goods
.
put
(
"GOODS_NAME"
,
element
.
elementText
(
"NORMT"
));
goods
.
put
(
"VMSTA"
,
element
.
elementText
(
"VMSTA"
));
goods
.
put
(
"MSTAV"
,
element
.
elementText
(
"MSTAV"
));
goods
.
put
(
"STKTYP"
,
element
.
elementText
(
"STKTYP"
));
goods
.
put
(
"PRODUCTION_LINE_CODE"
,
element
.
elementText
(
"LIFNR"
));
goods
.
put
(
"SPEC"
,
element
.
elementText
(
"UMREZ"
));
/*******************新增字段,样例中没有******************/
goods
.
put
(
"GOODS_NAME_EN"
,
element
.
elementText
(
"NORMT_EN"
));
goods
.
put
(
"AUMNG"
,
element
.
elementText
(
"AUMNG"
));
goods
.
put
(
"VRKME"
,
element
.
elementText
(
"VRKME"
));
goods
.
put
(
"BASE_UNIT"
,
element
.
elementText
(
"MEINS"
));
goods
.
put
(
"STATISTICS_UNIT"
,
element
.
elementText
(
"SCHME"
));
//(统计单位--》发货单位)
goods
.
put
(
"LAENG"
,
element
.
elementText
(
"LAENG"
));
goods
.
put
(
"BREIT"
,
element
.
elementText
(
"BREIT"
));
goods
.
put
(
"HOEHE"
,
element
.
elementText
(
"HOEHE"
));
goods
.
put
(
"MEABM"
,
element
.
elementText
(
"MEABM"
));
goods
.
put
(
"LAENG_B"
,
element
.
elementText
(
"LAENG_B"
));
goods
.
put
(
"BREIT_B"
,
element
.
elementText
(
"BREIT_B"
));
goods
.
put
(
"HOEHE_B"
,
element
.
elementText
(
"HOEHE_B"
));
goods
.
put
(
"MEABM_B"
,
element
.
elementText
(
"MEABM_B"
));
goods
.
put
(
"PUBLIC"
,
element
.
elementText
(
"PUBLIC"
));
goods
.
put
(
"INTERNET"
,
element
.
elementText
(
"INTERNET"
));
/*******************新增字段,样例中没有******************/
/***************item**************/
String
BATCH
=
(
String
)
goods
.
get
(
"BATCH"
);
if
(
BATCH
==
null
||
""
.
equals
(
BATCH
.
trim
()))
{
BATCH
=
datef
.
format
(
new
Date
())+
"-1"
;
}
else
{
String
[]
ss
=
BATCH
.
split
(
"-"
);
String
newDate
=
datef
.
format
(
new
Date
());
int
v
=
1
;
if
(
ss
[
0
].
equals
(
newDate
))
{
v
=
Integer
.
valueOf
(
ss
[
1
])+
1
;
}
BATCH
=
newDate
+
"-"
+
v
;
}
goods
.
put
(
"BATCH"
,
BATCH
);
goods
.
put
(
"SEND_STATUS"
,
"N"
);
goods
.
put
(
"UPDATED"
,
datetimef
.
format
(
new
Date
()));
if
(
goods
.
get
(
"ID"
)!=
null
)
{
updateGoods
(
goods
);
}
else
{
insertGoods
(
goods
);
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
private
void
updateGoods
(
Map
<
String
,
Object
>
goods
)
{
goods
.
put
(
"UPDATEDBY"
,
""
);
String
sql
=
"update t_ven_goods set "
;
List
<
Object
>
args
=
new
ArrayList
<>();
for
(
Entry
<
String
,
Object
>
entry
:
goods
.
entrySet
())
{
String
key
=
entry
.
getKey
();
Object
value
=
entry
.
getValue
();
if
(!
key
.
equals
(
"ID"
))
{
sql
=
sql
+
key
+
" = ?, "
;
args
.
add
(
value
);
}
}
sql
=
sql
.
substring
(
0
,
sql
.
length
()-
2
);
sql
=
sql
+
" where ID = ?"
;
args
.
add
(
goods
.
get
(
"ID"
));
jdbcTemplate
.
update
(
sql
,
args
);
}
private
void
insertGoods
(
Map
<
String
,
Object
>
goods
)
{
String
countSql
=
"select count(1) from t_ven_goods"
;
Integer
count
=
jdbcTemplate
.
queryForObject
(
countSql
,
Integer
.
class
);
String
ID
=
System
.
currentTimeMillis
()
+
prependZero
(
count
,
5
);
goods
.
put
(
"ID"
,
ID
);
goods
.
put
(
"CREATED"
,
datetimef
.
format
(
new
Date
()));
goods
.
put
(
"CREATEDBY"
,
""
);
String
insertSql
=
"insert into t_ven_goods "
;
String
fieldSql
=
"("
;
String
valuesSql
=
"("
;
List
<
Object
>
values
=
new
ArrayList
<>();
for
(
Entry
<
String
,
Object
>
entry
:
goods
.
entrySet
())
{
fieldSql
=
fieldSql
+
entry
.
getKey
()
+
", "
;
valuesSql
=
valuesSql
+
"?, "
;
values
.
add
(
entry
.
getValue
());
}
fieldSql
=
fieldSql
.
substring
(
0
,
fieldSql
.
length
()-
2
);
valuesSql
=
valuesSql
.
substring
(
0
,
valuesSql
.
length
()-
2
);
insertSql
=
insertSql
+
fieldSql
+
") values "
+
valuesSql
+
")"
;
jdbcTemplate
.
update
(
insertSql
,
values
);
}
private
String
prependZero
(
int
Num
,
int
length
)
{
return
prependZero
(
Num
+
""
,
length
);
}
private
String
prependZero
(
String
Num
,
int
length
)
{
String
prepend
=
""
;
for
(
int
i
=
Num
.
length
();
i
<=
length
;
i
++)
{
prepend
=
prepend
+
"0"
;
}
return
prepend
+
Num
;
}
private
Map
<
String
,
Object
>
getGoods
(
String
DIS_CODE
,
String
GOODS_CODE
){
String
sql
=
"select * from t_ven_goods where DIS_CODE = ? and GOODS_CODE = ?"
;
List
<
Map
<
String
,
Object
>>
list
=
jdbcTemplate
.
queryForList
(
sql
,
DIS_CODE
,
GOODS_CODE
);
if
(
list
!=
null
&&
list
.
size
()>
0
)
{
return
list
.
get
(
0
);
}
return
null
;
}
public
static
Element
getRecordElement
(
String
xml
)
{
Document
doc
=
null
;
Element
el
=
null
;
try
{
doc
=
DocumentHelper
.
parseText
(
xml
);
Element
root
=
doc
.
getRootElement
();
el
=
root
.
element
(
"RECORD"
);
}
catch
(
DocumentException
e
)
{
e
.
printStackTrace
();
}
return
el
;
}
}
}
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