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
60544650
Commit
60544650
authored
Aug 12, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
dc8d3e69
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
65 deletions
+101
-65
SI011ACTUALSALESSyncOutServiceTask.java
...ES_SyncOutService/SI011ACTUALSALESSyncOutServiceTask.java
+2
-2
CommonService.java
src/main/java/com/egolm/sso/services/CommonService.java
+99
-63
No files found.
src/main/java/com/egolm/sso/clients/SI_011_ACTUAL_SALES_SyncOutService/SI011ACTUALSALESSyncOutServiceTask.java
View file @
60544650
...
@@ -68,7 +68,7 @@ public class SI011ACTUALSALESSyncOutServiceTask {
...
@@ -68,7 +68,7 @@ public class SI011ACTUALSALESSyncOutServiceTask {
}
}
private
void
sendData
(
SI011ACTUALSALESSyncOut
SI011ACTUALSALESSyncOut
)
{
private
void
sendData
(
SI011ACTUALSALESSyncOut
SI011ACTUALSALESSyncOut
)
{
Page
page
=
new
Page
(
1L
,
1000L
,
new
String
[]
{
"DIS_CODE"
,
"
TRACE
_NO"
});
Page
page
=
new
Page
(
1L
,
1000L
,
new
String
[]
{
"DIS_CODE"
,
"
SALES
_NO"
});
String
sql
=
"SELECT * FROM t_dis_sales WHERE SEND_STATUS = 'N'"
;
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
>>
list
=
new
ArrayList
<
Map
<
String
,
Object
>>();
List
<
Map
<
String
,
Object
>>
tmp
=
null
;
List
<
Map
<
String
,
Object
>>
tmp
=
null
;
...
@@ -78,7 +78,7 @@ public class SI011ACTUALSALESSyncOutServiceTask {
...
@@ -78,7 +78,7 @@ public class SI011ACTUALSALESSyncOutServiceTask {
list
.
addAll
(
tmp
);
list
.
addAll
(
tmp
);
page
.
toNextPage
();
page
.
toNextPage
();
}
while
(
tmp
!=
null
&&
tmp
.
size
()
>
0
);
}
while
(
tmp
!=
null
&&
tmp
.
size
()
>
0
);
Map
<
String
,
List
<
Map
<
String
,
Object
>>>
datas
=
CollectionUtil
.
toGroupList
(
list
,
"DIS_CODE"
,
"
TRACE
_NO"
);
Map
<
String
,
List
<
Map
<
String
,
Object
>>>
datas
=
CollectionUtil
.
toGroupList
(
list
,
"DIS_CODE"
,
"
SALES
_NO"
);
for
(
List
<
Map
<
String
,
Object
>>
vList
:
datas
.
values
())
{
for
(
List
<
Map
<
String
,
Object
>>
vList
:
datas
.
values
())
{
try
{
try
{
this
.
sendData
(
SI011ACTUALSALESSyncOut
,
vList
);
this
.
sendData
(
SI011ACTUALSALESSyncOut
,
vList
);
...
...
src/main/java/com/egolm/sso/services/CommonService.java
View file @
60544650
package
com
.
egolm
.
sso
.
services
;
package
com
.
egolm
.
sso
.
services
;
import
java.sql.CallableStatement
;
import
java.sql.Connection
;
import
java.sql.SQLException
;
import
java.sql.Types
;
import
java.text.MessageFormat
;
import
java.text.MessageFormat
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
...
@@ -8,13 +12,15 @@ import java.util.HashMap;
...
@@ -8,13 +12,15 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
org.bouncycastle.util.encoders.Base64
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.config.ConfigurableBeanFactory
;
import
org.springframework.beans.factory.config.ConfigurableBeanFactory
;
import
org.springframework.context.annotation.Scope
;
import
org.springframework.context.annotation.Scope
;
import
org.springframework.dao.DataAccessException
;
import
org.springframework.dao.DuplicateKeyException
;
import
org.springframework.dao.DuplicateKeyException
;
import
org.springframework.dao.EmptyResultDataAccessException
;
import
org.springframework.dao.EmptyResultDataAccessException
;
import
org.springframework.jdbc.core.CallableStatementCallback
;
import
org.springframework.jdbc.core.CallableStatementCreator
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Propagation
;
...
@@ -29,55 +35,76 @@ import com.egolm.sso.util.SqlUtil.Sql;
...
@@ -29,55 +35,76 @@ import com.egolm.sso.util.SqlUtil.Sql;
import
com.egolm.sso.util.StringUtil
;
import
com.egolm.sso.util.StringUtil
;
@Service
@Service
@Scope
(
value
=
ConfigurableBeanFactory
.
SCOPE_SINGLETON
)
@Scope
(
value
=
ConfigurableBeanFactory
.
SCOPE_SINGLETON
)
public
class
CommonService
{
public
class
CommonService
{
@Autowired
@Autowired
private
JdbcTemplate
jdbcTemplate
;
private
JdbcTemplate
jdbcTemplate
;
@Value
(
"${systemId}"
)
@Value
(
"${systemId}"
)
private
String
systemId
;
private
String
systemId
;
@Value
(
"${dataTracking.appId}"
)
@Value
(
"${dataTracking.appId}"
)
private
String
appId
;
private
String
appId
;
@Value
(
"${dataTracking.appSecret}"
)
@Value
(
"${dataTracking.appSecret}"
)
private
String
appSecret
;
private
String
appSecret
;
@Value
(
"${dataTracking.username}"
)
@Value
(
"${dataTracking.username}"
)
private
String
username
;
private
String
username
;
@Value
(
"${dataTracking.baseUrl}"
)
@Value
(
"${dataTracking.baseUrl}"
)
private
String
baseUrl
;
private
String
baseUrl
;
@Value
(
"${dataTracking.uri.token}"
)
@Value
(
"${dataTracking.uri.token}"
)
private
String
tokenUri
;
private
String
tokenUri
;
@Value
(
"${dataTracking.uri.insertOrderTracking}"
)
@Value
(
"${dataTracking.uri.insertOrderTracking}"
)
private
String
insertOrderTrackingUri
;
private
String
insertOrderTrackingUri
;
@Value
(
"${dataTracking.isOpen}"
)
@Value
(
"${dataTracking.isOpen}"
)
private
boolean
isOpen
;
private
boolean
isOpen
;
public
Long
getNextval
(
String
sName
)
{
return
getNextvalBySql
(
sName
);
}
public
Long
getNextvalByProc
(
String
sName
)
{
return
this
.
jdbcTemplate
.
execute
(
new
CallableStatementCreator
()
{
public
CallableStatement
createCallableStatement
(
Connection
connection
)
throws
SQLException
{
String
storedProc
=
"{call getNextval(?, ?)}"
;
CallableStatement
cs
=
connection
.
prepareCall
(
storedProc
);
cs
.
setString
(
1
,
sName
);
cs
.
registerOutParameter
(
2
,
Types
.
BIGINT
);
return
cs
;
}
},
new
CallableStatementCallback
<
Long
>()
{
public
Long
doInCallableStatement
(
CallableStatement
cs
)
throws
SQLException
,
DataAccessException
{
cs
.
execute
();
return
cs
.
getLong
(
2
);
}
});
}
@Transactional
(
propagation
=
Propagation
.
NOT_SUPPORTED
)
@Transactional
(
propagation
=
Propagation
.
NOT_SUPPORTED
)
public
synchronized
Long
getNextva
l
(
String
sName
)
{
public
Long
getNextvalBySq
l
(
String
sName
)
{
try
{
try
{
Map
<
String
,
Object
>
seqMap
=
jdbcTemplate
.
queryForMap
(
"select * from x_sequence where name = ?"
,
sName
);
Map
<
String
,
Object
>
seqMap
=
jdbcTemplate
.
queryForMap
(
"select * from x_sequence where name = ?"
,
sName
);
Integer
id
=
(
Integer
)
seqMap
.
get
(
"id"
);
Integer
id
=
(
Integer
)
seqMap
.
get
(
"id"
);
Long
step
=
(
Long
)
seqMap
.
get
(
"step"
);
Long
step
=
(
Long
)
seqMap
.
get
(
"step"
);
Long
max
=
(
Long
)
seqMap
.
get
(
"max"
);
Long
max
=
(
Long
)
seqMap
.
get
(
"max"
);
Long
min
=
(
Long
)
seqMap
.
get
(
"min"
);
Long
min
=
(
Long
)
seqMap
.
get
(
"min"
);
Long
value
=
(
Long
)
seqMap
.
get
(
"value"
);
Long
value
=
(
Long
)
seqMap
.
get
(
"value"
);
Long
nextValue
=
value
+
step
;
Long
nextValue
=
value
+
step
;
if
(
value
>
max
||
value
<
min
)
{
if
(
value
>
max
||
value
<
min
)
{
throw
new
XRException
(
MessageFormat
.
format
(
"序列已超出许可范围[{0}]"
,
sName
));
throw
new
XRException
(
MessageFormat
.
format
(
"序列已超出许可范围[{0}]"
,
sName
));
}
else
{
}
else
{
String
sql
=
"update x_sequence set value = ? where id = ? and value < ?"
;
String
sql
=
"update x_sequence set value = ? where id = ? and value < ?"
;
int
count
=
jdbcTemplate
.
update
(
sql
,
nextValue
,
id
,
nextValue
);
int
count
=
jdbcTemplate
.
update
(
sql
,
nextValue
,
id
,
nextValue
);
if
(
count
==
1
)
{
if
(
count
==
1
)
{
return
value
;
return
value
;
}
else
if
(
count
==
0
)
{
}
else
if
(
count
==
0
)
{
return
this
.
getNextval
(
sName
);
return
this
.
getNextval
(
sName
);
}
else
{
}
else
{
throw
new
XRException
(
MessageFormat
.
format
(
"序列错误[{0}]"
,
sName
));
throw
new
XRException
(
MessageFormat
.
format
(
"序列错误[{0}]"
,
sName
));
...
@@ -93,21 +120,25 @@ public class CommonService {
...
@@ -93,21 +120,25 @@ public class CommonService {
}
}
}
}
}
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
Long
.
MAX_VALUE
);
}
public
String
getNextBatch
(
Date
day
,
String
sPrefix
,
String
sName
)
{
public
String
getNextBatch
(
Date
day
,
String
sPrefix
,
String
sName
)
{
String
dateString
=
DateUtil
.
formatDate
(
day
,
"yyyyMMdd"
);
String
dateString
=
DateUtil
.
formatDate
(
day
,
"yyyyMMdd"
);
sName
=
sPrefix
+
"_"
+
sName
+
"_"
+
dateString
;
sName
=
sPrefix
+
"_"
+
sName
+
"_"
+
dateString
;
return
dateString
+
"-"
+
this
.
getNextval
(
sName
);
return
dateString
+
"-"
+
this
.
getNextval
(
sName
);
}
}
public
String
limitByMysql
(
String
sql
,
Page
page
)
{
public
String
limitByMysql
(
String
sql
,
Page
page
)
{
long
start
=
(
page
.
getIndex
()
-
1
)
*
page
.
getLimit
();
long
start
=
(
page
.
getIndex
()
-
1
)
*
page
.
getLimit
();
long
limit
=
page
.
getLimit
();
long
limit
=
page
.
getLimit
();
String
limitKeys
=
StringUtil
.
join
(
", as_limit."
,
" order by as_limit."
,
""
,
""
,
page
.
getLimitKey
());
String
limitKeys
=
StringUtil
.
join
(
", as_limit."
,
" order by as_limit."
,
""
,
""
,
page
.
getLimitKey
());
return
"select as_limit.* from ("
+
sql
+
") as_limit"
+
limitKeys
+
" limit "
+
start
+
", "
+
limit
;
return
"select as_limit.* from ("
+
sql
+
") as_limit"
+
limitKeys
+
" limit "
+
start
+
", "
+
limit
;
}
}
@Transactional
(
propagation
=
Propagation
.
NOT_SUPPORTED
)
@Transactional
(
propagation
=
Propagation
.
NOT_SUPPORTED
)
public
void
saveApiAccessLog
(
String
METHOD
,
String
ADDRESS
,
String
RESULT
)
{
public
void
saveApiAccessLog
(
String
METHOD
,
String
ADDRESS
,
String
RESULT
)
{
Date
now
=
new
Date
();
Date
now
=
new
Date
();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
...
@@ -123,15 +154,16 @@ public class CommonService {
...
@@ -123,15 +154,16 @@ public class CommonService {
Object
[]
objs
=
sqlObj
.
getArgs
();
Object
[]
objs
=
sqlObj
.
getArgs
();
jdbcTemplate
.
update
(
sql
,
objs
);
jdbcTemplate
.
update
(
sql
,
objs
);
}
}
@Value
(
"${dataTracking.tokenExpireMinute}"
)
@Value
(
"${dataTracking.tokenExpireMinute}"
)
private
Long
tokenExpireMinute
;
private
Long
tokenExpireMinute
;
private
static
String
token
;
private
static
String
token
;
private
static
Date
tokenCreateTime
;
private
static
Date
tokenCreateTime
;
public
String
getToken
()
{
public
String
getToken
()
{
Date
now
=
new
Date
();
Date
now
=
new
Date
();
if
(
token
!=
null
&&
tokenCreateTime
!=
null
&&
(
tokenCreateTime
.
getTime
()
+
((
tokenExpireMinute
-
2
)*
60L
*
1000L
))
>
now
.
getTime
())
{
if
(
token
!=
null
&&
tokenCreateTime
!=
null
&&
(
tokenCreateTime
.
getTime
()
+
((
tokenExpireMinute
-
2
)
*
60L
*
1000L
))
>
now
.
getTime
())
{
return
token
;
return
token
;
}
}
String
requestUrl
=
baseUrl
+
tokenUri
;
String
requestUrl
=
baseUrl
+
tokenUri
;
...
@@ -142,7 +174,7 @@ public class CommonService {
...
@@ -142,7 +174,7 @@ public class CommonService {
String
resultText
=
HttpUtil
.
post
(
requestUrl
,
parameters
,
null
);
String
resultText
=
HttpUtil
.
post
(
requestUrl
,
parameters
,
null
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
resultText
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
resultText
);
Boolean
isSuccess
=
jsonObject
.
getBoolean
(
"success"
);
Boolean
isSuccess
=
jsonObject
.
getBoolean
(
"success"
);
if
(
isSuccess
!=
null
&&
isSuccess
)
{
if
(
isSuccess
!=
null
&&
isSuccess
)
{
tokenCreateTime
=
now
;
tokenCreateTime
=
now
;
token
=
jsonObject
.
getString
(
"token"
);
token
=
jsonObject
.
getString
(
"token"
);
return
token
;
return
token
;
...
@@ -150,13 +182,14 @@ public class CommonService {
...
@@ -150,13 +182,14 @@ public class CommonService {
throw
new
TrackingTokenException
(
jsonObject
.
getString
(
"message"
));
throw
new
TrackingTokenException
(
jsonObject
.
getString
(
"message"
));
}
}
}
}
public
String
saveOrderTracking
(
String
traceNo
,
String
orderType
,
String
orderNo
,
String
disCode
,
String
action
,
String
result
,
String
message
,
String
errorMessage
)
{
public
String
saveOrderTracking
(
String
traceNo
,
String
orderType
,
String
orderNo
,
String
disCode
,
String
action
,
if
(
isOpen
)
{
String
result
,
String
message
,
String
errorMessage
)
{
if
(
isOpen
)
{
String
requestUrl
=
baseUrl
+
insertOrderTrackingUri
;
String
requestUrl
=
baseUrl
+
insertOrderTrackingUri
;
String
token
=
this
.
getToken
();
String
token
=
this
.
getToken
();
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
headers
.
put
(
"Authorization"
,
"Bearer "
+
token
);
headers
.
put
(
"Authorization"
,
"Bearer "
+
token
);
Map
<
String
,
Object
>
parameters
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
parameters
=
new
HashMap
<
String
,
Object
>();
parameters
.
put
(
"traceNo"
,
traceNo
);
parameters
.
put
(
"traceNo"
,
traceNo
);
parameters
.
put
(
"orderType"
,
orderType
);
parameters
.
put
(
"orderType"
,
orderType
);
...
@@ -170,20 +203,16 @@ public class CommonService {
...
@@ -170,20 +203,16 @@ public class CommonService {
}
}
return
null
;
return
null
;
}
}
public
static
class
TrackingTokenException
extends
RuntimeException
{
public
static
class
TrackingTokenException
extends
RuntimeException
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
public
TrackingTokenException
(
String
msg
)
{
public
TrackingTokenException
(
String
msg
)
{
super
(
msg
);
super
(
msg
);
}
}
}
}
public
static
void
main
(
String
[]
args
)
{
public
static
class
Page
implements
java
.
io
.
Serializable
{
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
;
private
static
final
long
serialVersionUID
=
1L
;
...
@@ -191,41 +220,45 @@ public class CommonService {
...
@@ -191,41 +220,45 @@ public class CommonService {
* 分页页数
* 分页页数
*/
*/
protected
Long
index
=
1L
;
protected
Long
index
=
1L
;
/**
/**
* 分页大小,即每页数据显示条数
* 分页大小,即每页数据显示条数
*/
*/
protected
Long
limit
=
50L
;
protected
Long
limit
=
50L
;
/**
/**
* 数据总条数
* 数据总条数
*/
*/
protected
Long
total
=
0L
;
protected
Long
total
=
0L
;
protected
String
[]
limitKey
;
protected
String
[]
limitKey
;
public
Page
()
{}
public
Page
()
{
}
public
Page
(
String
...
limitKey
)
{
public
Page
(
String
...
limitKey
)
{
this
.
limitKey
=
limitKey
;
this
.
limitKey
=
limitKey
;
}
}
/**
/**
* 构造函数
* 构造函数
* @param index 分页查询的页索引
*
* @param limit 每页显示的条数
* @param index
* 分页查询的页索引
* @param limit
* 每页显示的条数
*/
*/
public
Page
(
Long
index
,
Long
limit
)
{
public
Page
(
Long
index
,
Long
limit
)
{
this
.
index
=
index
;
this
.
index
=
index
;
this
.
limit
=
limit
;
this
.
limit
=
limit
;
}
}
public
Page
(
Long
index
,
Long
limit
,
String
...
limitKey
)
{
public
Page
(
Long
index
,
Long
limit
,
String
...
limitKey
)
{
this
.
index
=
index
;
this
.
index
=
index
;
this
.
limit
=
limit
;
this
.
limit
=
limit
;
this
.
limitKey
=
limitKey
;
this
.
limitKey
=
limitKey
;
}
}
public
Long
getIndex
()
{
public
Long
getIndex
()
{
Long
pageTotal
=
getPageTotal
();
Long
pageTotal
=
getPageTotal
();
if
(
index
>
pageTotal
&&
pageTotal
!=
null
&&
pageTotal
!=
0
)
{
if
(
index
>
pageTotal
&&
pageTotal
!=
null
&&
pageTotal
!=
0
)
{
...
@@ -233,7 +266,7 @@ public class CommonService {
...
@@ -233,7 +266,7 @@ public class CommonService {
}
}
return
index
;
return
index
;
}
}
public
Page
toNextPage
()
{
public
Page
toNextPage
()
{
this
.
index
+=
1
;
this
.
index
+=
1
;
return
this
;
return
this
;
...
@@ -254,35 +287,38 @@ public class CommonService {
...
@@ -254,35 +287,38 @@ public class CommonService {
public
Long
getTotal
()
{
public
Long
getTotal
()
{
return
total
;
return
total
;
}
}
public
void
setTotal
(
Long
total
)
{
public
void
setTotal
(
Long
total
)
{
this
.
total
=
total
;
this
.
total
=
total
;
}
}
/**
/**
* 计算总分页页数
* 计算总分页页数
*
* @return
* @return
*/
*/
public
Long
getPageTotal
()
{
public
Long
getPageTotal
()
{
return
total
%
limit
==
0
?
(
total
/
limit
)
:
(
total
/
limit
+
1
);
return
total
%
limit
==
0
?
(
total
/
limit
)
:
(
total
/
limit
+
1
);
}
}
/**
/**
* 计算分页查询开始行的行标
* 计算分页查询开始行的行标
*
* @return 分页查询开始行标
* @return 分页查询开始行标
*/
*/
public
Long
getFirstRowNumber
()
{
public
Long
getFirstRowNumber
()
{
return
((
index
-
1
)
*
limit
)
+
1
;
return
((
index
-
1
)
*
limit
)
+
1
;
}
}
/**
/**
* 计算分页查询结束行的行标
* 计算分页查询结束行的行标
*
* @return 分页查询结束行标
* @return 分页查询结束行标
*/
*/
public
Long
getLastRowNumber
()
{
public
Long
getLastRowNumber
()
{
return
index
*
limit
;
return
index
*
limit
;
}
}
public
Long
[]
getPageIndexs
()
{
public
Long
[]
getPageIndexs
()
{
Long
lastIndex
=
this
.
getPageTotal
();
Long
lastIndex
=
this
.
getPageTotal
();
List
<
Long
>
list
=
new
ArrayList
<
Long
>();
List
<
Long
>
list
=
new
ArrayList
<
Long
>();
...
@@ -290,17 +326,17 @@ public class CommonService {
...
@@ -290,17 +326,17 @@ public class CommonService {
Long
i
=
1L
;
Long
i
=
1L
;
Long
prefPage
=
index
;
Long
prefPage
=
index
;
Long
nextPage
=
index
;
Long
nextPage
=
index
;
do
{
do
{
prefPage
=
index
-
i
;
prefPage
=
index
-
i
;
nextPage
=
index
+
i
;
nextPage
=
index
+
i
;
if
(
prefPage
>=
1
)
{
if
(
prefPage
>=
1
)
{
list
.
add
(
0
,
prefPage
);
list
.
add
(
0
,
prefPage
);
}
}
if
(
nextPage
<=
lastIndex
)
{
if
(
nextPage
<=
lastIndex
)
{
list
.
add
(
nextPage
);
list
.
add
(
nextPage
);
}
}
i
++;
i
++;
}
while
(
list
.
size
()
<
6
&&
(
prefPage
>=
1
||
nextPage
<=
lastIndex
));
}
while
(
list
.
size
()
<
6
&&
(
prefPage
>=
1
||
nextPage
<=
lastIndex
));
return
list
.
toArray
(
new
Long
[
list
.
size
()]);
return
list
.
toArray
(
new
Long
[
list
.
size
()]);
}
}
...
@@ -309,7 +345,7 @@ public class CommonService {
...
@@ -309,7 +345,7 @@ public class CommonService {
}
}
public
void
setLimitKey
(
String
...
limitKey
)
{
public
void
setLimitKey
(
String
...
limitKey
)
{
if
(
this
.
limitKey
==
null
)
{
if
(
this
.
limitKey
==
null
)
{
this
.
limitKey
=
limitKey
;
this
.
limitKey
=
limitKey
;
}
else
{
}
else
{
List
<
String
>
strs
=
new
ArrayList
<
String
>();
List
<
String
>
strs
=
new
ArrayList
<
String
>();
...
@@ -318,7 +354,7 @@ public class CommonService {
...
@@ -318,7 +354,7 @@ public class CommonService {
this
.
limitKey
=
strs
.
toArray
(
new
String
[
strs
.
size
()]);
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