Elabora Cpt
unknown
java
4 years ago
15 kB
12
Indexable
private void cmdElaboraContropartiActionPerformed(java.awt.event.ActionEvent evt) {
nazioni = null;
comuni = null;
vetImportControparti = new ArrayList<controparteImport>();
CountSet nazNT = new CountSet();
CountSet comuniNT = new CountSet();
CountSet agentiNT = new CountSet();
CountSet vettoriNT = new CountSet();
CountSet tipiScadenzeNT = new CountSet();
CountSet bancheNT = new CountSet();
CountSet classificazioniNT = new CountSet();
CountSet tipiTrasportoNT = new CountSet();
CountSet nezziTrasportoNT = new CountSet();
HashMap<String, Controparte> agenti = new HashMap<>();
String hql = "select c from Controparte c where c.isAgente=true";
Collection contro = (Collection) executeHqlQuery(hql);
for (Iterator it = contro.iterator(); it.hasNext();) {
Controparte co = (Controparte) it.next();
agenti.put(co.getCodice().trim().substring(1), co);
}
HashMap<String, Controparte> vettori = new HashMap<>();
hql = "select c from Controparte c where c.isVettore=true";
contro = (Collection) executeHqlQuery(hql);
for (Iterator it = contro.iterator(); it.hasNext();) {
Controparte co = (Controparte) it.next();
vettori.put(co.getCodice().trim().substring(1), co);
}
//Controparte c= new Controparte();
HashMap<String, Tipo> classificazioni = new HashMap<>();
hql = "select c from Tipo c where c.codice like 'PcnTp%'";
contro = (Collection) executeHqlQuery(hql);
for (Iterator it = contro.iterator(); it.hasNext();) {
Tipo co = (Tipo) it.next();
if(co.getValore()!=null){
classificazioni.put(co.getCodice().trim().toUpperCase().substring(5), co);
}
}
HashMap<String, Tipo> tipiTrasporto = new HashMap<>();
hql = "select c from Tipo c where c.codice like 'DdoPtr%'";
contro = (Collection) executeHqlQuery(hql);
for (Iterator it = contro.iterator(); it.hasNext();) {
Tipo co = (Tipo) it.next();
if(co.getValore()!=null){
tipiTrasporto.put(co.getValore().trim().toUpperCase(), co);
}
}
HashMap<String, Tipo> mezzoTrasporto = new HashMap<>();
hql = "select c from Tipo c where c.codice like 'DdoMrt%'";
contro = (Collection) executeHqlQuery(hql);
for (Iterator it = contro.iterator(); it.hasNext();) {
Tipo co = (Tipo) it.next();
if(co.getValore()!=null){
mezzoTrasporto.put(co.getValore().trim().toUpperCase(), co);
}
}
HashMap<String, TipoScadenza> tipiScadenze = new HashMap<>();
hql = "select c from TipoScadenza c ";
contro = (Collection) executeHqlQuery(hql);
for (Iterator it = contro.iterator(); it.hasNext();) {
TipoScadenza co = (TipoScadenza) it.next();
tipiScadenze.put(co.getCodice(), co);
}
for (String[] d : data) {
controparteImport c = new controparteImport();
try {
c.codice = Integer.parseInt(getCampo("Codice", d)) + "";
} catch (Exception ex) {
c.codice = getCampo("Codice", d);
}
if (c.codice != null) {
c.codice = c.codice.replace(".", "");
}
c.denominazione = getCampo("Denominazione", d);
c.pIva = getCampo("P.Iva", d);
c.Cfiscale = getCampo("C.Fiscale", d);
c.cap = getCampo("CAP", d);
c.civico = getCampo("Civico", d);
c.via = getCampo("Via", d);
c.note = getCampo("Note", d);
c.telefono = getCampo("Telefono", d);
c.rifTel1 = getCampo("RifTel1", d);
c.telefono2 = getCampo("Telefono2", d);
c.rifTel2 = getCampo("RifTel2", d);
c.fax = getCampo("Fax", d);
c.cellulare = getCampo("Cellulare", d);
c.mail = getCampo("E-Mail", d);
c.mail2 = getCampo("E-Mail2", d);
c.mail3 = getCampo("E-Mail3", d);
c.mail4 = getCampo("E-Mail4", d);
c.contocorrente = getCampo("ContoCorrente", d);
c.datiBanca = getCampo("DatiBanca", d);
c.sdi=getCampo("SDI", d);
c.pec=getCampo("Pec", d);
try {
c.sconto = Double.parseDouble(getCampo("Sconto", d));
} catch (Exception ex) {
}
try {
c.fido = Double.parseDouble(getCampo("Fido", d));
} catch (Exception ex) {
}
String abi = getCampo("Abi", d);
String cab = getCampo("Cab", d);
if (abi != null && cab != null && !abi.trim().equals("") && !cab.trim().equals("")) {
try {
c.banca = DlgMdlAnagPagamento.getBancaByAbiCab(new TString(abi + "-" + cab));
if (c.banca == null) {
bancheNT.add(abi + "-" + cab);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
String codAgente = "";
try {
codAgente = Integer.parseInt(getCampo("CODAGENTE", d)) + "";
} catch (Exception ex) {
codAgente = null;
}
if (codAgente != null && codAgente.trim().length() > 0) {
c.agente = agenti.get(codAgente);
if (c.agente == null) {
agentiNT.add(codAgente);
}
}
String codVettore = "";
try {
codVettore = Integer.parseInt(getCampo("TrasportoCodVettore", d)) + "";
} catch (Exception ex) {
codVettore = null;
}
if (codVettore != null && codVettore.trim().length() > 0) {
c.vettore = vettori.get(codVettore);
if (c.vettore == null) {
vettoriNT.add(codVettore);
}
}
String tipoIncasso=getCampo("TipoIncasso", d);
if(tipoIncasso!=null){
TipoScadenza ts = tipiScadenze.get("I"+tipoIncasso);
if(ts!=null){
c.tipoIncasso=ts;
}else{
tipiScadenzeNT.add("I"+tipoIncasso);
}
}
String classificazione=getCampo("Classificazione", d);
if(classificazione!=null){
Tipo ts = classificazioni.get(classificazione);
if(ts!=null){
c.classificazione=ts;
}else{
classificazioniNT.add(classificazione);
}
}
String porto=getCampo("TrasportoPorto", d);
if(porto!=null){
Tipo ts = tipiTrasporto.get(porto.trim().toUpperCase());
if(ts!=null){
c.porto=ts;
}else{
tipiTrasportoNT.add(porto);
}
}
String mezzo=getCampo("TrasportoMezzo", d);
if(mezzo!=null){
mezzo=mezzo.trim().toUpperCase();
Tipo ts = mezzoTrasporto.get(mezzo);
if(ts==null && mezzo.equals("M")){
ts = mezzoTrasporto.get("MITTENTE");
}
if(ts==null && mezzo.equals("V")){
ts = mezzoTrasporto.get("VETTORE");
}
if(ts==null && mezzo.equals("D")){
ts = mezzoTrasporto.get("DESTINATARIO");
}
if(ts!=null){
c.mezzotrasporto=ts;
}else{
nezziTrasportoNT.add(mezzo);
}
}
try {
c.provvigione = new Double(getCampo("Provvigione", d));
} catch (Exception e) {
c.provvigione = 0.0;
}
setIndirizzo(c, getCampo("Nazione", d), getCampo("Provincia", d), getCampo("Comune", d));
vetImportControparti.add(c);
if (c.comune == null || c.indirizzoManuale != null) {
c.comune = null;
if (c.nazione != null && c.nazione.getSigla().equals("IT")) {
String pr= "(" + getCampo("Provincia", d) + ")";
comuniNT.add(getCampo("Comune", d) + " " +pr);
}
if (c.nazione == null) {
nazNT.add(getCampo("Nazione", d));
}
}
}
int indMan = 0;
int noNaz = 0;
for (controparteImport c : vetImportControparti) {
if (c.comune == null) {
indMan++;
if (c.nazione == null) {
noNaz++;
}
}
}
String msg = "Controparti Da Importate: " + vetImportControparti.size() + "\n"
+ "Indirizzi Importati Manualmente: " + indMan + "\n"
+ "Nazioni Non Identificate: " + noNaz + "\n"
+ "In Caso i Codici Controparte fossero non univoci la specifica controparte non sara importata.\n";
if (nazNT.size() > 0) {
msg += "Nazioni non trovate:\n";
for (Map.Entry<String, Integer> m : nazNT.entrySet()) {
msg += m.getKey()+" "+m.getValue() + "\n";
}
}
if (comuniNT.size() > 0) {
msg += "Comuni non trovati:\n";
for (Map.Entry<String, Integer> m : comuniNT.entrySet()) {
msg += m.getKey()+" "+m.getValue() + "\n";
}
}
if (bancheNT.size() > 0) {
msg += "Banche non trovate:\n";
for (Map.Entry<String, Integer> m : bancheNT.entrySet()) {
msg += m.getKey()+" "+m.getValue() + "\n";
}
}
if (agentiNT.size() > 0) {
msg += "Codici Agenti non trovati:\n";
for (Map.Entry<String, Integer> m : agentiNT.entrySet()) {
msg += m.getKey()+" "+m.getValue() + "\n";
}
}
if (tipiScadenzeNT.size() > 0) {
msg += "Codici Scadenze non trovati:\n";
for (Map.Entry<String, Integer> m : tipiScadenzeNT.entrySet()) {
msg += m.getKey()+" "+m.getValue() + "\n";
}
}
if (vettoriNT.size() > 0) {
msg += "Codici Vettori non trovati:\n";
for (Map.Entry<String, Integer> m : vettoriNT.entrySet()) {
msg += m.getKey()+" "+m.getValue() + "\n";
}
}
if (tipiTrasportoNT.size() > 0) {
msg += "Tipi Trasporto non trovati:\n";
for (Map.Entry<String, Integer> m : tipiTrasportoNT.entrySet()) {
msg += m.getKey()+" "+m.getValue() + "\n";
}
}
if (classificazioniNT.size() > 0) {
msg += "Classificazioni non trovate:\n";
for (Map.Entry<String, Integer> m : classificazioniNT.entrySet()) {
msg += m.getKey()+" "+m.getValue() + "\n";
}
}
if (nezziTrasportoNT.size() > 0) {
msg += "Mezzi Trasporto non trovati:\n";
for (Map.Entry<String, Integer> m : nezziTrasportoNT.entrySet()) {
msg += m.getKey()+" "+m.getValue() + "\n";
}
}
txtResocontoControparte.setText(msg);
jTContropartiImport.setModel(new AbstractTableModel() {
@Override
public int getRowCount() {
return vetImportControparti.size();
}
@Override
public int getColumnCount() {
return 23;
}
@Override
public String getColumnName(int columnIndex) {
switch (columnIndex) {
case 0:
return "Codice";
case 1:
return "Denominazione";
case 2:
return "pIva";
case 3:
return "Cfiscale";
case 4:
return "Nazione";
case 5:
return "Comune";
case 6:
return "Via";
case 7:
return "Cap";
case 8:
return "Civico";
case 9:
return "Indirizzo Manuale";
case 10:
return "Provvigione";
case 11:
return "Telefono";
case 12:
return "Telefono2";
case 13:
return "Cellulare";
case 14:
return "Email";
case 15:
return "FAX";
case 16:
return "RIF TEL1";
case 17:
return "RIF TEL2";
case 18:
return "Sconto";
case 19:
return "Fido";
case 20:
return "Dati Banca";
case 21:
return "Banca";
case 22:
return "Contocorrente";
}
return "";
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
controparteImport c = vetImportControparti.get(rowIndex);
switch (columnIndex) {
case 0:
return c.codice;
case 1:
return c.denominazione;
case 2:
return c.pIva;
case 3:
return c.Cfiscale;
case 4:
return c.nazione;
case 5:
return c.comune;
case 6:
return c.via;
case 7:
return c.cap;
case 8:
return c.civico;
case 9:
return c.indirizzoManuale;
case 10:
return c.provvigione;
case 11:
return c.telefono;
case 12:
return c.telefono2;
case 13:
return c.cellulare;
case 14:
return c.mail;
case 15:
return c.fax;
case 16:
return c.rifTel1;
case 17:
return c.rifTel2;
case 18:
return c.sconto;
case 19:
return c.fido;
case 20:
return c.datiBanca;
case 21:
return c.banca;
case 22:
return c.contocorrente;
}
return "";
}
});
}Editor is loading...