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
074983c5
Commit
074983c5
authored
Aug 12, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
f180515b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
43 deletions
+0
-43
CommonService.java
src/main/java/com/egolm/sso/services/CommonService.java
+0
-43
No files found.
src/main/java/com/egolm/sso/services/CommonService.java
View file @
074983c5
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.util.ArrayList
;
import
java.util.Arrays
;
...
...
@@ -12,17 +8,12 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.Map
;
import
javax.annotation.PostConstruct
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.config.ConfigurableBeanFactory
;
import
org.springframework.context.annotation.Scope
;
import
org.springframework.dao.DataAccessException
;
import
org.springframework.dao.DuplicateKeyException
;
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.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
...
...
@@ -68,41 +59,11 @@ public class CommonService {
@Value
(
"${dataTracking.isOpen}"
)
private
boolean
isOpen
;
private
static
final
Map
<
String
,
Long
>
tmp
=
new
HashMap
<
String
,
Long
>();
@PostConstruct
public
void
init
()
{
String
sql
=
"select * from x_sequence"
;
List
<
Map
<
String
,
Object
>>
list
=
jdbcTemplate
.
queryForList
(
sql
);
for
(
Map
<
String
,
Object
>
map
:
list
)
{
String
name
=
(
String
)
map
.
get
(
"name"
);
Long
value
=
((
Number
)
map
.
get
(
"value"
)).
longValue
();
tmp
.
put
(
name
,
value
);
}
}
public
Long
getNextval
(
String
sName
)
{
CommonService
common
=
SapServiceApplication
.
getBean
(
CommonService
.
class
);
return
common
.
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
)
public
Long
getNextvalBySql
(
String
sName
)
{
try
{
...
...
@@ -137,10 +98,6 @@ public class CommonService {
}
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
Long
.
MAX_VALUE
);
}
public
String
getNextBatch
(
Date
day
,
String
sPrefix
,
String
sName
)
{
String
dateString
=
DateUtil
.
formatDate
(
day
,
"yyyyMMdd"
);
sName
=
sPrefix
+
"_"
+
sName
+
"_"
+
dateString
;
...
...
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