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
8ff8c065
Commit
8ff8c065
authored
Aug 13, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
f18593ef
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
159 additions
and
159 deletions
+159
-159
SI004INVENTORYSyncOutServiceTask.java
...TORY_SyncOutService/SI004INVENTORYSyncOutServiceTask.java
+3
-2
SI011ACTUALSALESSyncOutServiceTask.java
...ES_SyncOutService/SI011ACTUALSALESSyncOutServiceTask.java
+3
-2
CommonService.java
src/main/java/com/egolm/sso/services/CommonService.java
+0
-155
SqlUtil.java
src/main/java/com/egolm/sso/util/SqlUtil.java
+153
-0
No files found.
src/main/java/com/egolm/sso/clients/SI_004_INVENTORY_SyncOutService/SI004INVENTORYSyncOutServiceTask.java
View file @
8ff8c065
...
...
@@ -20,10 +20,11 @@ import com.alibaba.fastjson.JSONObject;
import
com.egolm.sso.clients.ServiceFactory
;
import
com.egolm.sso.config.XRException
;
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.SqlUtil
;
import
com.egolm.sso.util.SqlUtil.Page
;
import
com.egolm.sso.util.StringUtil
;
import
com.egolm.sso.util.ThrowableUtil
;
import
com.egolm.sso.util.XMLUtil
;
...
...
@@ -73,7 +74,7 @@ public class SI004INVENTORYSyncOutServiceTask {
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<
Map
<
String
,
Object
>>();
List
<
Map
<
String
,
Object
>>
tmp
=
null
;
do
{
String
limitSql
=
common
.
limitByMysql
(
sql
,
page
);
String
limitSql
=
SqlUtil
.
limitByMysql
(
sql
,
page
);
tmp
=
jdbcTemplate
.
queryForList
(
limitSql
);
list
.
addAll
(
tmp
);
page
.
toNextPage
();
...
...
src/main/java/com/egolm/sso/clients/SI_011_ACTUAL_SALES_SyncOutService/SI011ACTUALSALESSyncOutServiceTask.java
View file @
8ff8c065
...
...
@@ -20,10 +20,11 @@ import com.alibaba.fastjson.JSONObject;
import
com.egolm.sso.clients.ServiceFactory
;
import
com.egolm.sso.config.XRException
;
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.SqlUtil
;
import
com.egolm.sso.util.SqlUtil.Page
;
import
com.egolm.sso.util.StringUtil
;
import
com.egolm.sso.util.ThrowableUtil
;
import
com.egolm.sso.util.XMLUtil
;
...
...
@@ -73,7 +74,7 @@ public class SI011ACTUALSALESSyncOutServiceTask {
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<
Map
<
String
,
Object
>>();
List
<
Map
<
String
,
Object
>>
tmp
=
null
;
do
{
String
limitSql
=
common
.
limitByMysql
(
sql
,
page
);
String
limitSql
=
SqlUtil
.
limitByMysql
(
sql
,
page
);
tmp
=
jdbcTemplate
.
queryForList
(
limitSql
);
list
.
addAll
(
tmp
);
page
.
toNextPage
();
...
...
src/main/java/com/egolm/sso/services/CommonService.java
View file @
8ff8c065
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.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -120,13 +117,6 @@ public class CommonService {
return
sPrefix
+
timeString
+
this
.
getNextval
(
sName
+
"_TRACE_"
+
dateString
);
}
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
;
}
@Value
(
"${dataTracking.tokenExpireMinute}"
)
private
Long
tokenExpireMinute
;
private
static
String
token
;
...
...
@@ -184,149 +174,4 @@ public class CommonService {
}
}
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
()]);
}
}
}
}
src/main/java/com/egolm/sso/util/SqlUtil.java
View file @
8ff8c065
...
...
@@ -2,6 +2,7 @@ package com.egolm.sso.util;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -52,6 +53,13 @@ public class SqlUtil {
return
new
Sql
(
sql
,
args
.
toArray
());
}
public
static
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
;
}
public
static
class
Sql
{
private
String
sql
;
...
...
@@ -78,4 +86,149 @@ public class SqlUtil {
}
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