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
dd12d377
Commit
dd12d377
authored
Aug 08, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
a806f714
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
119 additions
and
61 deletions
+119
-61
SI004INVENTORYSyncOutServiceTask.java
...TORY_SyncOutService/SI004INVENTORYSyncOutServiceTask.java
+56
-27
SI011ACTUALSALESSyncOutServiceTask.java
...ES_SyncOutService/SI011ACTUALSALESSyncOutServiceTask.java
+63
-34
No files found.
src/main/java/com/egolm/sso/distributors/SI_004_INVENTORY_SyncOutService/SI004INVENTORYSyncOutServiceTask.java
View file @
dd12d377
...
...
@@ -3,6 +3,7 @@ package com.egolm.sso.distributors.SI_004_INVENTORY_SyncOutService;
import
java.io.File
;
import
java.math.BigInteger
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -16,11 +17,17 @@ import org.springframework.stereotype.Component;
import
org.springframework.transaction.annotation.Transactional
;
import
com.alibaba.fastjson.JSONObject
;
import
com.egolm.sso.config.XRException
;
import
com.egolm.sso.distributors.ServiceFactory
;
import
com.egolm.sso.services.CommonService
;
import
com.egolm.sso.services.CommonService.Page
;
import
com.egolm.sso.util.CollectionUtil
;
import
com.egolm.sso.util.DateUtil
;
import
com.egolm.sso.util.FileUtil
;
import
com.egolm.sso.util.StringUtil
;
import
com.egolm.sso.util.ThrowableUtil
;
import
com.egolm.sso.util.XMLUtil
;
import
com.google.gson.Gson
;
@Component
public
class
SI004INVENTORYSyncOutServiceTask
{
...
...
@@ -42,6 +49,9 @@ public class SI004INVENTORYSyncOutServiceTask {
@Value
(
"${WSDLPATH}"
)
private
String
WSDLPATH
;
@Value
(
"${xmlRoot}"
)
private
String
xmlRoot
;
@Transactional
//@Scheduled(cron="${cronSi004}")
public
void
execute
()
{
...
...
@@ -59,6 +69,8 @@ public class SI004INVENTORYSyncOutServiceTask {
}
private
void
sendData
(
SI004INVENTORYSyncOut
SI004INVENTORYSyncOut
)
{
Date
now
=
new
Date
();
String
timeString
=
DateUtil
.
formatDate
(
now
,
"yyyyMMddHHmmssSSS"
);
Page
page
=
new
Page
(
1L
,
1000L
,
new
String
[]
{
"DIS_CODE"
,
"INVENTORY_DATE"
});
String
sql
=
"SELECT * FROM t_dis_inventory WHERE SEND_STATUS = 'N'"
;
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<
Map
<
String
,
Object
>>();
...
...
@@ -71,35 +83,52 @@ public class SI004INVENTORYSyncOutServiceTask {
}
while
(
tmp
!=
null
&&
tmp
.
size
()
>
0
);
Map
<
String
,
List
<
Map
<
String
,
Object
>>>
datas
=
CollectionUtil
.
toGroupList
(
list
,
"DIS_CODE"
,
"INVENTORY_DATE"
);
for
(
List
<
Map
<
String
,
Object
>>
vList
:
datas
.
values
())
{
JSONObject
headerObject
=
new
JSONObject
(
vList
.
get
(
0
))
;
boolean
isSuccess
=
true
;
ZDTSD004INVENTORYSENDING
mt004INVENTORY
=
new
ZDTSD004INVENTORYSENDING
();
ZDTSD004INVENTORYSENDING
.
RECORD
RECORD
=
new
ZDTSD004INVENTORYSENDING
.
RECORD
();
ZDTSD004INVENTORYSENDING
.
RECORD
.
INVENTORYRECORD
INVENTORYRECORD
=
new
ZDTSD004INVENTORYSENDING
.
RECORD
.
INVENTORYRECORD
();
ZDTSD004INVENTORYSENDING
.
RECORD
.
INVENTORYRECORD
.
HEADER
INVENTORYRECORD_HEADER
=
new
ZDTSD004INVENTORYSENDING
.
RECORD
.
INVENTORYRECORD
.
HEADER
();
INVENTORYRECORD_HEADER
.
setKUNNR
(
headerObject
.
getString
(
"DIS_CODE"
));
INVENTORYRECORD_HEADER
.
setNAME1
(
headerObject
.
getString
(
"DIS_NAME"
));
INVENTORYRECORD_HEADER
.
setZDATE
(
headerObject
.
getString
(
"INVENTORY_DATE"
));
INVENTORYRECORD_HEADER
.
setZSPART
(
headerObject
.
getString
(
"MPG"
));
INVENTORYRECORD
.
setHEADER
(
INVENTORYRECORD_HEADER
);
RECORD
.
setINVENTORYRECORD
(
INVENTORYRECORD
);
mt004INVENTORY
.
setRECORD
(
RECORD
);
List
<
ZDTSD004INVENTORYSENDING
.
RECORD
.
INVENTORYRECORD
.
ITEM
>
NVENTORYR_ITEM_LIST
=
INVENTORYRECORD
.
getITEM
();
List
<
BigInteger
>
idList
=
new
ArrayList
<
BigInteger
>();
for
(
Map
<
String
,
Object
>
map
:
vList
)
{
JSONObject
jsonObject
=
new
JSONObject
(
map
);
idList
.
add
(
jsonObject
.
getBigInteger
(
"ID"
));
ZDTSD004INVENTORYSENDING
.
RECORD
.
INVENTORYRECORD
.
ITEM
NVENTORYR_ITEM
=
new
ZDTSD004INVENTORYSENDING
.
RECORD
.
INVENTORYRECORD
.
ITEM
();
NVENTORYR_ITEM
.
setMAKTX
(
jsonObject
.
getString
(
"DIS_SPEC"
));
NVENTORYR_ITEM
.
setMATNR
(
jsonObject
.
getString
(
"DIS_GOODS_CODE"
));
NVENTORYR_ITEM
.
setMENGE
(
jsonObject
.
getString
(
"DIS_QTY"
));
NVENTORYR_ITEM
.
setPOSNR
(
jsonObject
.
getString
(
"INVENTORY_LINE"
));
NVENTORYR_ITEM
.
setZPRIC
(
jsonObject
.
getString
(
"DIS_TAX_PRICE"
));
NVENTORYR_ITEM
.
setZVALU
(
jsonObject
.
getString
(
"DIS_TAX_AMOUNT"
));
NVENTORYR_ITEM_LIST
.
add
(
NVENTORYR_ITEM
);
try
{
JSONObject
headerObject
=
new
JSONObject
(
vList
.
get
(
0
));
ZDTSD004INVENTORYSENDING
.
RECORD
RECORD
=
new
ZDTSD004INVENTORYSENDING
.
RECORD
();
ZDTSD004INVENTORYSENDING
.
RECORD
.
INVENTORYRECORD
INVENTORYRECORD
=
new
ZDTSD004INVENTORYSENDING
.
RECORD
.
INVENTORYRECORD
();
ZDTSD004INVENTORYSENDING
.
RECORD
.
INVENTORYRECORD
.
HEADER
INVENTORYRECORD_HEADER
=
new
ZDTSD004INVENTORYSENDING
.
RECORD
.
INVENTORYRECORD
.
HEADER
();
INVENTORYRECORD_HEADER
.
setKUNNR
(
headerObject
.
getString
(
"DIS_CODE"
));
INVENTORYRECORD_HEADER
.
setNAME1
(
headerObject
.
getString
(
"DIS_NAME"
));
INVENTORYRECORD_HEADER
.
setZDATE
(
headerObject
.
getString
(
"INVENTORY_DATE"
));
INVENTORYRECORD_HEADER
.
setZSPART
(
headerObject
.
getString
(
"MPG"
));
INVENTORYRECORD
.
setHEADER
(
INVENTORYRECORD_HEADER
);
RECORD
.
setINVENTORYRECORD
(
INVENTORYRECORD
);
mt004INVENTORY
.
setRECORD
(
RECORD
);
List
<
ZDTSD004INVENTORYSENDING
.
RECORD
.
INVENTORYRECORD
.
ITEM
>
NVENTORYR_ITEM_LIST
=
INVENTORYRECORD
.
getITEM
();
List
<
BigInteger
>
idList
=
new
ArrayList
<
BigInteger
>();
for
(
Map
<
String
,
Object
>
map
:
vList
)
{
JSONObject
jsonObject
=
new
JSONObject
(
map
);
idList
.
add
(
jsonObject
.
getBigInteger
(
"ID"
));
ZDTSD004INVENTORYSENDING
.
RECORD
.
INVENTORYRECORD
.
ITEM
NVENTORYR_ITEM
=
new
ZDTSD004INVENTORYSENDING
.
RECORD
.
INVENTORYRECORD
.
ITEM
();
NVENTORYR_ITEM
.
setMAKTX
(
jsonObject
.
getString
(
"DIS_SPEC"
));
NVENTORYR_ITEM
.
setMATNR
(
jsonObject
.
getString
(
"DIS_GOODS_CODE"
));
NVENTORYR_ITEM
.
setMENGE
(
jsonObject
.
getString
(
"DIS_QTY"
));
NVENTORYR_ITEM
.
setPOSNR
(
jsonObject
.
getString
(
"INVENTORY_LINE"
));
NVENTORYR_ITEM
.
setZPRIC
(
jsonObject
.
getString
(
"DIS_TAX_PRICE"
));
NVENTORYR_ITEM
.
setZVALU
(
jsonObject
.
getString
(
"DIS_TAX_AMOUNT"
));
NVENTORYR_ITEM_LIST
.
add
(
NVENTORYR_ITEM
);
}
SI004INVENTORYSyncOut
.
si004INVENTORYSyncOut
(
mt004INVENTORY
);
String
updateSql
=
"UPDATE t_dis_inventory SET SEND_STATUS = 'Y', SEND_TIME = NOW() WHERE ID IN ("
+
StringUtil
.
join
(
"?"
,
", "
,
idList
.
size
(),
""
,
""
)
+
")"
;
jdbcTemplate
.
update
(
updateSql
,
idList
.
toArray
());
}
catch
(
Throwable
e
)
{
isSuccess
=
false
;
throw
new
XRException
(
ThrowableUtil
.
getCaused
(
e
).
getMessage
()
+
" -- "
+
timeString
,
e
);
}
finally
{
String
xmlName
=
"004_INVENTORY"
;
try
{
String
xml
=
XMLUtil
.
toXml
(
mt004INVENTORY
);
String
xmlFullName
=
xmlRoot
+
"/sap/"
+
xmlName
+
"/"
+
DateUtil
.
formatDate
(
now
,
DateUtil
.
FMT_DATE
)
+
"/"
+
(
isSuccess
?
"success"
:
"error"
)
+
"/"
+
xmlName
+
"-"
+
timeString
+
".XML"
;
FileUtil
.
writeText
(
xmlFullName
,
xml
);
String
json
=
new
Gson
().
toJson
(
mt004INVENTORY
);
FileUtil
.
writeText
(
xmlFullName
+
".JSON"
,
json
);
}
catch
(
Exception
e
)
{
throw
new
XRException
(
ThrowableUtil
.
getCaused
(
e
).
getMessage
(),
e
);
}
}
SI004INVENTORYSyncOut
.
si004INVENTORYSyncOut
(
mt004INVENTORY
);
String
updateSql
=
"UPDATE t_dis_inventory SET SEND_STATUS = 'Y', SEND_TIME = NOW() WHERE ID IN ("
+
StringUtil
.
join
(
"?"
,
", "
,
idList
.
size
(),
""
,
""
)
+
")"
;
jdbcTemplate
.
update
(
updateSql
,
idList
.
toArray
());
}
}
...
...
src/main/java/com/egolm/sso/distributors/SI_011_ACTUAL_SALES_SyncOutService/SI011ACTUALSALESSyncOutServiceTask.java
View file @
dd12d377
...
...
@@ -3,6 +3,7 @@ package com.egolm.sso.distributors.SI_011_ACTUAL_SALES_SyncOutService;
import
java.io.File
;
import
java.math.BigInteger
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -16,11 +17,17 @@ import org.springframework.stereotype.Component;
import
org.springframework.transaction.annotation.Transactional
;
import
com.alibaba.fastjson.JSONObject
;
import
com.egolm.sso.config.XRException
;
import
com.egolm.sso.distributors.ServiceFactory
;
import
com.egolm.sso.services.CommonService
;
import
com.egolm.sso.services.CommonService.Page
;
import
com.egolm.sso.util.CollectionUtil
;
import
com.egolm.sso.util.DateUtil
;
import
com.egolm.sso.util.FileUtil
;
import
com.egolm.sso.util.StringUtil
;
import
com.egolm.sso.util.ThrowableUtil
;
import
com.egolm.sso.util.XMLUtil
;
import
com.google.gson.Gson
;
@Component
public
class
SI011ACTUALSALESSyncOutServiceTask
{
...
...
@@ -42,6 +49,9 @@ public class SI011ACTUALSALESSyncOutServiceTask {
@Value
(
"${WSDLPATH}"
)
private
String
WSDLPATH
;
@Value
(
"${xmlRoot}"
)
private
String
xmlRoot
;
@Transactional
//@Scheduled(cron="${cronSi011}")
public
void
execute
()
{
...
...
@@ -59,6 +69,8 @@ public class SI011ACTUALSALESSyncOutServiceTask {
}
private
void
sendData
(
SI011ACTUALSALESSyncOut
SI011ACTUALSALESSyncOut
)
{
Date
now
=
new
Date
();
String
timeString
=
DateUtil
.
formatDate
(
now
,
"yyyyMMddHHmmssSSS"
);
Page
page
=
new
Page
(
1L
,
1000L
,
new
String
[]
{
"DIS_CODE"
,
"SALES_NO"
});
String
sql
=
"SELECT * FROM t_dis_sales WHERE SEND_STATUS = 'N'"
;
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<
Map
<
String
,
Object
>>();
...
...
@@ -71,42 +83,59 @@ public class SI011ACTUALSALESSyncOutServiceTask {
}
while
(
tmp
!=
null
&&
tmp
.
size
()
>
0
);
Map
<
String
,
List
<
Map
<
String
,
Object
>>>
datas
=
CollectionUtil
.
toGroupList
(
list
,
"DIS_CODE"
,
"SALES_NO"
);
for
(
List
<
Map
<
String
,
Object
>>
vList
:
datas
.
values
())
{
boolean
isSuccess
=
true
;
ZDTSD011ACTUALSALESSENDING
mt011ACTUALSALES
=
new
ZDTSD011ACTUALSALESSENDING
();
ZDTSD011ACTUALSALESSENDING
.
RECORD
RECORD
=
new
ZDTSD011ACTUALSALESSENDING
.
RECORD
();
mt011ACTUALSALES
.
setRECORD
(
RECORD
);
ZDTSD011ACTUALSALESSENDING
.
RECORD
.
HEADER
header
=
new
ZDTSD011ACTUALSALESSENDING
.
RECORD
.
HEADER
();
List
<
ZDTSD011ACTUALSALESSENDING
.
RECORD
.
ITEM
>
itemList
=
RECORD
.
getITEM
();
JSONObject
headerObject
=
new
JSONObject
(
vList
.
get
(
0
));
header
.
setAUBEL
(
headerObject
.
getString
(
"SALES_NO"
));
header
.
setFXSNA
(
headerObject
.
getString
(
"DIS_NAME"
));
header
.
setFXSNO
(
headerObject
.
getString
(
"DIS_CODE"
));
header
.
setSDATE
(
headerObject
.
getString
(
"SALES_DATE"
));
RECORD
.
setHEADER
(
header
);
List
<
BigInteger
>
idList
=
new
ArrayList
<
BigInteger
>();
for
(
Map
<
String
,
Object
>
itemMap
:
vList
)
{
JSONObject
itemObject
=
new
JSONObject
(
itemMap
);
idList
.
add
(
itemObject
.
getBigInteger
(
"ID"
));
ZDTSD011ACTUALSALESSENDING
.
RECORD
.
ITEM
item
=
new
ZDTSD011ACTUALSALESSENDING
.
RECORD
.
ITEM
();
item
.
setCUSNA
(
itemObject
.
getString
(
"DIS_STORE_NAME"
));
item
.
setCUSNO
(
itemObject
.
getString
(
"DIS_STORE_CODE"
));
item
.
setCUSTY
(
itemObject
.
getString
(
"DIS_STORE_TYPE"
));
item
.
setFAMOU
(
itemObject
.
getString
(
"DIS_TAX_AMOUNT"
));
item
.
setFCITY
(
itemObject
.
getString
(
"DIS_STORE_CITY"
));
item
.
setFDNO
(
itemObject
.
getString
(
"SALES_LINE"
));
item
.
setFITEM
(
itemObject
.
getString
(
"DIS_GOODS_CODE"
));
item
.
setFPRIC
(
itemObject
.
getString
(
"DIS_TAX_PRICE"
));
item
.
setFPROV
(
itemObject
.
getString
(
"DIS_STORE_PROV"
));
item
.
setFQTY
(
itemObject
.
getString
(
"DIS_QTY"
));
item
.
setFSNDP
(
itemObject
.
getString
(
"PURCHASING_PRICE"
));
item
.
setMPG
(
itemObject
.
getString
(
"MPG"
));
item
.
setYLZD1
(
itemObject
.
getString
(
"YLZD1"
));
item
.
setYLZD2
(
itemObject
.
getString
(
"YLZD2"
));
item
.
setYLZD3
(
itemObject
.
getString
(
"YLZD3"
));
itemList
.
add
(
item
);
try
{
ZDTSD011ACTUALSALESSENDING
.
RECORD
RECORD
=
new
ZDTSD011ACTUALSALESSENDING
.
RECORD
();
mt011ACTUALSALES
.
setRECORD
(
RECORD
);
ZDTSD011ACTUALSALESSENDING
.
RECORD
.
HEADER
header
=
new
ZDTSD011ACTUALSALESSENDING
.
RECORD
.
HEADER
();
List
<
ZDTSD011ACTUALSALESSENDING
.
RECORD
.
ITEM
>
itemList
=
RECORD
.
getITEM
();
JSONObject
headerObject
=
new
JSONObject
(
vList
.
get
(
0
));
header
.
setAUBEL
(
headerObject
.
getString
(
"SALES_NO"
));
header
.
setFXSNA
(
headerObject
.
getString
(
"DIS_NAME"
));
header
.
setFXSNO
(
headerObject
.
getString
(
"DIS_CODE"
));
header
.
setSDATE
(
headerObject
.
getString
(
"SALES_DATE"
));
RECORD
.
setHEADER
(
header
);
List
<
BigInteger
>
idList
=
new
ArrayList
<
BigInteger
>();
for
(
Map
<
String
,
Object
>
itemMap
:
vList
)
{
JSONObject
itemObject
=
new
JSONObject
(
itemMap
);
idList
.
add
(
itemObject
.
getBigInteger
(
"ID"
));
ZDTSD011ACTUALSALESSENDING
.
RECORD
.
ITEM
item
=
new
ZDTSD011ACTUALSALESSENDING
.
RECORD
.
ITEM
();
item
.
setCUSNA
(
itemObject
.
getString
(
"DIS_STORE_NAME"
));
item
.
setCUSNO
(
itemObject
.
getString
(
"DIS_STORE_CODE"
));
item
.
setCUSTY
(
itemObject
.
getString
(
"DIS_STORE_TYPE"
));
item
.
setFAMOU
(
itemObject
.
getString
(
"DIS_TAX_AMOUNT"
));
item
.
setFCITY
(
itemObject
.
getString
(
"DIS_STORE_CITY"
));
item
.
setFDNO
(
itemObject
.
getString
(
"SALES_LINE"
));
item
.
setFITEM
(
itemObject
.
getString
(
"DIS_GOODS_CODE"
));
item
.
setFPRIC
(
itemObject
.
getString
(
"DIS_TAX_PRICE"
));
item
.
setFPROV
(
itemObject
.
getString
(
"DIS_STORE_PROV"
));
item
.
setFQTY
(
itemObject
.
getString
(
"DIS_QTY"
));
item
.
setFSNDP
(
itemObject
.
getString
(
"PURCHASING_PRICE"
));
item
.
setMPG
(
itemObject
.
getString
(
"MPG"
));
item
.
setYLZD1
(
itemObject
.
getString
(
"YLZD1"
));
item
.
setYLZD2
(
itemObject
.
getString
(
"YLZD2"
));
item
.
setYLZD3
(
itemObject
.
getString
(
"YLZD3"
));
itemList
.
add
(
item
);
}
SI011ACTUALSALESSyncOut
.
si011ACTUALSALESSyncOut
(
mt011ACTUALSALES
);
String
updateSql
=
"UPDATE t_dis_sales SET SEND_STATUS = 'Y', SEND_TIME = NOW() WHERE ID IN ("
+
StringUtil
.
join
(
"?"
,
", "
,
idList
.
size
(),
""
,
""
)
+
")"
;
jdbcTemplate
.
update
(
updateSql
,
idList
.
toArray
());
}
catch
(
Throwable
e
)
{
isSuccess
=
false
;
e
.
printStackTrace
();
}
finally
{
String
xmlName
=
"011_ACTUAL_SALES"
;
try
{
String
xml
=
XMLUtil
.
toXml
(
mt011ACTUALSALES
);
String
xmlFullName
=
xmlRoot
+
"/sap/"
+
xmlName
+
"/"
+
DateUtil
.
formatDate
(
now
,
DateUtil
.
FMT_DATE
)
+
"/"
+
(
isSuccess
?
"success"
:
"error"
)
+
"/"
+
xmlName
+
"-"
+
timeString
+
".XML"
;
FileUtil
.
writeText
(
xmlFullName
,
xml
);
String
json
=
new
Gson
().
toJson
(
mt011ACTUALSALES
);
FileUtil
.
writeText
(
xmlFullName
+
".JSON"
,
json
);
}
catch
(
Exception
e
)
{
throw
new
XRException
(
ThrowableUtil
.
getCaused
(
e
).
getMessage
(),
e
);
}
}
SI011ACTUALSALESSyncOut
.
si011ACTUALSALESSyncOut
(
mt011ACTUALSALES
);
String
updateSql
=
"UPDATE t_dis_sales SET SEND_STATUS = 'Y', SEND_TIME = NOW() WHERE ID IN ("
+
StringUtil
.
join
(
"?"
,
", "
,
idList
.
size
(),
""
,
""
)
+
")"
;
jdbcTemplate
.
update
(
updateSql
,
idList
.
toArray
());
}
}
...
...
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