refactor: store details structure
parent
3cae6f2c69
commit
819523c5ac
|
|
@ -15,7 +15,7 @@ public class DatabaseConnectDOTSOFT implements AutoCloseable {
|
|||
|
||||
private Connection connection;
|
||||
|
||||
public DatabaseConnectDOTSOFT(String username) {
|
||||
public DatabaseConnectDOTSOFT(String username) throws SQLException {
|
||||
String environment = loadEnvironment();
|
||||
|
||||
try {
|
||||
|
|
@ -29,6 +29,7 @@ public class DatabaseConnectDOTSOFT implements AutoCloseable {
|
|||
logger.info("DOTSOFT Connection OK for user " + username + " on environment " + environment);
|
||||
} catch (SQLException e) {
|
||||
logger.error("Failed to connect to DOTSOFT database for user " + username + " on environment " + environment, e);
|
||||
throw e; // re-throw the exception
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public class DatabaseConnectXSTORE implements AutoCloseable {
|
|||
|
||||
private Connection connection;
|
||||
|
||||
public DatabaseConnectXSTORE(String dbHost, String username) {
|
||||
public DatabaseConnectXSTORE(String dbHost, String username) throws SQLException {
|
||||
try {
|
||||
Properties dbProperties = loadDatabaseProperties();
|
||||
|
||||
|
|
@ -27,6 +27,7 @@ public class DatabaseConnectXSTORE implements AutoCloseable {
|
|||
logger.info("XSTORE Connection OK for user " + username + " on host " + dbHost);
|
||||
} catch (SQLException e) {
|
||||
logger.error("Failed to connect to XSTORE database for user " + username + " on host " + dbHost, e);
|
||||
throw e; // re-throw the exception
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -389,8 +389,7 @@ public class StoreService {
|
|||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Response getStoreDetails(
|
||||
@PathParam("storeId") Integer storeId,
|
||||
@QueryParam("dbHost") String dbHost,
|
||||
@QueryParam("workstationId") Integer workstationId) {
|
||||
@QueryParam("dbHost") String dbHost) {
|
||||
|
||||
if (dbHost == null) {
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity("{\"error\":\"dbHost parameter is required\"}").build();
|
||||
|
|
@ -401,7 +400,7 @@ public class StoreService {
|
|||
}
|
||||
|
||||
try {
|
||||
StoreDetails storeDetails = retrieveStoreDetails(dbHost,storeId,workstationId);
|
||||
StoreDetails storeDetails = retrieveStoreDetails(dbHost,storeId);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
|
|
@ -428,144 +427,65 @@ public class StoreService {
|
|||
* @param workstationId the ID of the workstation
|
||||
* @return storeDetails
|
||||
*/
|
||||
private StoreDetails retrieveStoreDetails(String dbHost, Integer storeId, Integer workstationId) {
|
||||
private StoreDetails retrieveStoreDetails(String dbHost, Integer storeId) {
|
||||
DriverManager.setLoginTimeout(5);
|
||||
|
||||
StoreDetails storeDetails = new StoreDetails(); // Declare object outside try blocks
|
||||
|
||||
try (DatabaseConnectXSTORE databaseConnection = new DatabaseConnectXSTORE(dbHost,"dtv")) {
|
||||
// Replication section
|
||||
String replicationQuery = "SELECT COUNT(*) AS pendingReplications, " +
|
||||
"MIN(crq.CREATE_DATE) AS minPendingReplicationDate, " +
|
||||
"MAX(crq.CREATE_DATE) AS maxPendingReplicationDate " +
|
||||
"FROM repqueue.CTL_REPLICATION_QUEUE crq";
|
||||
// get Pos list
|
||||
String PosQuery = "SELECT cdr.RTL_LOC_ID, " +
|
||||
"cdr.WKSTN_ID, " +
|
||||
"cdr.IP_ADDRESS, " +
|
||||
"cdr.BUSINESS_DATE, " +
|
||||
"cdr.XSTORE_VERSION, " +
|
||||
"cdr.PRIMARY_REGISTER_FLAG " +
|
||||
"FROM dtv.ctl_device_registration cdr " +
|
||||
"WHERE cdr.ORGANIZATION_ID = 1 " +
|
||||
"ORDER BY cdr.PRIMARY_REGISTER_FLAG desc, cdr.WKSTN_ID";
|
||||
|
||||
logger.info(replicationQuery);
|
||||
try (PreparedStatement storeStatement = databaseConnection.getConnection().prepareStatement(replicationQuery);
|
||||
ResultSet storeReplicationResultSet = storeStatement.executeQuery()) {
|
||||
logger.info(PosQuery);
|
||||
try (PreparedStatement posStatement = databaseConnection.getConnection().prepareStatement(PosQuery)) {
|
||||
try (ResultSet posResultSet = posStatement.executeQuery()) {
|
||||
Integer posRtlLocId = 0;
|
||||
Integer posWkstnId = 0;
|
||||
String posIp = "";
|
||||
String posVersion = "";
|
||||
Date posBusinessDate = null;
|
||||
Integer primaryRegisterFlag = 0;
|
||||
|
||||
if (storeReplicationResultSet.next()) {
|
||||
StoreReplication storeReplication = mapResultSetToStoreReplication(storeReplicationResultSet);
|
||||
storeDetails.setReplication(storeReplication);
|
||||
while (posResultSet.next()) {
|
||||
posRtlLocId = posResultSet.getInt("RTL_LOC_ID");
|
||||
posWkstnId = posResultSet.getInt("WKSTN_ID");
|
||||
posIp = posResultSet.getString("IP_ADDRESS");
|
||||
posVersion = posResultSet.getString("XSTORE_VERSION");
|
||||
posBusinessDate = posResultSet.getDate("BUSINESS_DATE");
|
||||
primaryRegisterFlag = posResultSet.getInt("PRIMARY_REGISTER_FLAG");
|
||||
|
||||
StorePos pos = new StorePos();
|
||||
|
||||
// add new pos object
|
||||
storeDetails.getPos().add(pos);
|
||||
pos.setWorkstationId(posWkstnId);
|
||||
pos.setIp(posIp);
|
||||
pos.setVersion(posVersion);
|
||||
pos.setBusinessDate(posBusinessDate);
|
||||
pos.setPrimaryRegister(primaryRegisterFlag);
|
||||
pos.setFatalError(1);
|
||||
|
||||
// retrieve all pos details only on database of the master pos
|
||||
retrieveStorePosDetails(databaseConnection, posRtlLocId, posWkstnId, posBusinessDate, pos);
|
||||
|
||||
/* if (posResultSet.getString("IP_ADDRESS").equals(dbHost)) {
|
||||
retrieveStorePosDetails(databaseConnection, posRtlLocId, posWkstnId, posBusinessDate, pos);
|
||||
} else {
|
||||
// Adjust to the desired behavior if no results are found
|
||||
try (DatabaseConnectXSTORE newDatabaseConnection = new DatabaseConnectXSTORE(posIp,"dtv")) {
|
||||
retrieveStorePosDetails(newDatabaseConnection, posRtlLocId, posWkstnId, posBusinessDate, pos);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
// Handle exceptions correctly in a production environment
|
||||
}
|
||||
}
|
||||
|
||||
// opening transation section
|
||||
String openingTransactionQuery = "SELECT"+
|
||||
" COUNT(*) AS counter,"+
|
||||
" MIN(tt.END_DATETIME) AS minDate,"+
|
||||
" MAX(tt.END_DATETIME) AS maxDate"+
|
||||
" FROM"+
|
||||
" trn_trans tt"+
|
||||
" WHERE"+
|
||||
" tt.BUSINESS_DATE = ("+
|
||||
" SELECT"+
|
||||
" MAX(tt_bdate.BUSINESS_DATE) as bd"+
|
||||
" FROM"+
|
||||
" trn_trans tt_bdate"+
|
||||
" WHERE"+
|
||||
" tt_bdate.trans_TYPCODE = 'WORKSTATION_OPEN'"+
|
||||
" AND tt_bdate.TRANS_STATCODE = 'COMPLETE'"+
|
||||
" )"+
|
||||
" AND tt.trans_TYPCODE = 'WORKSTATION_OPEN'"+
|
||||
" AND tt.TRANS_STATCODE = 'COMPLETE'" ;
|
||||
|
||||
logger.info(openingTransactionQuery);
|
||||
try (PreparedStatement storeStatement = databaseConnection.getConnection().prepareStatement(openingTransactionQuery);
|
||||
ResultSet openingTransactionResultSet = storeStatement.executeQuery()) {
|
||||
|
||||
if (openingTransactionResultSet.next()) {
|
||||
XstoreTransaction openingTransaction = mapResultSetToXstoreOpeningTransaction(openingTransactionResultSet);
|
||||
storeDetails.setOpeningTransaction(openingTransaction);
|
||||
} else {
|
||||
// Adjust to the desired behavior if no results are found
|
||||
}
|
||||
}
|
||||
|
||||
// Closing transation section
|
||||
String closingTransactionQuery = "SELECT"+
|
||||
" COUNT(*) AS counter,"+
|
||||
" MIN(tt.END_DATETIME) AS minDate,"+
|
||||
" MAX(tt.END_DATETIME) AS maxDate"+
|
||||
" FROM"+
|
||||
" trn_trans tt"+
|
||||
" WHERE"+
|
||||
" tt.BUSINESS_DATE = ("+
|
||||
" SELECT"+
|
||||
" MAX(tt_bdate.BUSINESS_DATE)"+
|
||||
" FROM"+
|
||||
" trn_trans tt_bdate"+
|
||||
" WHERE"+
|
||||
" tt_bdate.trans_TYPCODE = 'WORKSTATION_OPEN'"+
|
||||
" AND tt_bdate.TRANS_STATCODE = 'COMPLETE'"+
|
||||
" )"+
|
||||
" AND tt.trans_TYPCODE = 'WORKSTATION_CLOSE'"+
|
||||
" AND tt.TRANS_STATCODE = 'COMPLETE'";
|
||||
|
||||
logger.info(closingTransactionQuery);
|
||||
try (PreparedStatement storeStatement = databaseConnection.getConnection().prepareStatement(closingTransactionQuery);
|
||||
ResultSet closingTransactionResultSet = storeStatement.executeQuery()) {
|
||||
|
||||
if (closingTransactionResultSet.next()) {
|
||||
XstoreTransaction closingTransaction = mapResultSetToXstoreClosingTransaction(closingTransactionResultSet);
|
||||
storeDetails.setClosingTransaction(closingTransaction);
|
||||
} else {
|
||||
// Adjust to the desired behavior if no results are found
|
||||
}
|
||||
}
|
||||
|
||||
// sale transation section
|
||||
String saleTransactionQuery = "SELECT"+
|
||||
" COUNT(*) AS counter,"+
|
||||
" MIN(tt.END_DATETIME) AS minDate,"+
|
||||
" MAX(tt.END_DATETIME) AS maxDate"+
|
||||
" FROM"+
|
||||
" trn_trans tt"+
|
||||
" WHERE"+
|
||||
" tt.BUSINESS_DATE = ("+
|
||||
" SELECT"+
|
||||
" MAX(tt_bdate.BUSINESS_DATE)"+
|
||||
" FROM"+
|
||||
" trn_trans tt_bdate"+
|
||||
" WHERE"+
|
||||
" tt_bdate.trans_TYPCODE = 'WORKSTATION_OPEN'"+
|
||||
" AND tt_bdate.TRANS_STATCODE = 'COMPLETE'"+
|
||||
" )"+
|
||||
" AND tt.trans_TYPCODE = 'RETAIL_SALE'"+
|
||||
" AND tt.TRANS_STATCODE = 'COMPLETE'";
|
||||
|
||||
logger.info(saleTransactionQuery);
|
||||
try (PreparedStatement storeStatement = databaseConnection.getConnection().prepareStatement(saleTransactionQuery);
|
||||
ResultSet saleTransactionResultSet = storeStatement.executeQuery()) {
|
||||
|
||||
if (saleTransactionResultSet.next()) {
|
||||
XstoreTransaction saleTransaction = mapResultSetToXstoreSaleTransaction(saleTransactionResultSet);
|
||||
storeDetails.setSaleTransaction(saleTransaction);
|
||||
} else {
|
||||
// Adjust to the desired behavior if no results are found
|
||||
}
|
||||
}
|
||||
|
||||
// version section
|
||||
String versionQuery = "SELECT * FROM ( " +
|
||||
" SELECT CUSTOMER,CUSTOMER_SCHEMA_VERSION,CUSTOMER_SCHEMA_DATE" +
|
||||
" FROM dtv.CTL_VERSION_HISTORY" +
|
||||
" WHERE organization_id = 1 AND customer IS NOT NULL" +
|
||||
" ORDER BY seq DESC" +
|
||||
" ) " +
|
||||
" WHERE ROWNUM = 1";
|
||||
|
||||
logger.info(versionQuery);
|
||||
try (PreparedStatement versionStatement = databaseConnection.getConnection().prepareStatement(versionQuery)) {
|
||||
try (ResultSet versionResultSet = versionStatement.executeQuery()) {
|
||||
if (versionResultSet.next()) {
|
||||
storeDetails.setXstoreVersion(versionResultSet.getString("CUSTOMER_SCHEMA_VERSION"));
|
||||
storeDetails.setXstoreVersionDate(versionResultSet.getDate("CUSTOMER_SCHEMA_DATE"));
|
||||
storeDetails.setXstoreVersionCustomer(versionResultSet.getString("CUSTOMER"));
|
||||
} else {
|
||||
// Adjust to the desired behavior if no results are found
|
||||
} */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -574,7 +494,7 @@ public class StoreService {
|
|||
// Handle exceptions correctly in a production environment
|
||||
}
|
||||
|
||||
try (DatabaseConnectDOTSOFT databaseConnection = new DatabaseConnectDOTSOFT("com02")) {
|
||||
try (DatabaseConnectDOTSOFT databaseConnectionDS = new DatabaseConnectDOTSOFT("com02")) {
|
||||
// Store section
|
||||
String storeQuery = "SELECT st.id_structure," +
|
||||
" TRIM(st.nom) as nom," +
|
||||
|
|
@ -600,7 +520,7 @@ public class StoreService {
|
|||
" WHERE st.id_structure = ?";
|
||||
|
||||
logger.info(storeQuery);
|
||||
try (PreparedStatement storeStatement = databaseConnection.getConnection().prepareStatement(storeQuery)) {
|
||||
try (PreparedStatement storeStatement = databaseConnectionDS.getConnection().prepareStatement(storeQuery)) {
|
||||
storeStatement.setInt(1, storeId); // Set the value of the parameter
|
||||
|
||||
try (ResultSet storeResultSet = storeStatement.executeQuery()) {
|
||||
|
|
@ -614,27 +534,34 @@ public class StoreService {
|
|||
}
|
||||
|
||||
// Transaction section
|
||||
String transactionQuery = "SELECT COUNT(*) as backOfficeTransactions, " +
|
||||
String boTransactionQuery =
|
||||
"SELECT COUNT(*) AS backOfficeTransactions, " +
|
||||
" MIN(cf.fdate_integration) AS minBackOfficeTransactionDate, " +
|
||||
" MAX(cf.fdate_integration) AS maxBackOfficeTransactionDate, " +
|
||||
" TRUNC(MAX(cf.fdate)) AS backOfficeBusinessDate " +
|
||||
" MAX(cf.fdate_integration) AS maxBackOfficeTransactionDate " +
|
||||
"FROM com02.client_facture cf " +
|
||||
"WHERE cf.id_structure = ? " +
|
||||
"AND TRUNC(cf.fdate_integration) = TRUNC(SYSDATE) " + //TODO : changer la date
|
||||
"AND cf.version_info = 'XSTORE'";
|
||||
" AND cf.id_caisse = ? " +
|
||||
" AND TRUNC(cf.fdate) = ? " +
|
||||
" AND cf.version_info = 'XSTORE'";
|
||||
|
||||
logger.info(transactionQuery);
|
||||
try (PreparedStatement transactionStatement = databaseConnection.getConnection().prepareStatement(transactionQuery)) {
|
||||
transactionStatement.setInt(1, storeId); // Set the value of the parameter
|
||||
for (StorePos pos : storeDetails.getPos()) {
|
||||
logger.info(boTransactionQuery);
|
||||
try (PreparedStatement boTransactionStatement = databaseConnectionDS.getConnection().prepareStatement(boTransactionQuery)) {
|
||||
boTransactionStatement.setInt(1, storeId);
|
||||
boTransactionStatement.setInt(2, pos.getWorkstationId());
|
||||
boTransactionStatement.setDate(3, pos.getBusinessDate());
|
||||
|
||||
try (ResultSet transactionResultSet = transactionStatement.executeQuery()) {
|
||||
if (transactionResultSet.next()) {
|
||||
BackOfficeTransaction storetransaction = mapResultSetToBackOfficetransaction(transactionResultSet);
|
||||
storeDetails.setTransaction(storetransaction);
|
||||
try (ResultSet boTransactionResultSet = boTransactionStatement.executeQuery()) {
|
||||
if (boTransactionResultSet.next()) {
|
||||
BackOfficeTransaction boTransaction = mapResultSetToBoTransaction(boTransactionResultSet);
|
||||
pos.setBoTransaction(boTransaction);
|
||||
} else {
|
||||
// Adjust to the desired behavior if no results are found
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
// Handle exception
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
|
|
@ -645,6 +572,132 @@ public class StoreService {
|
|||
return storeDetails;
|
||||
}
|
||||
|
||||
private void retrieveStorePosDetails(DatabaseConnectXSTORE databaseConnection, Integer storeId, Integer workstationId, Date businessDate, StorePos pos) throws SQLException {
|
||||
// Replication section
|
||||
String replicationQuery = "SELECT COUNT(*) AS pendingReplications, " +
|
||||
"MIN(crq.CREATE_DATE) AS minPendingReplicationDate, " +
|
||||
"MAX(crq.CREATE_DATE) AS maxPendingReplicationDate " +
|
||||
"FROM repqueue.CTL_REPLICATION_QUEUE crq " +
|
||||
"WHERE crq.organization_id = 1 AND crq.RTL_LOC_ID = ? and crq.WKSTN_ID = ?";
|
||||
|
||||
logger.info(replicationQuery);
|
||||
try (PreparedStatement replicationStatement = databaseConnection.getConnection().prepareStatement(replicationQuery)) {
|
||||
replicationStatement.setInt(1, storeId);
|
||||
replicationStatement.setInt(2, workstationId);
|
||||
|
||||
try (ResultSet replicationResultSet = replicationStatement.executeQuery()) {
|
||||
if (replicationResultSet.next()) {
|
||||
PosReplication posReplication = mapResultSetToPosReplication(replicationResultSet);
|
||||
pos.setReplication(posReplication);
|
||||
} else {
|
||||
// Adjust to the desired behavior if no results are found
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// opening transation section
|
||||
String openingQuery =
|
||||
"SELECT MIN(lsj.TIME_STAMP) AS minOpeningDate " +
|
||||
"FROM loc_state_journal lsj " +
|
||||
"WHERE lsj.TIME_STAMP BETWEEN TRUNC(SYSDATE) AND TRUNC(SYSDATE + 1) " +
|
||||
"AND lsj.ORGANIZATION_ID = 1 " +
|
||||
"AND lsj.RTL_LOC_ID = ? " +
|
||||
"AND lsj.WKSTN_ID = ? " +
|
||||
"AND lsj.STATUS_TYPCODE = 'WKSTN_STATE' " +
|
||||
"AND lsj.STRING_VALUE = 'OPEN'";
|
||||
|
||||
logger.info(openingQuery);
|
||||
try (PreparedStatement openingStatement = databaseConnection.getConnection().prepareStatement(openingQuery)) {
|
||||
openingStatement.setInt(1, storeId);
|
||||
openingStatement.setInt(2, workstationId);
|
||||
|
||||
try (ResultSet openingResultSet = openingStatement.executeQuery()) {
|
||||
if (openingResultSet.next()) {
|
||||
pos.setOpeningDate(openingResultSet.getTimestamp("minOpeningDate"));
|
||||
} else {
|
||||
// Adjust to the desired behavior if no results are found
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// closing transation section
|
||||
String closingQuery =
|
||||
"SELECT MAX(lsj.TIME_STAMP) AS maxClosingDate " +
|
||||
"FROM loc_state_journal lsj " +
|
||||
"WHERE lsj.TIME_STAMP BETWEEN TRUNC(SYSDATE) AND TRUNC(SYSDATE + 1) " +
|
||||
"AND lsj.ORGANIZATION_ID = 1 " +
|
||||
"AND lsj.RTL_LOC_ID = ? " +
|
||||
"AND lsj.WKSTN_ID = ? " +
|
||||
"AND lsj.STATUS_TYPCODE = 'WKSTN_STATE' " +
|
||||
"AND lsj.STRING_VALUE = 'CLOSED'";
|
||||
|
||||
logger.info(closingQuery);
|
||||
try (PreparedStatement closingStatement = databaseConnection.getConnection().prepareStatement(closingQuery)) {
|
||||
closingStatement.setInt(1, storeId);
|
||||
closingStatement.setInt(2, workstationId);
|
||||
|
||||
try (ResultSet closingResultSet = closingStatement.executeQuery()) {
|
||||
if (closingResultSet.next()) {
|
||||
pos.setClosingDate(closingResultSet.getTimestamp("maxClosingDate"));
|
||||
} else {
|
||||
// Adjust to the desired behavior if no results are found
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sale transation section
|
||||
String saleTransactionQuery =
|
||||
"SELECT COUNT(*) AS counter, " +
|
||||
"MIN(tt.END_DATETIME) AS minDate, " +
|
||||
"MAX(tt.END_DATETIME) AS maxDate " +
|
||||
"FROM dtv.trn_trans tt " +
|
||||
"WHERE tt.ORGANIZATION_ID = 1 "+
|
||||
"AND tt.RTL_LOC_ID = ? " +
|
||||
"AND tt.BUSINESS_DATE = ? " +
|
||||
"AND tt.WKSTN_ID = ? " +
|
||||
"AND tt.trans_TYPCODE = 'RETAIL_SALE' " +
|
||||
"AND tt.TRANS_STATCODE = 'COMPLETE'";
|
||||
|
||||
logger.info(saleTransactionQuery);
|
||||
try (PreparedStatement saleTransactionStatement = databaseConnection.getConnection().prepareStatement(saleTransactionQuery)) {
|
||||
saleTransactionStatement.setInt(1, storeId);
|
||||
saleTransactionStatement.setDate(2, pos.getBusinessDate());
|
||||
saleTransactionStatement.setInt(3, workstationId);
|
||||
|
||||
try (ResultSet saleTransactionResultSet = saleTransactionStatement.executeQuery()) {
|
||||
if (saleTransactionResultSet.next()) {
|
||||
XstoreTransaction saleTransaction = mapResultSetToSaleTransaction(saleTransactionResultSet);
|
||||
pos.setSaleTransaction(saleTransaction);
|
||||
} else {
|
||||
// Adjust to the desired behavior if no results are found
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sale transation section
|
||||
String logQuery = "SELECT COUNT(*) as counter " +
|
||||
"FROM dtv.CTL_EVENT_LOG cel " +
|
||||
"WHERE cel.CREATE_DATE BETWEEN TRUNC(SYSDATE) AND TRUNC(SYSDATE + 1) " +
|
||||
"AND cel.ORGANIZATION_ID = 1 " +
|
||||
"AND cel.RTL_LOC_ID = ? " +
|
||||
"AND cel.WKSTN_ID = ? " +
|
||||
"AND cel.LOG_LEVEL = 'FATAL'";
|
||||
|
||||
logger.info(logQuery);
|
||||
try (PreparedStatement logStatement = databaseConnection.getConnection().prepareStatement(logQuery)) {
|
||||
logStatement.setInt(1, storeId);
|
||||
logStatement.setInt(2, workstationId);
|
||||
|
||||
try (ResultSet logResultSet = logStatement.executeQuery()) {
|
||||
if (logResultSet.next()) {
|
||||
pos.setFatalError(logResultSet.getInt("counter"));
|
||||
} else {
|
||||
// Adjust to the desired behavior if no results are found
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Store mapResultSetToStore(ResultSet resultSet) throws SQLException {
|
||||
Integer id_structure = resultSet.getInt("id_structure");
|
||||
String nom = resultSet.getString("nom");
|
||||
|
|
@ -659,15 +712,15 @@ public class StoreService {
|
|||
return new Store(id_structure, nom, telephone, photoLink, enseigne, pays, caisses, adresse, date_migration);
|
||||
}
|
||||
|
||||
private StoreReplication mapResultSetToStoreReplication(ResultSet resultSet) throws SQLException {
|
||||
private PosReplication mapResultSetToPosReplication(ResultSet resultSet) throws SQLException {
|
||||
int pendingReplications = resultSet.getInt("pendingReplications");
|
||||
Date minPendingReplicationDate = resultSet.getDate("minPendingReplicationDate");
|
||||
Date maxPendingReplicationDate = resultSet.getDate("maxPendingReplicationDate");
|
||||
|
||||
return new StoreReplication(pendingReplications, minPendingReplicationDate, maxPendingReplicationDate);
|
||||
return new PosReplication(pendingReplications, minPendingReplicationDate, maxPendingReplicationDate);
|
||||
}
|
||||
|
||||
private XstoreTransaction mapResultSetToXstoreOpeningTransaction(ResultSet resultSet) throws SQLException {
|
||||
private XstoreTransaction mapResultSetToSaleTransaction(ResultSet resultSet) throws SQLException {
|
||||
int count = resultSet.getInt("counter");
|
||||
Date minDate = resultSet.getDate("minDate");
|
||||
Date maxDate = resultSet.getDate("maxDate");
|
||||
|
|
@ -675,29 +728,12 @@ public class StoreService {
|
|||
return new XstoreTransaction(count, minDate, maxDate);
|
||||
}
|
||||
|
||||
private XstoreTransaction mapResultSetToXstoreClosingTransaction(ResultSet resultSet) throws SQLException {
|
||||
int count = resultSet.getInt("counter");
|
||||
Date minDate = resultSet.getDate("minDate");
|
||||
Date maxDate = resultSet.getDate("maxDate");
|
||||
|
||||
return new XstoreTransaction(count, minDate, maxDate);
|
||||
}
|
||||
|
||||
private XstoreTransaction mapResultSetToXstoreSaleTransaction(ResultSet resultSet) throws SQLException {
|
||||
int count = resultSet.getInt("counter");
|
||||
Date minDate = resultSet.getDate("minDate");
|
||||
Date maxDate = resultSet.getDate("maxDate");
|
||||
|
||||
return new XstoreTransaction(count, minDate, maxDate);
|
||||
}
|
||||
|
||||
private BackOfficeTransaction mapResultSetToBackOfficetransaction(ResultSet resultSet) throws SQLException {
|
||||
private BackOfficeTransaction mapResultSetToBoTransaction(ResultSet resultSet) throws SQLException {
|
||||
int backofficeTransactions = resultSet.getInt("backOfficeTransactions");
|
||||
Date minBackofficeTransactionDate = resultSet.getDate("minBackOfficeTransactionDate");
|
||||
Date maxBackofficeTransactionDate = resultSet.getDate("maxBackOfficeTransactionDate");
|
||||
Date backOfficeBusinessDate = resultSet.getDate("backOfficeBusinessDate");
|
||||
|
||||
return new BackOfficeTransaction(backofficeTransactions, minBackofficeTransactionDate, maxBackofficeTransactionDate, backOfficeBusinessDate);
|
||||
return new BackOfficeTransaction(backofficeTransactions, minBackofficeTransactionDate, maxBackofficeTransactionDate);
|
||||
}
|
||||
|
||||
private StoreVersion mapResultSetToStoreVersion(ResultSet resultSet) throws SQLException {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ public class BackOfficeTransaction {
|
|||
private int backOfficeTransactions;
|
||||
private Date minBackOfficeTransactionDate;
|
||||
private Date maxBackOfficeTransactionDate;
|
||||
private Date backOfficeBusinessDate;
|
||||
|
||||
|
||||
// Default constructor
|
||||
|
|
@ -16,11 +15,10 @@ public class BackOfficeTransaction {
|
|||
}
|
||||
|
||||
// Constructor with parameters
|
||||
public BackOfficeTransaction(int backOfficeTransactions, Date minbackOfficeTransactionDate, Date maxbackOfficeTransactionDate, Date backOfficeBusinessDate) {
|
||||
public BackOfficeTransaction(int backOfficeTransactions, Date minbackOfficeTransactionDate, Date maxbackOfficeTransactionDate) {
|
||||
this.backOfficeTransactions = backOfficeTransactions;
|
||||
this.minBackOfficeTransactionDate = minbackOfficeTransactionDate;
|
||||
this.maxBackOfficeTransactionDate = maxbackOfficeTransactionDate;
|
||||
this.backOfficeBusinessDate = backOfficeBusinessDate;
|
||||
}
|
||||
|
||||
// Getters et setters
|
||||
|
|
@ -57,18 +55,4 @@ public class BackOfficeTransaction {
|
|||
public void setMaxBackOfficeTransactionDate(Date maxBackOfficeTransactionDate) {
|
||||
this.maxBackOfficeTransactionDate = maxBackOfficeTransactionDate;
|
||||
}
|
||||
|
||||
public String getBackOfficeBusinessDate() {
|
||||
if (backOfficeBusinessDate != null) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
|
||||
return dateFormat.format(backOfficeBusinessDate);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setBackOfficeBusinessDate(Date backOfficeBusinessDate) {
|
||||
this.backOfficeBusinessDate = backOfficeBusinessDate;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,18 +3,18 @@ package com.example.services.store;
|
|||
import java.sql.Date;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
public class StoreReplication {
|
||||
public class PosReplication {
|
||||
private int pendingReplications;
|
||||
private Date minPendingReplicationDate;
|
||||
private Date maxPendingReplicationDate;
|
||||
|
||||
// Constructeur par défaut
|
||||
public StoreReplication() {
|
||||
// Default constructor
|
||||
public PosReplication() {
|
||||
// Default constructor required for JSON deserialization
|
||||
}
|
||||
|
||||
// Constructeur avec paramètres
|
||||
public StoreReplication(int pendingReplications, Date minPendingReplicationDate, Date maxPendingReplicationDate) {
|
||||
// Constructor with parameters
|
||||
public PosReplication(int pendingReplications, Date minPendingReplicationDate, Date maxPendingReplicationDate) {
|
||||
this.pendingReplications = pendingReplications;
|
||||
this.minPendingReplicationDate = minPendingReplicationDate;
|
||||
this.maxPendingReplicationDate = maxPendingReplicationDate;
|
||||
|
|
@ -1,34 +1,20 @@
|
|||
package com.example.services.store;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class StoreDetails {
|
||||
private Store store;
|
||||
private StoreReplication replication;
|
||||
private BackOfficeTransaction transaction;
|
||||
private XstoreTransaction openingTransaction;
|
||||
private XstoreTransaction closingTransaction;
|
||||
private XstoreTransaction saleTransaction;
|
||||
private String xstoreVersion;
|
||||
private Date xstoreVersionDate;
|
||||
private String xstoreVersionCustomer;
|
||||
|
||||
private List<StorePos> pos;
|
||||
|
||||
public StoreDetails() {
|
||||
// Constructeur par défaut nécessaire pour la désérialisation JSON
|
||||
this.pos = new ArrayList<>();
|
||||
}
|
||||
|
||||
public StoreDetails(Store store, StoreReplication replication, BackOfficeTransaction transaction, XstoreTransaction openingTransaction, XstoreTransaction closingTransaction, XstoreTransaction saleTransaction, String xstoreVersion, Date xstoreVersionDate, String xstoreVersionCustomer) {
|
||||
public StoreDetails(Store store, List<StorePos> pos) {
|
||||
this.store = store;
|
||||
this.replication = replication;
|
||||
this.transaction = transaction;
|
||||
this.openingTransaction = openingTransaction;
|
||||
this.closingTransaction = closingTransaction;
|
||||
this.saleTransaction = saleTransaction;
|
||||
this.xstoreVersion = xstoreVersion;
|
||||
this.xstoreVersionDate = xstoreVersionDate;
|
||||
this.xstoreVersionCustomer = xstoreVersionCustomer;
|
||||
this.pos = pos != null ? pos : new ArrayList<>();
|
||||
}
|
||||
|
||||
public Store getStore() {
|
||||
|
|
@ -39,73 +25,12 @@ public class StoreDetails {
|
|||
this.store = store;
|
||||
}
|
||||
|
||||
public StoreReplication getReplication() {
|
||||
return replication;
|
||||
public List<StorePos> getPos() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
public void setReplication(StoreReplication replication) {
|
||||
this.replication = replication;
|
||||
}
|
||||
|
||||
public BackOfficeTransaction getTransaction() {
|
||||
return transaction;
|
||||
}
|
||||
|
||||
public void setTransaction(BackOfficeTransaction transaction) {
|
||||
this.transaction = transaction;
|
||||
}
|
||||
|
||||
public XstoreTransaction getOpeningTransaction() {
|
||||
return openingTransaction;
|
||||
}
|
||||
|
||||
public void setOpeningTransaction(XstoreTransaction openingTransaction) {
|
||||
this.openingTransaction = openingTransaction;
|
||||
}
|
||||
|
||||
public XstoreTransaction getClosingTransaction() {
|
||||
return closingTransaction;
|
||||
}
|
||||
|
||||
public void setClosingTransaction(XstoreTransaction closingTransaction) {
|
||||
this.closingTransaction = closingTransaction;
|
||||
}
|
||||
|
||||
public XstoreTransaction getSaleTransaction() {
|
||||
return saleTransaction;
|
||||
}
|
||||
|
||||
public void setSaleTransaction(XstoreTransaction saleTransaction) {
|
||||
this.saleTransaction = saleTransaction;
|
||||
}
|
||||
|
||||
public String getXstoreVersion() {
|
||||
return xstoreVersion;
|
||||
}
|
||||
|
||||
public void setXstoreVersion(String xstoreVersion) {
|
||||
this.xstoreVersion = xstoreVersion;
|
||||
}
|
||||
|
||||
public String getXstoreVersionDate() {
|
||||
if (xstoreVersionDate != null) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
||||
return dateFormat.format(xstoreVersionDate);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public void setXstoreVersionDate(Date xstoreVersionDate) {
|
||||
this.xstoreVersionDate = xstoreVersionDate;
|
||||
}
|
||||
|
||||
public String getXstoreVersionCustomer() {
|
||||
return xstoreVersionCustomer;
|
||||
}
|
||||
|
||||
public void setXstoreVersionCustomer(String xstoreVersionCustomer) {
|
||||
this.xstoreVersionCustomer = xstoreVersionCustomer;
|
||||
public void setPos(List<StorePos> pos) {
|
||||
this.pos = pos;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,138 @@
|
|||
package com.example.services.store;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
public class StorePos {
|
||||
private int workstationId;
|
||||
private String ip;
|
||||
private String version;
|
||||
private Date businessDate;
|
||||
private String openingDate;
|
||||
private String closingDate;
|
||||
private BackOfficeTransaction boTransaction;
|
||||
private PosReplication replication;
|
||||
private XstoreTransaction saleTransaction;
|
||||
private boolean primaryRegister = false;
|
||||
private boolean fatalError = false;
|
||||
|
||||
// Default constructor
|
||||
public StorePos() {
|
||||
// Default constructor required for JSON deserialization
|
||||
}
|
||||
|
||||
// Constructor with parameters
|
||||
public StorePos( int workstationId, String ip, String version, Date businessDate, String openingDate, String closingDate ,BackOfficeTransaction boTransaction, PosReplication replication, XstoreTransaction saleTransaction, boolean primaryRegister, boolean fatalError) {
|
||||
this.workstationId = workstationId;
|
||||
this.ip = ip;
|
||||
this.version = version;
|
||||
this.businessDate = businessDate;
|
||||
this.openingDate = openingDate;
|
||||
this.closingDate = closingDate;
|
||||
this.boTransaction = boTransaction;
|
||||
this.replication = replication;
|
||||
this.saleTransaction = saleTransaction;
|
||||
this.primaryRegister = primaryRegister;
|
||||
this.fatalError = fatalError;
|
||||
}
|
||||
// Getters et setters
|
||||
public int getWorkstationId() {
|
||||
return workstationId;
|
||||
}
|
||||
public void setWorkstationId(int workstationId) {
|
||||
this.workstationId = workstationId;
|
||||
}
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getBusinessDateS() {
|
||||
if (businessDate != null) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
|
||||
return dateFormat.format(businessDate);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public Date getBusinessDate() {
|
||||
return businessDate;
|
||||
}
|
||||
|
||||
public void setBusinessDate(Date businessDate) {
|
||||
this.businessDate = businessDate;
|
||||
}
|
||||
|
||||
public String getOpeningDate() {
|
||||
return openingDate;
|
||||
}
|
||||
|
||||
public void setOpeningDate(java.sql.Timestamp openingDate) {
|
||||
if (openingDate != null) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
||||
String strOpeningDate = dateFormat.format(openingDate);
|
||||
this.openingDate = strOpeningDate;
|
||||
}
|
||||
}
|
||||
|
||||
public String getClosingDate() {
|
||||
return closingDate;
|
||||
}
|
||||
|
||||
public void setClosingDate(java.sql.Timestamp closingDate) {
|
||||
if (closingDate != null) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
||||
String strClosingDate = dateFormat.format(closingDate);
|
||||
this.closingDate = strClosingDate;
|
||||
}
|
||||
}
|
||||
|
||||
public BackOfficeTransaction getBoTransaction() {
|
||||
return boTransaction;
|
||||
}
|
||||
|
||||
public void setBoTransaction(BackOfficeTransaction boTransaction) {
|
||||
this.boTransaction = boTransaction;
|
||||
}
|
||||
|
||||
public PosReplication getReplication() {
|
||||
return replication;
|
||||
}
|
||||
|
||||
public void setReplication(PosReplication replication) {
|
||||
this.replication = replication;
|
||||
}
|
||||
|
||||
public XstoreTransaction getSaleTransaction() {
|
||||
return saleTransaction;
|
||||
}
|
||||
|
||||
public void setSaleTransaction(XstoreTransaction saleTransaction) {
|
||||
this.saleTransaction = saleTransaction;
|
||||
}
|
||||
|
||||
public boolean isPrimaryRegister() {
|
||||
return primaryRegister;
|
||||
}
|
||||
|
||||
public void setPrimaryRegister(int primaryRegister) {
|
||||
this.primaryRegister = (primaryRegister == 1);
|
||||
}
|
||||
|
||||
public boolean isFatalError() {
|
||||
return fatalError;
|
||||
}
|
||||
|
||||
public void setFatalError(int fatalError) {
|
||||
this.fatalError = (fatalError > 0);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue