gestita esportazione dei documenti di acquisto

This commit is contained in:
2024-07-25 17:39:50 +02:00
parent e52b9896d0
commit fa5b0393eb

View File

@@ -3180,32 +3180,38 @@ public class PvmService {
entityProcessor.processEntity(dtbDoct, multiDBTransactionManager);
result.add(dtbDoct);
String exportType = "";
String exportType = "", whereCondAnag = "";
gestione = dtbDoct.getGestione();
if ("V".equals(gestione)) {
exportType = "DOCUMENTI VENDITA";
whereCondAnag = " wtb_clie.cod_anag = " + UtilityDB.valueToString(dtbDoct.getCodAnag());
} else if ("L".equals(gestione)) {
exportType = "DOCUMENTI LAVORAZIONE";
whereCondAnag = " wtb_forn.cod_anag = " + UtilityDB.valueToString(dtbDoct.getCodAnag());
} else if ("A".equals(gestione)) {
exportType = "DOCUMENTI ACQUISTO";
whereCondAnag = " wtb_forn.cod_anag = " + UtilityDB.valueToString(dtbDoct.getCodAnag());
}
query =
"SELECT wtb_users.user_name, wtb_users.password, wtb_users_info.format_file, COUNT(wtb_users_info.format_file) over (partition by wtb_users_info.user_name) " +
" FROM wtb_users, wtb_users_info, wtb_clie " +
" WHERE wtb_users.User_name = wtb_users_info.user_name and " +
" wtb_users_info.User_name = wtb_clie.user_name and " +
" wtb_clie.cod_anag = " + UtilityDB.valueToString(dtbDoct.getCodAnag()) + " AND " +
" wtb_users_info.flag_state = 'S' and " +
" wtb_users_info.export_type = " + UtilityDB.valueToString(exportType);
PreparedStatement psExport = multiDBTransactionManager.prepareStatement(query);
ResultSet rsExport = psExport.executeQuery();
if (rsExport.next()) {
String userNameExport = rsExport.getString(1);
String passwordExport = rsExport.getString(2);
String formatExport = rsExport.getString(3);
Integer countExport = rsExport.getInt(4);
query =
"SELECT wtb_users.user_name, wtb_users.password, wtb_users_info.format_file, COUNT(wtb_users_info.format_file) over (partition by wtb_users_info.user_name) as count_export" +
" FROM wtb_users " +
"INNER JOIN wtb_users_info ON wtb_users.User_name = wtb_users_info.user_name " +
"LEFT OUTER JOIN wtb_clie ON wtb_users.User_name = wtb_clie.user_name AND wtb_users_info.export_type = 'DOCUMENTI VENDITA' " +
"LEFT OUTER JOIN wtb_forn ON wtb_users.User_name = wtb_forn.user_name AND wtb_users_info.export_type <> 'DOCUMENTI VENDITA'" +
" WHERE wtb_users_info.flag_state = 'S' and " +
" wtb_users_info.export_type = " + UtilityDB.valueToString(exportType);
query = UtilityDB.addwhereCond(query, whereCondAnag, true);
HashMap<String, Object> datiExport = UtilityDB.executeSimpleQueryOnlyFirstRow(multiDBTransactionManager.getPrimaryConnection(), query);
if (UtilityHashMap.isPresent(datiExport)) {
String userNameExport = UtilityHashMap.getValueIfExists(datiExport, "user_name");
String passwordExport = UtilityHashMap.getValueIfExists(datiExport, "password");
String formatExport = UtilityHashMap.getValueIfExists(datiExport, "format_file");
Integer countExport = UtilityHashMap.getValueIfExists(datiExport, "count_export");
if (countExport == 1) {
requestDataDTO.setUsername(userNameExport);
@@ -3225,8 +3231,6 @@ public class PvmService {
}
}
rsExport.close();
psExport.close();
} catch (Exception e) {
multiDBTransactionManager.rollbackAll();