Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
sap-service
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
曲欣亮
sap-service
Commits
d8bd91f5
Commit
d8bd91f5
authored
Jul 19, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
0b5f4281
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
107 additions
and
69 deletions
+107
-69
MaterialMasterServiceImpl.java
...o/services/material_master/MaterialMasterServiceImpl.java
+92
-68
XMLUtil.java
src/main/java/com/egolm/sso/util/XMLUtil.java
+12
-1
application-dev.yml
src/main/resources/application-dev.yml
+1
-0
application-pro.yml
src/main/resources/application-pro.yml
+1
-0
application-uat.yml
src/main/resources/application-uat.yml
+1
-0
No files found.
src/main/java/com/egolm/sso/services/material_master/MaterialMasterServiceImpl.java
View file @
d8bd91f5
...
@@ -9,104 +9,128 @@ import java.util.Map.Entry;
...
@@ -9,104 +9,128 @@ import java.util.Map.Entry;
import
javax.jws.WebService
;
import
javax.jws.WebService
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.egolm.sso.config.XRException
;
import
com.egolm.sso.services.CommonService
;
import
com.egolm.sso.services.CommonService
;
import
com.egolm.sso.services.material_master.Z_MT_SD_001_MATERIAL_MASTER.HEADER_SENDING
;
import
com.egolm.sso.services.material_master.Z_MT_SD_001_MATERIAL_MASTER.HEADER_SENDING
;
import
com.egolm.sso.services.material_master.Z_MT_SD_001_MATERIAL_MASTER.ITEM
;
import
com.egolm.sso.services.material_master.Z_MT_SD_001_MATERIAL_MASTER.ITEM
;
import
com.egolm.sso.services.material_master.Z_MT_SD_001_MATERIAL_MASTER.RECORD
;
import
com.egolm.sso.services.material_master.Z_MT_SD_001_MATERIAL_MASTER.RECORD
;
import
com.egolm.sso.util.DateUtil
;
import
com.egolm.sso.util.DateUtil
;
import
com.egolm.sso.util.FileUtil
;
import
com.egolm.sso.util.StringUtil
;
import
com.egolm.sso.util.StringUtil
;
import
com.egolm.sso.util.XMLUtil
;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
@Component
@Component
@WebService
(
serviceName
=
"MaterialMasterService"
,
targetNamespace
=
"http://material_master.sso.egolm.com"
,
endpointInterface
=
"com.egolm.sso.services.material_master.MaterialMasterService"
)
@WebService
(
serviceName
=
"MaterialMasterService"
,
targetNamespace
=
"http://material_master.sso.egolm.com"
,
endpointInterface
=
"com.egolm.sso.services.material_master.MaterialMasterService"
)
public
class
MaterialMasterServiceImpl
implements
MaterialMasterService
{
public
class
MaterialMasterServiceImpl
implements
MaterialMasterService
{
private
static
Log
logger
=
LogFactory
.
getLog
(
MaterialMasterService
.
class
);
@Autowired
@Autowired
JdbcTemplate
jdbcTemplate
;
JdbcTemplate
jdbcTemplate
;
@Autowired
@Autowired
CommonService
common
;
CommonService
common
;
@Value
(
"${xmlRoot}"
)
private
String
xmlRoot
;
@Override
@Override
@Transactional
@Transactional
public
void
execute
(
Z_MT_SD_001_MATERIAL_MASTER
Z_MT_SD_001_MATERIAL_MASTER
)
{
public
void
execute
(
Z_MT_SD_001_MATERIAL_MASTER
Z_MT_SD_001_MATERIAL_MASTER
)
{
System
.
out
.
println
(
new
Gson
().
toJson
(
Z_MT_SD_001_MATERIAL_MASTER
));
Date
now
=
new
Date
();
Date
now
=
new
Date
();
String
today
=
DateUtil
.
formatDate
(
now
,
DateUtil
.
FMT_DATE
);
boolean
isSuccess
=
true
;
System
.
out
.
println
(
new
Gson
().
toJson
(
Z_MT_SD_001_MATERIAL_MASTER
));
RECORD
RECORD
=
Z_MT_SD_001_MATERIAL_MASTER
.
getRECORD
();
String
dateString
=
DateUtil
.
formatDate
(
now
,
DateUtil
.
FMT_DATE
);
HEADER_SENDING
h
=
RECORD
.
getHEADER_SENDING
();
try
{
String
DIS_CODE
=
h
.
getKUNNR
();
RECORD
RECORD
=
Z_MT_SD_001_MATERIAL_MASTER
.
getRECORD
();
String
DATUM
=
h
.
getDATUM
();
HEADER_SENDING
h
=
RECORD
.
getHEADER_SENDING
();
String
UZEIT
=
h
.
getUZEIT
();
String
DIS_CODE
=
h
.
getKUNNR
();
String
DATUM
=
h
.
getDATUM
();
List
<
ITEM
>
items
=
RECORD
.
getITEM
();
String
UZEIT
=
h
.
getUZEIT
();
for
(
ITEM
item
:
items
)
{
String
GOODS_CODE
=
item
.
getMATNR
();
Map
<
String
,
Object
>
goods
=
getGoods
(
DIS_CODE
,
GOODS_CODE
);
if
(
goods
==
null
)
{
goods
=
new
HashMap
<>();
}
goods
.
put
(
"DIS_CODE"
,
DIS_CODE
);
goods
.
put
(
"DATUM"
,
DateUtil
.
parseDate
(
DATUM
,
DateUtil
.
FMT_DATE
));
goods
.
put
(
"UZEIT"
,
DateUtil
.
parseDate
(
UZEIT
,
DateUtil
.
FMT_TIME
));
goods
.
put
(
"GOODS_CODE"
,
GOODS_CODE
);
goods
.
put
(
"ROUGH_WEIGHT"
,
Double
.
valueOf
(
item
.
getBRGEW
()));
goods
.
put
(
"NET_WEIGHT"
,
Double
.
valueOf
(
item
.
getNTGEW
()));
goods
.
put
(
"WETGHT_UNIT"
,
item
.
getGEWEI
());
goods
.
put
(
"CATEGORY_CODE"
,
item
.
getPLINE
());
goods
.
put
(
"CREATION_DATE"
,
DateUtil
.
parseDate
(
item
.
getERSDA
(),
DateUtil
.
FMT_DATE
));
goods
.
put
(
"LAST_CHANGE_DATE"
,
DateUtil
.
parseDate
(
item
.
getLAEDA
(),
DateUtil
.
FMT_DATE
));
goods
.
put
(
"GOODS_NAME"
,
item
.
getNORMT
());
goods
.
put
(
"VMSTA"
,
item
.
getVMSTA
());
goods
.
put
(
"STKTYP"
,
item
.
getSTKTYP
());
goods
.
put
(
"SPEC"
,
item
.
getUMREZ
());
goods
.
put
(
"GOODS_NAME_EN"
,
item
.
getNORMT_EN
());
goods
.
put
(
"AUMNG"
,
item
.
getAUMNG
());
goods
.
put
(
"VRKME"
,
item
.
getVRKME
());
goods
.
put
(
"BASE_UNIT"
,
item
.
getMEINS
());
goods
.
put
(
"STATISTICS_UNIT"
,
item
.
getSCHME
());
// (统计单位--》发货单位)
goods
.
put
(
"LAENG"
,
item
.
getLAENG
());
goods
.
put
(
"BREIT"
,
item
.
getBREIT
());
goods
.
put
(
"HOEHE"
,
item
.
getHOEHE
());
goods
.
put
(
"MEABM"
,
item
.
getMEABM
());
goods
.
put
(
"LAENG_B"
,
item
.
getLAENG_B
());
goods
.
put
(
"BREIT_B"
,
item
.
getBREIT_B
());
goods
.
put
(
"HOEHE_B"
,
item
.
getHOEHE_B
());
goods
.
put
(
"MEABM_B"
,
item
.
getMEABM_B
());
goods
.
put
(
"PUBLIC"
,
item
.
getPUBLIC
());
goods
.
put
(
"INTERNET"
,
item
.
getINTERNET
());
/*
List
<
ITEM
>
items
=
RECORD
.
getITEM
();
goods.put("CATEGORY_NAME", "");// 品类名称
goods.put("PRODUCTION_LINE_CODE", "");// 产线(产地)编码
goods.put("PRODUCTION_LINE_NAME", "");// 产线(产地)名称
goods.put("MSTAV", "");// 停产标志2
goods.put("BARCODE", "");// 物料条码
goods.put("TAX_RATE", 0);// 税率
goods.put("GOODS_KEY", "");// 物料唯一码
goods.put("SEND_TIME", now);// 发送时间
goods.put("DIS_UPDATE_STATUS", "N");// 分销商更新结果(Y成功,N失败)
*/
Long
BATCHID
=
common
.
getNextval
(
today
+
"T_VEN_GOODS_BATCH_"
+
today
);
for
(
ITEM
item
:
items
)
{
String
BATCH
=
today
+
"-"
+
BATCHID
;
String
GOODS_CODE
=
item
.
getMATNR
();
goods
.
put
(
"TRACE_NO"
,
"sapmaterialmaster"
+
DateUtil
.
formatDate
(
now
,
DateUtil
.
FMT_DATETIME
));
Map
<
String
,
Object
>
goods
=
getGoods
(
DIS_CODE
,
GOODS_CODE
);
goods
.
put
(
"BATCH"
,
BATCH
);
if
(
goods
==
null
)
{
goods
.
put
(
"SEND_STATUS"
,
"N"
);
goods
=
new
HashMap
<>();
}
goods
.
put
(
"DIS_CODE"
,
DIS_CODE
);
goods
.
put
(
"DATUM"
,
DateUtil
.
parseDate
(
DATUM
,
DateUtil
.
FMT_DATE
));
goods
.
put
(
"UZEIT"
,
DateUtil
.
parseDate
(
UZEIT
,
DateUtil
.
FMT_TIME
));
goods
.
put
(
"GOODS_CODE"
,
GOODS_CODE
);
goods
.
put
(
"ROUGH_WEIGHT"
,
Double
.
valueOf
(
item
.
getBRGEW
()));
goods
.
put
(
"NET_WEIGHT"
,
Double
.
valueOf
(
item
.
getNTGEW
()));
goods
.
put
(
"WETGHT_UNIT"
,
item
.
getGEWEI
());
goods
.
put
(
"CATEGORY_CODE"
,
item
.
getPLINE
());
goods
.
put
(
"CREATION_DATE"
,
DateUtil
.
parseDate
(
item
.
getERSDA
(),
DateUtil
.
FMT_DATE
));
goods
.
put
(
"LAST_CHANGE_DATE"
,
DateUtil
.
parseDate
(
item
.
getLAEDA
(),
DateUtil
.
FMT_DATE
));
goods
.
put
(
"GOODS_NAME"
,
item
.
getNORMT
());
goods
.
put
(
"VMSTA"
,
item
.
getVMSTA
());
goods
.
put
(
"STKTYP"
,
item
.
getSTKTYP
());
goods
.
put
(
"SPEC"
,
item
.
getUMREZ
());
if
(
goods
.
get
(
"ID"
)
!=
null
)
{
goods
.
put
(
"GOODS_NAME_EN"
,
item
.
getNORMT_EN
());
updateGoods
(
goods
);
goods
.
put
(
"AUMNG"
,
item
.
getAUMNG
());
}
else
{
goods
.
put
(
"VRKME"
,
item
.
getVRKME
());
insertGoods
(
goods
);
goods
.
put
(
"BASE_UNIT"
,
item
.
getMEINS
());
goods
.
put
(
"STATISTICS_UNIT"
,
item
.
getSCHME
());
// (统计单位--》发货单位)
goods
.
put
(
"LAENG"
,
item
.
getLAENG
());
goods
.
put
(
"BREIT"
,
item
.
getBREIT
());
goods
.
put
(
"HOEHE"
,
item
.
getHOEHE
());
goods
.
put
(
"MEABM"
,
item
.
getMEABM
());
goods
.
put
(
"LAENG_B"
,
item
.
getLAENG_B
());
goods
.
put
(
"BREIT_B"
,
item
.
getBREIT_B
());
goods
.
put
(
"HOEHE_B"
,
item
.
getHOEHE_B
());
goods
.
put
(
"MEABM_B"
,
item
.
getMEABM_B
());
goods
.
put
(
"PUBLIC"
,
item
.
getPUBLIC
());
goods
.
put
(
"INTERNET"
,
item
.
getINTERNET
());
/*
goods.put("CATEGORY_NAME", "");// 品类名称
goods.put("PRODUCTION_LINE_CODE", "");// 产线(产地)编码
goods.put("PRODUCTION_LINE_NAME", "");// 产线(产地)名称
goods.put("MSTAV", "");// 停产标志2
goods.put("BARCODE", "");// 物料条码
goods.put("TAX_RATE", 0);// 税率
goods.put("GOODS_KEY", "");// 物料唯一码
goods.put("SEND_TIME", now);// 发送时间
goods.put("DIS_UPDATE_STATUS", "N");// 分销商更新结果(Y成功,N失败)
*/
Long
BATCHID
=
common
.
getNextval
(
dateString
+
"T_VEN_GOODS_BATCH_"
+
dateString
);
String
BATCH
=
dateString
+
"-"
+
BATCHID
;
goods
.
put
(
"TRACE_NO"
,
"sapmaterialmaster"
+
DateUtil
.
formatDate
(
now
,
DateUtil
.
FMT_DATETIME
));
goods
.
put
(
"BATCH"
,
BATCH
);
goods
.
put
(
"SEND_STATUS"
,
"N"
);
if
(
goods
.
get
(
"ID"
)
!=
null
)
{
updateGoods
(
goods
);
}
else
{
insertGoods
(
goods
);
}
}
}
catch
(
Exception
e
)
{
isSuccess
=
false
;
throw
new
XRException
(
"数据保存失败"
,
e
);
}
finally
{
String
xmlName
=
Z_MT_SD_001_MATERIAL_MASTER
.
getClass
().
getSimpleName
()
+
".xml"
;
try
{
String
xml
=
XMLUtil
.
toXml
(
Z_MT_SD_001_MATERIAL_MASTER
);
FileUtil
.
writeText
(
xmlRoot
+
"/sap/"
+
xmlName
+
"/"
+
DateUtil
.
formatDate
(
new
Date
(),
DateUtil
.
FMT_DATE
)
+
"/"
+
(
isSuccess
?
"success"
:
"error"
)
+
"/"
+
xmlName
+
"-"
+
common
.
getNextval
(
dateString
+
"T_VEN_GOODS_BATCH_"
+
dateString
)
+
".XML"
,
xml
);
}
catch
(
Exception
e
)
{
throw
new
XRException
(
"报文保存失败"
,
e
);
}
}
}
}
}
}
...
...
src/main/java/com/egolm/sso/util/XMLUtil.java
View file @
d8bd91f5
...
@@ -2,16 +2,18 @@ package com.egolm.sso.util;
...
@@ -2,16 +2,18 @@ package com.egolm.sso.util;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayInputStream
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.io.StringWriter
;
import
javax.xml.bind.JAXBContext
;
import
javax.xml.bind.JAXBContext
;
import
javax.xml.bind.JAXBException
;
import
javax.xml.bind.JAXBException
;
import
javax.xml.bind.Marshaller
;
import
javax.xml.bind.Unmarshaller
;
import
javax.xml.bind.Unmarshaller
;
import
com.egolm.sso.config.XRException
;
import
com.egolm.sso.config.XRException
;
import
com.thoughtworks.xstream.XStream
;
import
com.thoughtworks.xstream.XStream
;
public
class
XMLUtil
{
public
class
XMLUtil
{
public
static
<
T
>
T
toBean
(
String
XML
,
Class
<
T
>
requireType
)
{
public
static
<
T
>
T
toBean
(
String
XML
,
Class
<
T
>
requireType
)
{
XStream
xStream
=
new
XStream
();
XStream
xStream
=
new
XStream
();
XStream
.
setupDefaultSecurity
(
xStream
);
XStream
.
setupDefaultSecurity
(
xStream
);
...
@@ -35,5 +37,14 @@ public class XMLUtil {
...
@@ -35,5 +37,14 @@ public class XMLUtil {
throw
new
XRException
(
"XML转换错误"
,
e
);
throw
new
XRException
(
"XML转换错误"
,
e
);
}
}
}
}
public
static
String
toXml
(
Object
obj
)
throws
JAXBException
{
StringWriter
sw
=
new
StringWriter
();
JAXBContext
context
=
JAXBContext
.
newInstance
(
obj
.
getClass
());
Marshaller
marshaller
=
context
.
createMarshaller
();
marshaller
.
setProperty
(
Marshaller
.
JAXB_FORMATTED_OUTPUT
,
Boolean
.
TRUE
);
marshaller
.
marshal
(
obj
,
sw
);
return
sw
.
toString
();
}
}
}
src/main/resources/application-dev.yml
View file @
d8bd91f5
wsUsername
:
test
wsUsername
:
test
wsPassword
:
78258c537d6e4d5fb210a57d05619fb6
wsPassword
:
78258c537d6e4d5fb210a57d05619fb6
xmlRoot
:
xmlHistory
SAP
:
SAP
:
NO009
:
NO009
:
CRON
:
0 0 0 * * ?
CRON
:
0 0 0 * * ?
...
...
src/main/resources/application-pro.yml
View file @
d8bd91f5
wsUsername
:
schneider
wsUsername
:
schneider
wsPassword
:
f14d4a80f823438a875b1924384c944c
wsPassword
:
f14d4a80f823438a875b1924384c944c
xmlRoot
:
xmlHistory
SAP
:
SAP
:
NO009
:
NO009
:
CRON
:
0 0 0 * * ?
CRON
:
0 0 0 * * ?
...
...
src/main/resources/application-uat.yml
View file @
d8bd91f5
wsUsername
:
test
wsUsername
:
test
wsPassword
:
78258c537d6e4d5fb210a57d05619fb6
wsPassword
:
78258c537d6e4d5fb210a57d05619fb6
xmlRoot
:
xmlHistory
SAP
:
SAP
:
NO009
:
NO009
:
CRON
:
0 0 0 * * ?
CRON
:
0 0 0 * * ?
...
...
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