sistemato messaggio di errore

This commit is contained in:
2024-07-08 18:01:08 +02:00
parent 21e2267340
commit f7e9fca83f

View File

@@ -657,59 +657,47 @@ public class OrdikidsService {
}
private Map<String, String> getCond_vvwClientiAgenti(String md5User) throws Exception {
String sqlNative, ls_codVage, ls_userAge, ls_condAggWClie, ls_codAnagAge, ls_codScoCliAge;
Map<String, String> DatiAgente = new HashMap<String, String>();
ResultSet rs = null;
PreparedStatement ps = null;
try {
sqlNative = " SELECT wtb_users.user_name, vtb_agen.cod_vage, ISNULL(vtb_agen.cond_clie_agg , '') AS cond_clie_agg "
+ " FROM vtb_agen, wtb_users "
+ " WHERE dbo.MD5_encode(lower(wtb_users.user_name + wtb_users.password)) = " + UtilityDB.valueToString(md5User) + " AND "
+ " wtb_users.User_code = vtb_agen.cod_vage AND "
+ " wtb_users.key_group = 5 AND "
+ " wtb_users.ctrl_state = 'S' ";
ps = multiDBTransactionManager.prepareStatement(sqlNative);
rs = ps.executeQuery();
if (rs.next()) {
ls_userAge = rs.getString("user_name");
ls_codVage = rs.getString("cod_vage");
ls_condAggWClie = rs.getString("cond_clie_agg");
if (ls_condAggWClie.length() > 0) {
ls_condAggWClie = "(" + ls_condAggWClie + ") OR ";
}
ls_condAggWClie = "(" + ls_condAggWClie + " vvw_clienti_agenti.cod_vage = '" + ls_codVage + "') ";
String sql, codVage, userAge, condAggWClie, codAnagAge;
Map<String, String> DatiAgente = new HashMap<>();
} else {
throw new Exception("Credenziali utente non valide");
sql = " SELECT wtb_users.user_name, vtb_agen.cod_vage, ISNULL(vtb_agen.cond_clie_agg , '') AS cond_clie_agg "
+ " FROM vtb_agen, wtb_users "
+ " WHERE dbo.MD5_encode(lower(wtb_users.user_name + wtb_users.password)) = " + UtilityDB.valueToString(md5User) + " AND "
+ " wtb_users.User_code = vtb_agen.cod_vage AND "
+ " wtb_users.key_group = 5 AND "
+ " wtb_users.ctrl_state = 'S' ";
HashMap<String, Object> datiAgenteDb = UtilityDB.executeSimpleQueryOnlyFirstRow(multiDBTransactionManager.getPrimaryConnection(), sql);
if ( datiAgenteDb != null && !datiAgenteDb.isEmpty()) {
userAge = UtilityHashMap.getValueIfExists(datiAgenteDb, "user_name");
codVage = UtilityHashMap.getValueIfExists(datiAgenteDb, "cod_vage");
condAggWClie = UtilityHashMap.getValueIfExists(datiAgenteDb, "cond_clie_agg");
if (!UtilityString.isNullOrEmpty(condAggWClie)) {
condAggWClie = "(" + condAggWClie + ") OR ";
}
rs.close();
ps.close();
condAggWClie = "(" + condAggWClie + " vvw_clienti_agenti.cod_vage = '" + codVage + "') ";
// CREAZIONE DEL CODICE ANAGRAFICO GENERICO A PARTIRE DAL CODICE
// DELL'AGENTE
ls_codAnagAge = UtilityString.rightPad(ls_codVage, 5, '0');
sqlNative = " SELECT cod_sco_cli FROM vtb_clie WHERE cod_anag = " + UtilityDB.valueToString(ls_codAnagAge);
ps = multiDBTransactionManager.prepareStatement(sqlNative);
rs = ps.executeQuery();
if (rs.next()) {
ls_codScoCliAge = rs.getString("cod_sco_cli");
} else {
throw new Exception("Errore configurazione anagrafica Generica Agente: " + ls_codAnagAge);
}
// POPOLAMENTO STRUTTURA DI OUTPUT
DatiAgente.put("user_name", ls_userAge);
DatiAgente.put("cod_vage", ls_codVage);
DatiAgente.put("cod_anag", ls_codAnagAge);
DatiAgente.put("cod_sco_cli", ls_codScoCliAge);
DatiAgente.put("cond_agg", ls_condAggWClie);
return DatiAgente;
} finally {
if (rs != null)
rs.close();
} else {
throw new Exception("Credenziali utente non valide");
}
// CREAZIONE DEL CODICE ANAGRAFICO GENERICO A PARTIRE DAL CODICE
// DELL'AGENTE
codAnagAge = UtilityString.rightPad(codVage, 5, '0');
sql = " SELECT cod_sco_cli FROM vtb_clie WHERE cod_anag = " + UtilityDB.valueToString(codAnagAge);
String codScoCliAge = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
if (UtilityString.isNullOrEmpty(codScoCliAge)) {
throw new Exception(String.format("Errore configurazione anagrafica cliente generico ( %s ) per l'agente %s ", codAnagAge, codVage));
}
// POPOLAMENTO STRUTTURA DI OUTPUT
DatiAgente.put("user_name", userAge);
DatiAgente.put("cod_vage", codVage);
DatiAgente.put("cod_anag", codAnagAge);
DatiAgente.put("cod_sco_cli", codScoCliAge);
DatiAgente.put("cond_agg", condAggWClie);
return DatiAgente;
}
private Boolean verificaUtente(String md5Agente) throws Exception {