fix: prevent timezoneoffset too large
parent
869328a33f
commit
18e73d4700
|
|
@ -52,7 +52,7 @@ public class StoreService {
|
|||
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"storeId parameter is required\"}").build();
|
||||
}
|
||||
|
||||
DriverManager.setLoginTimeout(5); // Définir le timeout à 5 secondes
|
||||
DriverManager.setLoginTimeout(5); // Set timeout to 5 seconds
|
||||
|
||||
try (DatabaseConnectDOTSOFT databaseConnection = new DatabaseConnectDOTSOFT("com02")) {
|
||||
String query = "SELECT st.id_structure," +
|
||||
|
|
@ -79,7 +79,6 @@ public class StoreService {
|
|||
" WHERE st.id_structure = ?";
|
||||
|
||||
logger.info(query);
|
||||
|
||||
try (PreparedStatement statement = databaseConnection.getConnection().prepareStatement(query)) {
|
||||
statement.setString(1, storeId);
|
||||
|
||||
|
|
@ -163,7 +162,7 @@ public class StoreService {
|
|||
* @return a list of stores retrieved from the database
|
||||
*/
|
||||
private List<Store> retrieveStoresFromDatabase() {
|
||||
DriverManager.setLoginTimeout(5); // Définir le timeout à 5 secondes
|
||||
DriverManager.setLoginTimeout(5); // Set timeout to 5 seconds
|
||||
|
||||
try (DatabaseConnectDOTSOFT databaseConnection = new DatabaseConnectDOTSOFT("com02")) {
|
||||
String query = "SELECT st.id_structure," +
|
||||
|
|
@ -191,7 +190,6 @@ public class StoreService {
|
|||
" ORDER BY st.id_structure";
|
||||
|
||||
logger.info(query);
|
||||
|
||||
try (PreparedStatement statement = databaseConnection.getConnection().prepareStatement(query);
|
||||
ResultSet resultSet = statement.executeQuery()) {
|
||||
|
||||
|
|
@ -225,7 +223,7 @@ public class StoreService {
|
|||
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"dbHost parameter is required\"}").build();
|
||||
}
|
||||
|
||||
DriverManager.setLoginTimeout(5); // Définir le timeout à 5 secondes
|
||||
DriverManager.setLoginTimeout(5); // Set timeout to 5 seconds
|
||||
|
||||
try (DatabaseConnectXSTORE databaseConnection = new DatabaseConnectXSTORE(dbHost,"dtv")) {
|
||||
|
||||
|
|
@ -234,6 +232,7 @@ public class StoreService {
|
|||
"WHERE organization_id = 1 " +
|
||||
"ORDER BY WKSTN_ID, SEQUENCE_ID";
|
||||
|
||||
logger.info(query);
|
||||
try (PreparedStatement statement = databaseConnection.getConnection().prepareStatement(query)) {
|
||||
ResultSet resultSet = statement.executeQuery();
|
||||
|
||||
|
|
@ -277,7 +276,7 @@ public class StoreService {
|
|||
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"dbHost parameter is required\"}").build();
|
||||
}
|
||||
|
||||
DriverManager.setLoginTimeout(5); // Définir le timeout à 5 secondes
|
||||
DriverManager.setLoginTimeout(5); // Set timeout to 5 seconds
|
||||
|
||||
try (DatabaseConnectXSTORE databaseConnection = new DatabaseConnectXSTORE(dbHost,"dtv")) {
|
||||
String query = "SELECT ORGANIZATION_ID, RTL_LOC_ID, WKSTN_ID, SIGNATURE_ID, SIGNATURE_MODE, SIGNATURE_STRING, SIGNATURE_SOURCE, CREATE_DATE, CREATE_USER_ID, UPDATE_DATE, UPDATE_USER_ID, RECORD_STATE " +
|
||||
|
|
@ -285,6 +284,7 @@ public class StoreService {
|
|||
"WHERE organization_id = 1 " +
|
||||
"ORDER BY WKSTN_ID";
|
||||
|
||||
logger.info(query);
|
||||
try (PreparedStatement statement = databaseConnection.getConnection().prepareStatement(query)) {
|
||||
ResultSet resultSet = statement.executeQuery();
|
||||
|
||||
|
|
@ -328,7 +328,7 @@ public class StoreService {
|
|||
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"dbHost parameter is required\"}").build();
|
||||
}
|
||||
|
||||
DriverManager.setLoginTimeout(5); // Définir le timeout à 5 secondes
|
||||
DriverManager.setLoginTimeout(5); // Set timeout to 5 seconds
|
||||
|
||||
try (DatabaseConnectXSTORE databaseConnection = new DatabaseConnectXSTORE(dbHost,"dtv")) {
|
||||
|
||||
|
|
@ -338,6 +338,7 @@ public class StoreService {
|
|||
"WHERE organization_id = 1 AND customer IS NOT NULL " +
|
||||
"ORDER BY seq DESC";
|
||||
|
||||
logger.info(query);
|
||||
try (PreparedStatement statement = databaseConnection.getConnection().prepareStatement(query)) {
|
||||
ResultSet resultSet = statement.executeQuery();
|
||||
|
||||
|
|
@ -385,7 +386,7 @@ public class StoreService {
|
|||
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"dbHost parameter is required\"}").build();
|
||||
}
|
||||
|
||||
DriverManager.setLoginTimeout(5); // Définir le timeout à 5 secondes
|
||||
DriverManager.setLoginTimeout(5); // Set timeout to 5 seconds
|
||||
|
||||
try (DatabaseConnectXSTORE databaseConnection = new DatabaseConnectXSTORE(dbHost,"dtv")) {
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
|
||||
|
|
@ -412,6 +413,7 @@ public class StoreService {
|
|||
") " +
|
||||
"WHERE ROWNUM = 1";
|
||||
|
||||
logger.info(queryTZ);
|
||||
while (startDate.compareTo(endDate) >= 0) {
|
||||
try (PreparedStatement pst = databaseConnection.getConnection().prepareStatement(queryTZ)) {
|
||||
pst.setInt(1, storeId);
|
||||
|
|
@ -435,7 +437,13 @@ public class StoreService {
|
|||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// to prevent timezone offset from being too large
|
||||
if (Math.abs(timezoneOffset) > 3) {
|
||||
timezoneOffset = 0;
|
||||
}
|
||||
|
||||
// WHERE cel.CREATE_DATE does not take time zone into account (...+ INTERVAL '1' HOUR * ?)
|
||||
String query = "SELECT cel.CREATE_DATE + INTERVAL '1' HOUR * ? as CREATE_DATE, " +
|
||||
"cel.CREATE_USER_ID, " +
|
||||
"cel.BUSINESS_DATE, " +
|
||||
|
|
@ -460,6 +468,7 @@ public class StoreService {
|
|||
"AND cel.THREAD_NAME IS NOT NULL " +
|
||||
"ORDER BY cel.CREATE_DATE DESC";
|
||||
|
||||
logger.info(query);
|
||||
try (PreparedStatement statement = databaseConnection.getConnection().prepareStatement(query)) {
|
||||
statement.setInt(1, timezoneOffset);
|
||||
statement.setString(2, logDate);
|
||||
|
|
@ -592,6 +601,7 @@ public class StoreService {
|
|||
"ORDER BY cdr.PRIMARY_REGISTER_FLAG desc, cdr.WKSTN_ID";
|
||||
|
||||
logger.info(PosQuery);
|
||||
|
||||
try (PreparedStatement posStatement = databaseConnection.getConnection().prepareStatement(PosQuery)) {
|
||||
try (ResultSet posResultSet = posStatement.executeQuery()) {
|
||||
Integer posRtlLocId = 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue