feat: add date_migration
parent
66f98461e5
commit
a9837bf4f1
|
|
@ -65,11 +65,13 @@ public class StoreService {
|
|||
" WHERE" +
|
||||
" hsc2.id_structure = st.id_structure" +
|
||||
" AND hsc2.id_caisse BETWEEN 20 AND 39) AS caisses," +
|
||||
" REPLACE(REPLACE(TRIM(st.adresse1), chr(10), ''), chr(13), '') AS adresse" +
|
||||
" REPLACE(REPLACE(TRIM(st.adresse1), chr(10), ''), chr(13), '') AS adresse," +
|
||||
" axs.date_stock as date_migration" +
|
||||
" FROM COM02.structure st" +
|
||||
" JOIN com02.PARAM_PAYS pp ON pp.id_pays = st.id_pays" +
|
||||
" LEFT OUTER JOIN mobretail.mp_etab_param metabp ON metabp.id_etab = st.id_structure" +
|
||||
" LEFT OUTER JOIN mobretail.mr_photo mpprinc ON mpprinc.id_photo = metabp.id_photo_principale" +
|
||||
" LEFT OUTER JOIN omni.ASPD_XSTO_STRUCTURE axs ON st.ID_STRUCTURE = axs.ID_STRUCTURE " +
|
||||
" WHERE st.id_structure = ?";
|
||||
|
||||
logger.info(query);
|
||||
|
|
@ -100,6 +102,24 @@ public class StoreService {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets cachedStoreList to null, forcing a reload of stores from the database on the next call to /stores.
|
||||
*
|
||||
* @return A response indicating success
|
||||
*/
|
||||
@GET
|
||||
@Path("/reload")
|
||||
public Response reloadStores() {
|
||||
cacheLock.lock();
|
||||
try {
|
||||
cachedStoreList = null;
|
||||
} finally {
|
||||
cacheLock.unlock();
|
||||
}
|
||||
|
||||
return Response.ok("{\"status\":\"Cache cleared\"}").build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all stores from the database and returns them as a JSON response.
|
||||
*
|
||||
|
|
@ -156,12 +176,13 @@ public class StoreService {
|
|||
" WHERE" +
|
||||
" hsc2.id_structure = st.id_structure" +
|
||||
" AND hsc2.id_caisse BETWEEN 20 AND 39) AS caisses," +
|
||||
" REPLACE(REPLACE(TRIM(st.adresse1), chr(10), ''), chr(13), '') AS adresse" +
|
||||
" REPLACE(REPLACE(TRIM(st.adresse1), chr(10), ''), chr(13), '') AS adresse," +
|
||||
" axs.date_stock as date_migration" +
|
||||
" FROM COM02.structure st" +
|
||||
" JOIN com02.PARAM_PAYS pp ON pp.id_pays = st.id_pays" +
|
||||
" LEFT OUTER JOIN mobretail.mp_etab_param metabp ON metabp.id_etab = st.id_structure" +
|
||||
" LEFT OUTER JOIN mobretail.mr_photo mpprinc ON mpprinc.id_photo = metabp.id_photo_principale" +
|
||||
" LEFT OUTER JOIN omni.ASPD_XSTO_STRUCTURE axs ON st.ID_STRUCTURE = axs.ID_STRUCTURE " +
|
||||
" LEFT OUTER JOIN omni.ASPD_XSTO_STRUCTURE axs ON st.ID_STRUCTURE = axs.ID_STRUCTURE" +
|
||||
" WHERE axs.date_stock is not null AND st.ID_NIVEAU=4 AND st.STATUT=2 AND st.id_canal_distribution = 1 and st.magasin_demo = 0" +
|
||||
" ORDER BY st.id_structure";
|
||||
|
||||
|
|
@ -358,6 +379,7 @@ public class StoreService {
|
|||
store.setPays(resultSet.getString("PAYS"));
|
||||
store.setCaisses(resultSet.getString("CAISSES"));
|
||||
store.setAdresse(resultSet.getString("ADRESSE"));
|
||||
store.setDate_migration(resultSet.getDate("DATE_MIGRATION"));
|
||||
|
||||
return store;
|
||||
}
|
||||
|
|
@ -568,11 +590,13 @@ public class StoreService {
|
|||
" WHERE" +
|
||||
" hsc2.id_structure = st.id_structure" +
|
||||
" AND hsc2.id_caisse BETWEEN 20 AND 39) AS caisses," +
|
||||
" REPLACE(REPLACE(TRIM(st.adresse1), chr(10), ''), chr(13), '') AS adresse" +
|
||||
" REPLACE(REPLACE(TRIM(st.adresse1), chr(10), ''), chr(13), '') AS adresse," +
|
||||
" axs.date_stock as date_migration" +
|
||||
" FROM COM02.structure st" +
|
||||
" JOIN com02.PARAM_PAYS pp ON pp.id_pays = st.id_pays" +
|
||||
" LEFT OUTER JOIN mobretail.mp_etab_param metabp ON metabp.id_etab = st.id_structure" +
|
||||
" LEFT OUTER JOIN mobretail.mr_photo mpprinc ON mpprinc.id_photo = metabp.id_photo_principale" +
|
||||
" LEFT OUTER JOIN omni.ASPD_XSTO_STRUCTURE axs ON st.ID_STRUCTURE = axs.ID_STRUCTURE " +
|
||||
" WHERE st.id_structure = ?";
|
||||
|
||||
logger.info(storeQuery);
|
||||
|
|
@ -630,8 +654,9 @@ public class StoreService {
|
|||
String pays = resultSet.getString("pays");
|
||||
String caisses = resultSet.getString("caisses");
|
||||
String adresse = resultSet.getString("adresse");
|
||||
Date date_migration = resultSet.getDate("date_migration");
|
||||
|
||||
return new Store(id_structure, nom, telephone, photoLink, enseigne, pays, caisses, adresse);
|
||||
return new Store(id_structure, nom, telephone, photoLink, enseigne, pays, caisses, adresse, date_migration);
|
||||
}
|
||||
|
||||
private StoreReplication mapResultSetToStoreReplication(ResultSet resultSet) throws SQLException {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.example.services.store;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
|
@ -16,6 +18,7 @@ public class Store {
|
|||
private Integer nbcaisses;
|
||||
private String adresse;
|
||||
private List<Caisse> caisses;
|
||||
private Date date_migration;
|
||||
|
||||
// Default constructor
|
||||
public Store() {
|
||||
|
|
@ -23,7 +26,7 @@ public class Store {
|
|||
}
|
||||
|
||||
// Constructor with parameters
|
||||
public Store(Integer id_structure, String nom, String telephone, String photoLink, String enseigne, String pays, String caisses, String adresse) {
|
||||
public Store(Integer id_structure, String nom, String telephone, String photoLink, String enseigne, String pays, String caisses, String adresse, Date date_migration) {
|
||||
this.id_structure = id_structure;
|
||||
this.nom = nom;
|
||||
this.telephone = telephone;
|
||||
|
|
@ -31,6 +34,7 @@ public class Store {
|
|||
this.enseigne = enseigne;
|
||||
this.pays = pays;
|
||||
this.adresse = adresse;
|
||||
this.date_migration = date_migration;
|
||||
|
||||
setCaisses(caisses);
|
||||
}
|
||||
|
|
@ -117,6 +121,19 @@ public class Store {
|
|||
Collections.sort(this.caisses, Comparator.comparing(Caisse::getId_caisse));
|
||||
}
|
||||
|
||||
public String getDate_migration() {
|
||||
if (date_migration != null) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
||||
return dateFormat.format(date_migration);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public void setDate_migration(Date date_migration) {
|
||||
this.date_migration = date_migration;
|
||||
}
|
||||
|
||||
public class Caisse {
|
||||
private Integer id_caisse;
|
||||
private String ip;
|
||||
|
|
|
|||
Loading…
Reference in New Issue