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
921d1dd0
Commit
921d1dd0
authored
Aug 08, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
e789a796
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
208 additions
and
0 deletions
+208
-0
SI011ACTUALSALESSyncOutServiceTask.java
...ES_SyncOutService/SI011ACTUALSALESSyncOutServiceTask.java
+59
-0
CommonService.java
src/main/java/com/egolm/sso/services/CommonService.java
+149
-0
No files found.
src/main/java/com/egolm/sso/distributors/SI_011_ACTUAL_SALES_SyncOutService/SI011ACTUALSALESSyncOutServiceTask.java
View file @
921d1dd0
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.List
;
import
java.util.Map
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
...
...
@@ -10,8 +14,12 @@ import org.springframework.boot.system.ApplicationHome;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.stereotype.Component
;
import
com.alibaba.fastjson.JSONObject
;
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.StringUtil
;
@Component
public
class
SI011ACTUALSALESSyncOutServiceTask
{
...
...
@@ -44,7 +52,58 @@ public class SI011ACTUALSALESSyncOutServiceTask {
}
private
void
sendData
(
SI011ACTUALSALESSyncOut
SI011ACTUALSALESSyncOut
)
{
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
>>();
List
<
Map
<
String
,
Object
>>
tmp
=
null
;
do
{
String
limitSql
=
common
.
limitByMysql
(
sql
,
page
);
tmp
=
jdbcTemplate
.
queryForList
(
limitSql
);
list
.
addAll
(
tmp
);
page
.
toNextPage
();
}
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
())
{
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
);
}
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
());
}
}
}
src/main/java/com/egolm/sso/services/CommonService.java
View file @
921d1dd0
package
com
.
egolm
.
sso
.
services
;
import
java.text.MessageFormat
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.bouncycastle.util.encoders.Base64
;
...
...
@@ -94,6 +97,13 @@ public class CommonService {
return
dateString
+
"-"
+
this
.
getNextval
(
sName
);
}
public
String
limitByMysql
(
String
sql
,
Page
page
)
{
long
start
=
(
page
.
getIndex
()
-
1
)
*
page
.
getLimit
();
long
limit
=
page
.
getLimit
();
String
limitKeys
=
StringUtil
.
join
(
", as_limit."
,
" order by as_limit."
,
""
,
""
,
page
.
getLimitKey
());
return
"select as_limit.* from ("
+
sql
+
") as_limit"
+
limitKeys
+
" limit "
+
start
+
", "
+
limit
;
}
@Transactional
(
propagation
=
Propagation
.
NOT_SUPPORTED
)
public
void
saveApiAccessLog
(
String
METHOD
,
String
ADDRESS
,
String
RESULT
)
{
Date
now
=
new
Date
();
...
...
@@ -169,4 +179,143 @@ public class CommonService {
String
string
=
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlSWRzIjpbIjM1YmY2NmI4LWQ2NzQtNDNkNy1iNjc3LTc0N2QwMWJhNDZiMyJdLCJ1c2VyX25hbWUiOiJ0cmFuY2UiLCJzY29wZSI6WyJDTElFTlQiXSwiZXhwaXJhdGlvbiI6MTU2NTAwODQ2ODA2NCwiZXhwIjoxNTY1MDA4NDY4LCJhdXRob3JpdGllcyI6WyJ0cmFuY2UiXSwianRpIjoiNGFmMjlhZTItZWJhYy00ZTg5LWExZDAtODUyYWEwZDhkNWM2IiwiY2xpZW50X2lkIjoicGMifQ.cCaEDqpB-yZQp-zmjYAv2igS1IdsjZVd-OT0EOfvdt4"
;
System
.
out
.
println
(
new
String
(
Base64
.
decode
(
string
)));
}
public
static
class
Page
implements
java
.
io
.
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 分页页数
*/
protected
Long
index
=
1L
;
/**
* 分页大小,即每页数据显示条数
*/
protected
Long
limit
=
50L
;
/**
* 数据总条数
*/
protected
Long
total
=
0L
;
protected
String
[]
limitKey
;
public
Page
()
{}
public
Page
(
String
...
limitKey
)
{
this
.
limitKey
=
limitKey
;
}
/**
* 构造函数
* @param index 分页查询的页索引
* @param limit 每页显示的条数
*/
public
Page
(
Long
index
,
Long
limit
)
{
this
.
index
=
index
;
this
.
limit
=
limit
;
}
public
Page
(
Long
index
,
Long
limit
,
String
...
limitKey
)
{
this
.
index
=
index
;
this
.
limit
=
limit
;
this
.
limitKey
=
limitKey
;
}
public
Long
getIndex
()
{
Long
pageTotal
=
getPageTotal
();
if
(
index
>
pageTotal
&&
pageTotal
!=
null
&&
pageTotal
!=
0
)
{
index
=
pageTotal
+
1
;
}
return
index
;
}
public
Page
toNextPage
()
{
this
.
index
+=
1
;
return
this
;
}
public
void
setIndex
(
Long
index
)
{
this
.
index
=
index
;
}
public
Long
getLimit
()
{
return
limit
;
}
public
void
setLimit
(
Long
limit
)
{
this
.
limit
=
limit
;
}
public
Long
getTotal
()
{
return
total
;
}
public
void
setTotal
(
Long
total
)
{
this
.
total
=
total
;
}
/**
* 计算总分页页数
* @return
*/
public
Long
getPageTotal
()
{
return
total
%
limit
==
0
?
(
total
/
limit
)
:
(
total
/
limit
+
1
);
}
/**
* 计算分页查询开始行的行标
* @return 分页查询开始行标
*/
public
Long
getFirstRowNumber
()
{
return
((
index
-
1
)
*
limit
)
+
1
;
}
/**
* 计算分页查询结束行的行标
* @return 分页查询结束行标
*/
public
Long
getLastRowNumber
()
{
return
index
*
limit
;
}
public
Long
[]
getPageIndexs
()
{
Long
lastIndex
=
this
.
getPageTotal
();
List
<
Long
>
list
=
new
ArrayList
<
Long
>();
list
.
add
(
index
);
Long
i
=
1L
;
Long
prefPage
=
index
;
Long
nextPage
=
index
;
do
{
prefPage
=
index
-
i
;
nextPage
=
index
+
i
;
if
(
prefPage
>=
1
)
{
list
.
add
(
0
,
prefPage
);
}
if
(
nextPage
<=
lastIndex
)
{
list
.
add
(
nextPage
);
}
i
++;
}
while
(
list
.
size
()
<
6
&&
(
prefPage
>=
1
||
nextPage
<=
lastIndex
));
return
list
.
toArray
(
new
Long
[
list
.
size
()]);
}
public
String
[]
getLimitKey
()
{
return
limitKey
;
}
public
void
setLimitKey
(
String
...
limitKey
)
{
if
(
this
.
limitKey
==
null
)
{
this
.
limitKey
=
limitKey
;
}
else
{
List
<
String
>
strs
=
new
ArrayList
<
String
>();
strs
.
addAll
(
Arrays
.
asList
(
this
.
limitKey
));
strs
.
addAll
(
Arrays
.
asList
(
limitKey
));
this
.
limitKey
=
strs
.
toArray
(
new
String
[
strs
.
size
()]);
}
}
}
}
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