[DEMO]
messi dati MRP e MES in cache per biolevante !!TEMPORANEAMENTE!!
This commit is contained in:
@@ -46,6 +46,17 @@ public class MrpConsumiHandlerService {
|
|||||||
if ( saveCache() ) {
|
if ( saveCache() ) {
|
||||||
looperService.add(() -> this.internalCacheConsumi(consumiCachedData), (UtilityDebug.isDebugExecution()?5:1) * 60 * 1000, MrpConsumiHandlerService.class.getName());
|
looperService.add(() -> this.internalCacheConsumi(consumiCachedData), (UtilityDebug.isDebugExecution()?5:1) * 60 * 1000, MrpConsumiHandlerService.class.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer()) {
|
||||||
|
looperService.add(() -> {
|
||||||
|
try {
|
||||||
|
loadConsumi( "biolevante", "BIOLEVANTE", consumiCachedData);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}, 5 * 1000, ProductionOrderDataHandlerService.class.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean saveCache(){
|
private boolean saveCache(){
|
||||||
@@ -66,21 +77,9 @@ public class MrpConsumiHandlerService {
|
|||||||
for (String dbName : databases.keySet()) {
|
for (String dbName : databases.keySet()) {
|
||||||
String profileName = databases.get(dbName).get(0).getProfileName();
|
String profileName = databases.get(dbName).get(0).getProfileName();
|
||||||
|
|
||||||
Date startDate = new Date();
|
|
||||||
MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(profileName, false);
|
|
||||||
|
|
||||||
boolean gestioneAbilitata = isGestioneAbilitata(multiDBTransactionManager);
|
loadConsumi(dbName,profileName,consumiList);
|
||||||
|
|
||||||
if ( gestioneAbilitata ) {
|
|
||||||
Map<String, List<MRPDailyConsumiDTO>> consumi = getConsumi(multiDBTransactionManager);
|
|
||||||
HashMap<String, Map<String, List<MRPDailyConsumiDTO>>> section = getSectionConsumiByDBName(consumiList, dbName);
|
|
||||||
section.clear();
|
|
||||||
section.put(dbName, consumi);
|
|
||||||
|
|
||||||
}
|
|
||||||
logger.trace(MrpConsumiHandlerService.class.getSimpleName() + " - Consumi: Timing " + ((new Date().getTime() - startDate.getTime()) / 1000) + " secs");
|
|
||||||
|
|
||||||
multiDBTransactionManager.closeAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@@ -88,6 +87,24 @@ public class MrpConsumiHandlerService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void loadConsumi(String dbName, String profileName, HashMap<String, HashMap<String, Map<String, List<MRPDailyConsumiDTO>>>> consumiList) throws Exception {
|
||||||
|
Date startDate = new Date();
|
||||||
|
MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(profileName, false);
|
||||||
|
|
||||||
|
boolean gestioneAbilitata = isGestioneAbilitata(multiDBTransactionManager);
|
||||||
|
|
||||||
|
if ( gestioneAbilitata ) {
|
||||||
|
Map<String, List<MRPDailyConsumiDTO>> consumi = getConsumi(multiDBTransactionManager);
|
||||||
|
HashMap<String, Map<String, List<MRPDailyConsumiDTO>>> section = getSectionConsumiByDBName(consumiList, dbName);
|
||||||
|
section.clear();
|
||||||
|
section.put(dbName, consumi);
|
||||||
|
|
||||||
|
}
|
||||||
|
logger.trace(MrpConsumiHandlerService.class.getSimpleName() + " - Consumi: Timing " + ((new Date().getTime() - startDate.getTime()) / 1000) + " secs");
|
||||||
|
|
||||||
|
multiDBTransactionManager.closeAll();
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean isGestioneAbilitata(MultiDBTransactionManager multiDBTransactionManager) throws Exception {
|
private static boolean isGestioneAbilitata(MultiDBTransactionManager multiDBTransactionManager) throws Exception {
|
||||||
String sql =
|
String sql =
|
||||||
"SELECT CAST(COUNT(*) AS BIT)\n" +
|
"SELECT CAST(COUNT(*) AS BIT)\n" +
|
||||||
@@ -234,7 +251,7 @@ public class MrpConsumiHandlerService {
|
|||||||
public Map<String, List<MRPDailyConsumiDTO>> getConsumi() throws Exception {
|
public Map<String, List<MRPDailyConsumiDTO>> getConsumi() throws Exception {
|
||||||
MultiDBTransactionManager multiDBTransactionManager = ContextLoader.getCurrentWebApplicationContext().getBean(MultiDBTransactionManager.class);
|
MultiDBTransactionManager multiDBTransactionManager = ContextLoader.getCurrentWebApplicationContext().getBean(MultiDBTransactionManager.class);
|
||||||
|
|
||||||
if (!saveCache()) {
|
if (!saveCache() && !multiDBTransactionManager.getPrimaryDatasource().getDbName().equalsIgnoreCase("biolevante")) {
|
||||||
return getConsumi(multiDBTransactionManager);
|
return getConsumi(multiDBTransactionManager);
|
||||||
} else {
|
} else {
|
||||||
HashMap<String, HashMap<String, Map<String, List<MRPDailyConsumiDTO>>>> inputMap = consumiCachedData;
|
HashMap<String, HashMap<String, Map<String, List<MRPDailyConsumiDTO>>>> inputMap = consumiCachedData;
|
||||||
|
|||||||
@@ -52,6 +52,16 @@ public class ProductionOrderDataHandlerService {
|
|||||||
if (!UtilityDebug.isDebugExecution() && !UtilityDebug.isIntegryServer()) {
|
if (!UtilityDebug.isDebugExecution() && !UtilityDebug.isIntegryServer()) {
|
||||||
looperService.add(() -> this.internalCacheOrdiniLavorazione(true, inevasiOrdersCachedData), 5 * 1000, ProductionOrderDataHandlerService.class.getName());
|
looperService.add(() -> this.internalCacheOrdiniLavorazione(true, inevasiOrdersCachedData), 5 * 1000, ProductionOrderDataHandlerService.class.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer()) {
|
||||||
|
looperService.add(() -> {
|
||||||
|
try {
|
||||||
|
loadOrdiniProfile(false, "biolevante", "BIOLEVANTE", inevasiOrdersCachedData);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}, 5 * 1000, ProductionOrderDataHandlerService.class.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -144,9 +154,7 @@ public class ProductionOrderDataHandlerService {
|
|||||||
MultiDBTransactionManager multiDBTransactionManager = ContextLoader.getCurrentWebApplicationContext().getBean(MultiDBTransactionManager.class);
|
MultiDBTransactionManager multiDBTransactionManager = ContextLoader.getCurrentWebApplicationContext().getBean(MultiDBTransactionManager.class);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
UtilityDebug.isIntegryServer()
|
UtilityString.isNullOrEmpty(flagEvaso)
|
||||||
|| UtilityDebug.isDebugExecution()
|
|
||||||
|| UtilityString.isNullOrEmpty(flagEvaso)
|
|
||||||
|| !flagEvaso.equalsIgnoreCase("I")
|
|| !flagEvaso.equalsIgnoreCase("I")
|
||||||
|| !isMESEnabled(multiDBTransactionManager)) {
|
|| !isMESEnabled(multiDBTransactionManager)) {
|
||||||
return getOrdiniLavorazione(multiDBTransactionManager, flagEvaso, linee, startDate, endDate, codAnag, whereCond);
|
return getOrdiniLavorazione(multiDBTransactionManager, flagEvaso, linee, startDate, endDate, codAnag, whereCond);
|
||||||
|
|||||||
Reference in New Issue
Block a user