Commit 074983c5 authored by Quxl's avatar Quxl

x

parent f180515b
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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment