package it.acxent.art; import com.ebay.soap.eBLBaseComponents.ItemType; import com.lowagie.text.Cell; import com.lowagie.text.Chunk; import com.lowagie.text.Document; import com.lowagie.text.Element; import com.lowagie.text.Font; import com.lowagie.text.HeaderFooter; import com.lowagie.text.Image; import com.lowagie.text.PageSize; import com.lowagie.text.Paragraph; import com.lowagie.text.Phrase; import com.lowagie.text.Rectangle; import com.lowagie.text.Table; import com.lowagie.text.pdf.Barcode128; import com.lowagie.text.pdf.PdfContentByte; import com.lowagie.text.pdf.PdfPCell; import com.lowagie.text.pdf.PdfPTable; import com.lowagie.text.pdf.PdfWriter; import it.acxent.anag.Clifor; import it.acxent.anag.DestinazioneDiversa; import it.acxent.anag.Iva; import it.acxent.anag.Listino; import it.acxent.anag.ListinoArticolo; import it.acxent.anag.MagFisico; import it.acxent.anag.Nazione; import it.acxent.anag.PrezzoArticolo; import it.acxent.anag.TipoPagamento; import it.acxent.anag.Users; import it.acxent.api.amz.AmzResult; import it.acxent.api.amz.AmzSellerApi; import it.acxent.api.ebay.EbayAbliaApi; import it.acxent.api.ebay.EbayResult; import it.acxent.bank.consel.ConselTabfin; import it.acxent.cart.Cart; import it.acxent.cart.CartItemId; import it.acxent.cart.CartItemIterface; import it.acxent.cc.Attivita; import it.acxent.common.DescTxtLang; import it.acxent.common.SimboliLavaggio; import it.acxent.common.StatusMsg; import it.acxent.contab.Documento; import it.acxent.contab.Movimento; import it.acxent.contab.MovimentoCR; import it.acxent.contab.RigaDocumento; import it.acxent.contab.RigaDocumentoCR; import it.acxent.db.AddImgInterface; import it.acxent.db.ApplParmFull; import it.acxent.db.DBAdapter; import it.acxent.db.ResParm; import it.acxent.db.WcString; import it.acxent.gtm.GoogleDataLayerBuilder; import it.acxent.icecat.Icecat; import it.acxent.mail.MailMessage; import it.acxent.mail.MailProperties; import it.acxent.tex.anag.ArticoloArticoloTessuto; import it.acxent.util.DoubleOperator; import it.acxent.util.FileWr; import it.acxent.util.PdfFontFactory; import it.acxent.util.ScaleImage; import it.acxent.util.SimpleDateFormat; import it.acxent.util.StringTokenizer; import it.acxent.util.Timer; import it.acxent.util.Vectumerator; import it.acxent.www.Sitemap; import it.acxent.www.SitemapCR; import java.awt.Color; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.FilenameFilter; import java.io.Serializable; import java.net.URI; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.sql.Date; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.Calendar; import java.util.Deque; import java.util.HashMap; import java.util.HashSet; import java.util.Hashtable; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.Locale; import java.util.Map; import java.util.Vector; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import jxl.NumberCell; import jxl.NumberFormulaCell; import jxl.Sheet; import jxl.Workbook; import jxl.format.CellFormat; import jxl.format.Colour; import jxl.write.Label; import jxl.write.Number; import jxl.write.WritableCell; import jxl.write.WritableCellFormat; import jxl.write.WritableFont; import jxl.write.WritableSheet; import jxl.write.WritableWorkbook; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import org.json.JSONArray; import org.json.JSONObject; public class Articolo extends _ArtAdapter implements Serializable, CartItemIterface, AddImgInterface, ArticoloInterface { private static final long serialVersionUID = -4264913259848621568L; public static final String SEO_TEMPLATE_PLACEHOLDER_TAG = "#"; public static final long SEO_MAX_META_DESCRIPTION_LENGTH = 150L; public static final long SEO_MAX_LINK_LENGTH = 80L; public static final long SEO_MAX_TAG_H2_LENGTH = 70L; public static final long SEO_MAX_TAG_H1_LENGTH = 70L; public static final long SEO_MAX_SEO_TITLE_LENGTH = 60L; public static final long SEO_MAX_SEO_TITLE_WORDS = 12L; private static final String CC_REWRITE_COMMAND_INFO = "info"; private static final String CC_REWRITE_COMMAND_DETAIL_SIZE_KIT_DTK = "dtk"; private static final String CC_REWRITE_COMMAND_DETAIL_SIZE_DT = "dt"; private static final String CC_REWRITE_COMMAND_DETAIL_KIT_SIZE_KIT_BOH_DKTK = "dktk"; private static final String CC_REWRITE_COMMAND_ADDITEMROW = "addItemRow"; private static final String CC_REWRITE_COMMAND_DETAIL_D = "d"; private static final String ARTICOLO_IN_OFFERTA = "articolo in offerta"; private static final String ARTICOLO_IN_OFFERTA_CAPITAL_A = "Articolo in offerta"; private static final String LINK_TROVAPREZZI_RICERCA = "https://www.trovaprezzi.it/categoria.aspx?id=-1&libera=#"; private static final String LINK_GOOGLE_RICERCA = "https://www.google.com/search?q=#"; private static final String LINK_AMAZON_RICERCA_EAN = "https://www.amazon.it/s?k=#"; private static final String LINK_AMAZON_RICERCA_ASIN = "https://www.amazon.it/dp/#"; private static final String LINK_EBAY_ITEM_IT = "https://www.ebay.it/itm/"; public static final int RPT_COMPATTO = 0; public static final int RPT_ARTICOLO_VARIANTI = 1; public static final int RPT_ARTICOLO_VARIANTI_SERIALI = 2; public static final int RPT_PDF_LISTINO_NEGOZIO = 10; public static final int RPT_PDF_USATO = 11; public static final long TIPO_SCHEDA_ARTICOLO_WWW_MANUALE = 0L; public static final long TIPO_SCHEDA_ARTICOLO_WWW_ICECAT = 1L; public static final long TIPO_SCHEDA_ARTICOLO_WWW_RUNNER = 2L; public static final long TIPO_SCHEDA_ARTICOLO_WWW_BESTIT = 3L; public static final String SERIALE_NULL = null; public static final long FLG_PRICE_TYPE_AMZ_PREZZO_SENZA_SPED = 0L; public static final long FLG_PRICE_TYPE_AMZ_PREZZO_CON_SPED_PERCENTILE = 1L; public static final long FLG_PRICE_TYPE_AMZ_PREZZO_CON_SPED_NO_PERCENTILE = 2L; public static final long FLG_AMAZON_SCARTATO = 2L; private static final long GOOGLE_NO_0 = 0L; private static final long GOOGLE_FREE_LISTING_1 = 1L; private static final long GOOGLE_FULL_LISTING_2 = 2L; private static final long GOOGLE_SEARCH_ALL_3 = 3L; private static final int LUNGHEZZA_CODICE_10 = 10; public static final String NAZIONE_ID_NAZIONE_ITALIA_I = "I"; private static final String SU_PREVENTIVO = "Su preventivo"; private static final String SPECIFICHE = "specifiche"; public static final String DESCRIZIONE_BREVE = "descrizioneBreve"; private static final double EBAY_TARIFFA_FISSA_0_35 = 0.5D; private static final double AMAZON_TARIFFA_FISSA_0_3 = 0.3D; private static final double PAYPAL_TARIFFA_FISSA_0_35 = 0.35D; private static final String NOME_MARKETPLACE = "nomeMarketplace"; private static final String NOME_L = "nomeL"; private static final String DESCRIZIONE_TECNICA = "descrizioneTecnica"; private static final String DESCRIZIONE_MARKETPLACE = "descrizioneMarketplace"; public static final String DESCRIZIONE_COMMERCIALE = "descrizioneCommerciale"; public static final String SEO_TITLE = "seoTitle"; public static final String META_DESCRIPTION = "metaDescription"; private static final String XML_TAB = " "; private static final String XML_TAB_x_2 = " "; public static final int STATO_A_RICHIESTA = 1; public static final int STATO_FINE_SERIE = 2; public static final int STATO_OK = 0; public static final long FLG_ESCLUDI_WEB_ART_VISIBILE = 0L; public static final long FLG_ESCLUDI_WEB_ART_NON_VISIBILE = 1L; public static final long FLG_ESCLUDI_WEB_ART_SOSPESO = 2L; public static final long FLG_ESCLUDI_WEB_ART_DA_TIPO = -1L; public static final long FLGMOD_IMP_ARTICOLO_TROVATO_NON_MODIFICATO = 3L; public static final long FLGMOD_IMP_ARTICOLO_MODIFICATO = 2L; public static final long FLGMOD_IMP_ARTICOLO_NON_TROVATO = 0L; public static final long FLGMOD_IMP_ARTICOLO_NUOVO = 1L; public static final long FLGMOD_IMP_ARTICOLO_TROVATO_NON_DISPONIBILE = 4L; public static final long FLGMOD_IMP_ARTICOLO_CONTROLLATO = 9L; public static final int STATO_IMPORT_VECCHIO = 0; public static final int STATO_IMPORT_NUOVO = 1; public static final int STATO_IMPORT_NUOVO_TROVATO_ULTIMO_IMPORT = 2; public static final long STOCK_OFFERTE_OFFERTE = 1L; public static final long STOCK_OFFERTE_STOCK = 2L; public static final long STOCK_OFFERTE_USATO = 3L; public static final long STOCK_OFFERTE_NOVITA = 4L; public static final long STOCK_OFFERTE_OFFERTE_ATTIVE = 99L; public static final int ARTICOLO_DISPONIBILE = 0; public static final int ARTICOLO_IN_ORDINE = 1; public static final int ARTICOLO_NON_DISPONIBILE = 2; public static final long FLG_USATO_NO = 0L; public static final long FLG_USATO_SI_DITTA = 2L; public static final long FLG_USATO_SI_PRIVATO = 1L; public static final long FLG_USATO_IGNORA = -1L; public static final long FLG_USATO_SI_TUTTI = 99L; public static final long NOLEGGIO_NO = 0L; public static final long NOLEGGIO_SOLO_NOLEGGIO = 1L; public static final long NOLEGGIO_VENDITA_E_NOLEGGIO = 2L; public static final long NOLEGGIO_SEARCH_VENDITA = 10L; public static final long NOLEGGIO_SEARCH_NOLEGGIO = 20L; public static final String TF_VISIBILE_WEB_NON_VISIBILE = "N"; public static final String TF_VISIBILE_WEB_SOSPESO = "P"; public static final String TF_VISIBILE_WEB_VISIBILE = "S"; class ThreadAllineaEbay extends Thread { private ApplParmFull apFull; private ArticoloCR CR; private final String TAG_THREAD_MSG = "ALLINEA EBAY "; public ThreadAllineaEbay(ApplParmFull apFull, ArticoloCR CR) { this.apFull = apFull; this.CR = CR; if (!Articolo.this.isLocalhost() && !Articolo.isThreadAllineaArticoloEbay()) { Articolo.threadAllineaArticoloEbay = true; start(); } } public void run() { boolean debug = false; Timer timer = new Timer(); timer.start(); StatusMsg.updateMsgByTag(Articolo.this.getApFull(), "ALLINEA EBAY ", "...inizio ..."); StringBuilder err = new StringBuilder(); ResParm rp = new ResParm(true); Articolo articolo = new Articolo(this.apFull); boolean isLocale = articolo.isLocalhost(); this.CR.setFlgEbayPubblicato(1L); Vectumerator vec = articolo.findByCR(this.CR, 0, 0); Vectumerator vecRes = new Vectumerator(); int i = 0, daAggiornare = 0, changed = 0; while (vec.hasMoreElements()) { Articolo row = (Articolo)vec.nextElement(); i++; StatusMsg.updateMsgByTag(Articolo.this.getApFull(), "ALLINEA EBAY ", "articolo " + i + " su " + vec.getTotNumberOfRecords() + ": " + changed + " aggiornati su " + daAggiornare); if (!row.isEbayPrezzoQtaAllineati()) { if (debug) System.out.println("AllineEbay: articolo codice " + row.getCodice() + " " + row.getNome()); daAggiornare++; StringBuilder beanNote = new StringBuilder(Articolo.this.getNf().format(row.getPrezzoSuEbayIva())); beanNote.append(" q."); beanNote.append(String.valueOf(row.getQtaSuEbay())); if (!isLocale) { rp = row.ebayPublishUpdate(); if (rp.getStatus()) { changed++; beanNote.append("\nupdated"); } else { rp = row.ebayDeleteInventoryItem(); if (rp.getStatus()) rp = row.ebayPublishFull(); if (rp.getStatus()) { changed++; beanNote.append("\nrepublish"); } else { beanNote.append("\nErr.: "); beanNote.append(rp.getMsg()); err.append(row.getCodice() + " " + row.getCodice() + ": " + row.getNome()); } } } row.setBeanNotes(beanNote.toString()); vecRes.add(row); } } timer.stop(); StatusMsg.updateMsgByTag(Articolo.this.getApFull(), "ALLINEA EBAY ", "Aggiornamento concluso. DURATA: " + timer.getDurataHourMin() + "\n" + err.toString()); System.out.println("###### THREAD ALLINEA EBAY CONCLUSO #####"); System.out.println("Aggiornamento concluso. DURATA: " + timer.getDurataHourMin()); System.out.println("Tot record: " + vec.getTotNumberOfRecords() + ": " + changed + " aggiornati su " + daAggiornare); System.out.println(err.toString()); System.out.println("############################################"); StringBuilder msg = new StringBuilder("DURATA: " + timer.getDurataHourMin()); msg.append("\n"); msg.append("Tot record: "); msg.append(vec.getTotNumberOfRecords()); msg.append(": "); msg.append(changed); msg.append(" aggiornati su "); msg.append(daAggiornare); StatusMsg.updateMsgByTag(Articolo.this.getApFull(), "ALLINEA EBAY ", "Aggiornamento concluso. Invio email risultato in corso..... "); Articolo.this.sendEbayUpdateResultByEmail(this.apFull, vecRes, msg.toString()); try { sleep(10000L); } catch (Exception e) {} StatusMsg.deleteMsgByTag(Articolo.this.getApFull(), "ALLINEA EBAY "); Articolo.threadAllineaArticoloEbay = false; System.out.println(rp.getMsg()); } } class ThreadCancellazioneMassiva extends Thread { private ApplParmFull apFull; private ArticoloCR CR; private final String TAG_THREAD_MSG = "CANCELLAZIONE ARTICOLI "; public ThreadCancellazioneMassiva(ApplParmFull apFull, ArticoloCR CR) { this.apFull = apFull; this.CR = CR; if (!Articolo.isThreadCancellazione()) { Articolo.threadCancellazione = true; start(); } } public void run() { boolean debug = false; Timer timer = new Timer(); timer.start(); StatusMsg.updateMsgByTag(Articolo.this.getApFull(), "CANCELLAZIONE ARTICOLI ", "...inizio ..."); StringBuilder err = new StringBuilder(); ResParm rp = new ResParm(true); Articolo articolo = new Articolo(this.apFull); boolean isLocale = articolo.isLocalhost(); Vectumerator vec = articolo.findByCR(this.CR, 0, 0); int i = 0, NONCancellati = 0, cancellati = 0, rimossiDaEbay = 0, visibiliNonCancellati = 0; while (vec.hasMoreElements()) { Articolo row = (Articolo)vec.nextElement(); rp.setStatus(true); i++; StatusMsg.updateMsgByTag(Articolo.this.getApFull(), "CANCELLAZIONE ARTICOLI ", "articolo " + i + " su " + vec.getTotNumberOfRecords() + "- Cancellati: " + cancellati + " - rimossi da ebay:" + rimossiDaEbay + " - Non cancellati: " + NONCancellati + " - Visibili NON Cancellati: " + visibiliNonCancellati); if (debug) System.out.println("Cancellazione massiva: articolo codice " + row.getCodice() + " " + row.getNome()); if (row.getFlgEscludiWeb() == 0L) { visibiliNonCancellati++; continue; } if (row.isEbayPubblicato()) { if (!isLocale) rp = row.ebayDeleteInventoryItem(); if (rp.getStatus()) rimossiDaEbay++; } if (rp.getStatus()) rp = row.delete(); if (rp.getStatus()) { cancellati++; continue; } NONCancellati++; } timer.stop(); StatusMsg.updateMsgByTag(Articolo.this.getApFull(), "CANCELLAZIONE ARTICOLI ", "Aggiornamento concluso. DURATA: " + timer.getDurataHourMin() + "\n" + err.toString()); System.out.println("###### THREAD CANCELLAZIONE MASSIVA CONCLUSO #####"); System.out.println("Aggiornamento concluso. DURATA: " + timer.getDurataHourMin()); System.out.println("Tot record: " + vec.getTotNumberOfRecords() + "- cancellati: " + cancellati + " NON cancellati: " + NONCancellati + " visibili NON Cancellati: " + visibiliNonCancellati); System.out.println(err.toString()); System.out.println("############################################"); StringBuilder msg = new StringBuilder("DURATA: " + timer.getDurataHourMin()); msg.append("\n"); msg.append("Tot record: "); msg.append(vec.getTotNumberOfRecords()); msg.append(" - cancellati: "); msg.append(cancellati); msg.append(" - rimossi da ebay: "); msg.append(rimossiDaEbay); msg.append(" - non cancellati: "); msg.append(NONCancellati); msg.append(" - Visibili non cancellati: "); msg.append(visibiliNonCancellati); StatusMsg.updateMsgByTag(Articolo.this.getApFull(), "CANCELLAZIONE ARTICOLI ", "Cancellazione conclusa. " + msg.toString()); try { sleep(10000L); } catch (Exception e) {} StatusMsg.deleteMsgByTag(Articolo.this.getApFull(), "CANCELLAZIONE ARTICOLI "); Articolo.threadCancellazione = false; System.out.println(rp.getMsg()); } } class ThreadIcecatAuto extends Thread { private ApplParmFull apFull; private ArticoloCR CR; private final String TAG_THREAD_MSG = "ICECAT AUTO "; public ThreadIcecatAuto(ApplParmFull apFull, ArticoloCR CR) { this.apFull = apFull; this.CR = CR; if (!Articolo.isThreadIcecatAuto()) { Articolo.threadIcecatAuto = true; start(); } } public void run() { boolean debug = false; Timer timer = new Timer(); timer.start(); StatusMsg.updateMsgByTag(Articolo.this.getApFull(), "ICECAT AUTO ", "...inizio ..."); StringBuilder err = new StringBuilder(); StringBuilder sb = new StringBuilder(); ResParm rp = new ResParm(true); Articolo articolo = new Articolo(this.apFull); sb.append(""); } return sb.toString(); } public static final String getMovimentoHtmlDesc(TipologiaArticolo tipologiaArticolo, double q, double nr, double kg, double mt, double quantitaInArrivo, double quantitaImpegnata, double quantitaEffettiva, boolean usaMagazzino, boolean usaMagazzinoSuArticoli, NumberFormat nf) { StringBuilder sb = new StringBuilder(); if (!usaMagazzino) { sb.append("No magazzino"); } else if (!usaMagazzinoSuArticoli) { sb.append(" "); if (tipologiaArticolo.getFlgNr() == 1L && tipologiaArticolo.getFlgUdm() == 1L && nr < 0.0D) { sb.append("n "); sb.append(nf.format(nr)); } if (tipologiaArticolo.getFlgMt() == 1L) { if (sb.length() > 0) sb.append(" "); sb.append("mt "); sb.append(nf.format(mt)); } if (tipologiaArticolo.getFlgKg() == 1L) { if (sb.length() > 0) sb.append(" "); sb.append("kg "); sb.append(nf.format(kg)); } sb.append(""); sb.append(" + "); sb.append(" "); sb.append(nf.format(quantitaInArrivo)); sb.append(""); sb.append(" - "); sb.append(" "); sb.append(nf.format(quantitaImpegnata)); sb.append(""); sb.append(" = "); sb.append(tipologiaArticolo.getUdm()); sb.append(" "); sb.append(nf.format(quantitaEffettiva)); sb.append(""); } else { DoubleOperator dp = new DoubleOperator(q); dp.subtract(quantitaImpegnata); sb.append(tipologiaArticolo.getUdm()); sb.append(" "); if (q < 0.0D) { sb.append(" "); sb.append(nf.format(q)); sb.append(""); } else { sb.append(nf.format(q)); } sb.append(" - "); sb.append(" "); sb.append(nf.format(quantitaImpegnata)); sb.append(""); sb.append(" = "); sb.append(" "); sb.append(nf.format(dp.getResult())); sb.append(""); } return sb.toString(); } public String getCodiciMagazzino() { return (this.codiciMagazzino == null) ? "" : this.codiciMagazzino.trim(); } public void setCodiciMagazzino(String codiciMagazzino) { this.codiciMagazzino = codiciMagazzino; } public boolean isTessutoPrincipale(long l_id_articoloTessuto, long l_id_articoloTessutoColore) { ArticoloArticoloTessuto aat = new ArticoloArticoloTessuto(getApFull()); aat.findByArticoloVarianteArticoloTessutoColore(getId_articoloVariante(), l_id_articoloTessuto, l_id_articoloTessutoColore); if (aat.getFlgPrincipale() == 1L) return true; return false; } public Vectumerator findWebByArticoloVarianteCR(ArticoloCR CR, int pageNumber, int pageRows) { String occurrenceFind, orderBy, s_Sql_Order; if (getParm("B2B").isTrue() && CR.getId_clifor() == 0L) return AB_EMPTY_VECTUMERATOR; String occurrence = findWebByArticoloCRCreateSmartSearchOccurrence(CR.getSearchTxtWeb().toLowerCase(), "B.descrizioneSearchAv"); if (!occurrence.isEmpty()) { occurrenceFind = occurrence + ", "; } else { occurrenceFind = ""; } StringBuffer s_Sql_Find = new StringBuffer("select " + occurrenceFind + " A.* from ARTICOLO AS A left join ARTICOLO_VARIANTE AS B ON A.id_articolo=B.id_articolo left JOIN TIPO AS C2 ON A.id_tipo2=C2.id_tipo inner join TIPO AS C on C.id_tipo=A.id_tipo"); if (occurrence.isEmpty()) { orderBy = " order by "; } else { orderBy = " order by occorrenze desc,"; } if (CR.getFlgOrderBy() == 6L) { s_Sql_Order = orderBy + "B.createTmst desc, A.ordine desc, C.ordine, A.id_articolo"; } else { s_Sql_Order = orderBy + " A.ordine desc, C.ordine, A.id_articolo"; } WcString wc = new WcString(); findWebByArticoloVarianteCRCreateWC(CR, s_Sql_Find, wc); try { PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find) + wc.toString()); return findRows(stmt, pageNumber, pageRows); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public String getDescrizioneCaratteristiche() { if (getId_articolo() == 0L) return ""; if (this.descrizioneCaratteristiche == null) { StringBuilder sb = new StringBuilder(); Vectumerator vec = getCaratteristicheArticolo(); while (vec.hasMoreElements()) { CaratteristicaArticolo row = (CaratteristicaArticolo)vec.nextElement(); sb.append(row.getCaratteristica().getDescrizione()); sb.append(" - "); sb.append(row.getVal()); if (vec.hasMoreElements()) sb.append("\n"); } this.descrizioneCaratteristiche = sb.toString(); } return (this.descrizioneCaratteristiche == null) ? "" : this.descrizioneCaratteristiche.trim(); } public void setDescrizioneCaratteristiche(String descrizioneCaratteristiche) { this.descrizioneCaratteristiche = descrizioneCaratteristiche; } public String getNotaArticolo() { return (this.notaArticolo == null) ? "" : this.notaArticolo.trim(); } public String getNoteTessutiBase(String lang) { if (getId_articolo() == 0L) return ""; StringBuilder sb = new StringBuilder(); Vectumerator vec = findArticoliTessuto(); while (vec.hasMoreElements()) { ArticoloArticoloTessuto row = (ArticoloArticoloTessuto)vec.nextElement(); if (!row.getArticoloTessuto().getNotaTessuto().isEmpty()) { sb.append(row.getArticoloTessuto().getDescrizioneCompleta(lang)); sb.append(": "); sb.append(row.getArticoloTessuto().getNotaTessuto()); if (vec.hasMoreElements()) sb.append("\n"); } } return sb.toString(); } public String getNoteTessutiBaseHtml(String lang) { return DBAdapter.convertStringToHtml(getNoteTessutiBase(lang), true); } public void setNotaArticolo(String notaArticolo) { this.notaArticolo = notaArticolo; } public long getMmConsumoByArticoloTessuto(long l_id_articoloTessuto) { if (getId_articolo() == 0L) return 0L; ArticoloArticoloTessuto aat = new ArticoloArticoloTessuto(getApFull()); aat.findByArticoloArticoloTessutoBase(getId_articolo(), l_id_articoloTessuto); return aat.getMmATT(); } public String getCodiceEan() { return (this.codiceEan == null) ? "" : this.codiceEan.trim(); } public String getCodiceEanNoZero() { return StringUtils.stripStart(getCodiceEan(), "0"); } public Date getDataUltimoCosto() { return this.dataUltimoCosto; } public String getDescrizioneGoogle() { return (this.descrizioneGoogle == null) ? "" : this.descrizioneGoogle.trim(); } public long getFlgEbay() { return this.flgEbay; } public long getFlgGoogle() { return this.flgGoogle; } public long getFlgNoleggio() { return this.flgNoleggio; } public long getFlgUsato() { return this.flgUsato; } public String getNMatricola() { return (this.nMatricola == null) ? "" : this.nMatricola; } public double getPercRicarico() { if (this.percRicarico == 0.0D) return getParm("PERC_RICARICO_DEFAULT").getNumero(); return this.percRicarico; } public double getPrezzoIvatoBarrato() { return this.prezzoIvatoBarrato; } public double getPrezzoIvatoBarrato(Users user) { if (user.getId_clifor() == 0L) return this.prezzoIvatoBarrato; if (user.getClifor().isPrezzoWebEsente()) return scorporaIva(this.prezzoIvatoBarrato, (double)getIva().getAliquota()); return this.prezzoIvatoBarrato; } public double getPercScontoRispettoAlPrezzoBarrato() { if (getPrezzoIvatoBarrato() == 0.0D) return 0.0D; DoubleOperator dop = new DoubleOperator(getPriceWVat()); dop.setScale(2, 5); dop.divide(getPrezzoIvatoBarrato()); dop.multiply(100); dop.subtract(100); return dop.getResult(); } public double getPrezzoNettoBarrato() { return this.prezzoNettoBarrato; } public boolean isArticoloNoleggio() { if (getFlgNoleggio() == 1L || getFlgNoleggio() == 2L) return true; return false; } public boolean isEbayGiacenza0() { if (getId_articolo() == 0L) return false; if (getFlgEbay() > 0L && getQuantita() <= 0.0D) return true; return false; } public boolean isSuperGaranzia() { if (getFlgSuperGaranzia() == 0L) return false; if (getFlgNoleggio() > 0L) return false; if (getFlgStockOfferte() == 3L || getFlgStockOfferte() == 2L) return false; return true; } public void setCodiceEan(String codiceEan) { this.codiceEan = codiceEan; } public void setDataUltimoCosto(Date dataUltimoCosto) { this.dataUltimoCosto = dataUltimoCosto; } public void setDescrizioneGoogle(String descrizioneGoogle) { this.descrizioneGoogle = descrizioneGoogle; } public void setFlgEbay(long flgEbay) { this.flgEbay = flgEbay; } public void setFlgGoogle(long flgGoogle) { this.flgGoogle = flgGoogle; } public void setFlgNoleggio(long flgNoleggio) { this.flgNoleggio = flgNoleggio; } public void setFlgUsato(long flgUsato) { this.flgUsato = flgUsato; } public void setNMatricola(String matricola) { this.nMatricola = matricola; } public void setPercRicarico(double percRicarico) { this.percRicarico = percRicarico; } public void setPrezzoIvatoBarrato(double prezzoIvatoBarrato) { this.prezzoIvatoBarrato = prezzoIvatoBarrato; } public void setPrezzoNettoBarrato(double prezzoNettoBarrato) { this.prezzoNettoBarrato = prezzoNettoBarrato; } public void setPrezzoNoleggio(double prezzoNoleggio) { this.prezzoNoleggio = prezzoNoleggio; } public double getPrezzoNoleggio() { return this.prezzoNoleggio; } public long getFlgSuperGaranzia() { return this.flgSuperGaranzia; } public void setFlgSuperGaranzia(long flgSuperGaranzia) { this.flgSuperGaranzia = flgSuperGaranzia; } public double getCostoNuovo() { return this.costoNuovo; } public void setCostoNuovo(double costoNuovo) { this.costoNuovo = costoNuovo; } public long getFlgStatoImport() { return this.flgStatoImport; } public void setFlgStatoImport(long flgStatoImport) { this.flgStatoImport = flgStatoImport; } public double getPrezzoNoleggioIva() { long l_id_ivaV = getCodiceIvaVendStd(); Iva iva = new Iva(getApFull()); iva.findByPrimaryKey(l_id_ivaV); DoubleOperator temp = new DoubleOperator((float)iva.getAliquota()); temp.setScale(2, 5); temp.divide(100.0F); temp.add(1); DoubleOperator temp2 = new DoubleOperator(getPrezzoNoleggio()); temp2.setScale(2, 5); temp2.multiply(temp); return temp2.getResult(); } public double getCostoTessutoCalc() { if (getId_articolo() == 0L) return 0.0D; Vectumerator vec = findArticoliTessuto(); DoubleOperator tot = new DoubleOperator(); tot.setScale(4, 5); while (vec.hasMoreElements()) { ArticoloArticoloTessuto row = (ArticoloArticoloTessuto)vec.nextElement(); DoubleOperator temp = new DoubleOperator(row.getArticoloTessuto().getUltimoPrezzoAcquisto()); temp.setScale(4, 5); temp.multiply(row.getMmATT()); temp.divide(1000.0F); tot.add(temp); } return tot.getResult(); } public double getCostoNettoDb() { return this.costoNettoDb; } public void setCostoNetto(double newCostoNetto) { this.costoNetto = newCostoNetto; } public void setCostoNettoDb(double costoNettoDb) { this.costoNettoDb = costoNettoDb; } public static final String getStockOfferte(long l_flgStockOfferte) { if (l_flgStockOfferte == 2L) return "Stock"; if (l_flgStockOfferte == 1L) return "Offerta"; if (l_flgStockOfferte == 3L) return "Usato"; if (l_flgStockOfferte == 4L) return "Novita'"; if (l_flgStockOfferte == 99L) return "Offerte Attive"; if (l_flgStockOfferte == 0L) return ""; return "??"; } public double getCostoManodopera() { return this.costoManodopera; } public void setCostoManodopera(double costoManodopera) { this.costoManodopera = costoManodopera; } public double getCostoStiro() { if (this.costoStiro == 0.0D) return getParm("COSTO_STIRO_DEFAULT").getNumero(); return this.costoStiro; } public void setCostoStiro(double costoStiro) { this.costoStiro = costoStiro; } public double getCostoSpeseFisse() { if (this.costoSpeseFisse == 0.0D) return getParm("COSTO_SPESE_FISSE_DEFAULT").getNumero(); return this.costoSpeseFisse; } public void setCostoSpeseFisse(double costoSpeseFisse) { this.costoSpeseFisse = costoSpeseFisse; } public double getCostoAccessori() { return this.costoAccessori; } public void setCostoAccessori(double costoAccessori) { this.costoAccessori = costoAccessori; } public double getCostoNetto() { return this.costoNetto; } public void setTotCostoConfezione(double totCostoConfezione) { this.totCostoConfezione = totCostoConfezione; } public double getTotCostoConfezione() { if (this.totCostoConfezione == -1.0D) { DoubleOperator dop = new DoubleOperator(); dop.setScale(4, 5); dop.add(getCostoAccessori()); dop.add(getCostoStiro()); dop.add(getCostoSpeseFisse()); dop.add(getCostoManodopera()); dop.add(getCostoTessutoCalc()); this.totCostoConfezione = dop.getResult(); } return this.totCostoConfezione; } public String getKit() { return getKit(getFlgKit()); } public long getFlgKit() { return this.flgKit; } public void setFlgKit(long flgKit) { this.flgKit = flgKit; } public static final String getKit(long l_flgKit) { return Tipo.getKit(l_flgKit); } public long getFlgKitArt() { return this.flgKitArt; } public void setFlgKitArt(long flgKitArt) { this.flgKitArt = flgKitArt; } public String getKitArt() { return getKit(getFlgKit()); } public boolean isInVendita() { if (getFlgWebNoVendita() == 0L) return true; return false; } public boolean isArticoloAcquistabile() { if (getFlgWebNoVendita() != 0L) return false; if (getFlgEscludiWeb() != 0L) return false; if (!getTipo().isArticoloAcquistabile()) return false; if ((getDispoLevel() > 0 || !isCheckAvail()) && getPrezzoPubblico() > 0.0D) return true; return false; } public double getPrezzoPubblicoArticoloVarianteMaxByCR(ArticoloCR CR) { StringBuffer s_Sql_Find = new StringBuffer("select max(prezzoPubblico) as _max from ARTICOLO AS A left join ARTICOLO_VARIANTE AS B ON A.id_articolo=B.id_articolo inner JOIN TIPO AS C2 ON A.id_tipo2=C2.id_tipo inner join TIPO AS C on C.id_tipo=A.id_tipo "); if (!CR.getSearchTxtWeb().isEmpty() && !CR.getSearchTxtWeb().equals("*")) s_Sql_Find = new StringBuffer("select max(prezzoPubblico) as _max from ARTICOLO as A left join ARTICOLO_VARIANTE AS B ON A.id_articolo=B.id_articolo inner join DESC_TXT_LANG AS X ON A.id_articolo=X.idTabella LEFT JOIN TIPO AS C2 ON A.id_tipo2=C2.id_tipo inner join TIPO AS C on C.id_tipo=A.id_tipo"); try { WcString wc = new WcString(); ArticoloCR CR2 = CR.getClone(); CR2.setPrezzoA(0.0D); CR2.setPrezzoDa(0.0D); CR2.setFlgNoleggio(10L); findWebByArticoloVarianteCRCreateWC(CR2, s_Sql_Find, wc); PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find)); return getMax(stmt); } catch (SQLException|CloneNotSupportedException e) { handleDebug(e); return 0.0D; } } public double getPrezzoPubblicoIvaArticoloVarianteMaxByCR(ArticoloCR CR) { return conIva(getPrezzoPubblicoArticoloVarianteMaxByCR(CR), (double)getId_iva()); } public double getPrezzoPubblicoIvaArticoloVarianteMinByCR(ArticoloCR CR) { return conIva(getPrezzoPubblicoArticoloVarianteMinByCR(CR), (double)getId_iva()); } public double getPrezzoPubblicoArticoloMaxByCR(ArticoloCR CR) { String occurrenceFind; StringBuilder sb = new StringBuilder(); boolean debug = false; Timer timer = new Timer(); if (debug) { timer.start(); sb.append(">>>>>>>>>>>>>>>>>>>>>>\nPREZZO MAX findWebByArticoloCR: "); java.util.Date d = new java.util.Date(System.currentTimeMillis()); sb.append(getApFull().getReqUrl()); sb.append("\n"); sb.append(d.toString()); sb.append(" ip: "); sb.append(getApFull().getReqIpAddress()); } String occurrence = findWebByArticoloCRCreateSmartSearchOccurrence(CR.getSearchTxtWeb().toLowerCase(), "A.descrizioneSearch"); if (!occurrence.isEmpty()) { occurrenceFind = occurrence + ", "; } else { occurrenceFind = ""; } StringBuffer s_Sql_Find = new StringBuffer("select " + occurrenceFind + " max(prezzoPubblicoIvaOrd) as _max from ARTICOLO AS A inner join TIPO AS C on C.id_tipo=A.id_tipo "); try { WcString wc = new WcString(); ArticoloCR CR2 = CR.getClone(); CR2.setPrezzoA(0.0D); CR2.setPrezzoDa(0.0D); CR2.setFlgNoleggio(10L); findWebByArticoloCRCreateWC(CR2, s_Sql_Find, wc); if (debug) { sb.append("\n"); sb.append(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find)); } PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find)); double res = getMax(stmt); if (debug) { timer.stop(); sb.append("\nDurata query: ms "); sb.append(timer.getDurataMilliSec()); sb.append("\n"); sb.append("\n<<<<<<<<<<<<"); System.out.println(sb.toString()); } return res; } catch (SQLException|CloneNotSupportedException e) { handleDebug(e); return 0.0D; } } public double getPrezzoPubblicoArticoloVarianteMinByCR(ArticoloCR CR) { StringBuffer s_Sql_Find = new StringBuffer("select min(prezzoPubblico) as _max from ARTICOLO AS A left join ARTICOLO_VARIANTE AS B ON A.id_articolo=B.id_articolo inner JOIN TIPO AS C2 ON A.id_tipo2=C2.id_tipo inner join TIPO AS C on C.id_tipo=A.id_tipo "); if (!CR.getSearchTxtWeb().isEmpty() && !CR.getSearchTxtWeb().equals("*")) s_Sql_Find = new StringBuffer("select min(prezzoPubblico) as _max from ARTICOLO as A left join ARTICOLO_VARIANTE AS B ON A.id_articolo=B.id_articolo inner join DESC_TXT_LANG AS X ON A.id_articolo=X.idTabella LEFT JOIN TIPO AS C2 ON A.id_tipo2=C2.id_tipo inner join TIPO AS C on C.id_tipo=A.id_tipo"); try { WcString wc = new WcString(); ArticoloCR CR2 = CR.getClone(); CR2.setPrezzoA(0.0D); CR2.setPrezzoDa(0.0D); CR2.setFlgNoleggio(10L); findWebByArticoloVarianteCRCreateWC(CR2, s_Sql_Find, wc); PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find)); return getMax(stmt); } catch (SQLException|CloneNotSupportedException e) { handleDebug(e); return 0.0D; } } public double getPrezzoPubblicoIvaArticoloMaxByCR(ArticoloCR CR) { return conIva(getPrezzoPubblicoArticoloMaxByCR(CR), (double)getId_iva()); } public double getPrezzoPubblicoIvaArticoloMinByCR(ArticoloCR CR) { return conIva(getPrezzoPubblicoArticoloMinByCR(CR), (double)getId_iva()); } protected void findWebByArticoloVarianteCRCreateWC(ArticoloCR CR, StringBuffer s_Sql_Find, WcString wc) { boolean smartSearch = false; if (!CR.getSearchTxtWeb().isEmpty() && !CR.getSearchTxtWeb().equals("*")) if (!CR.getSearchTxtWeb().startsWith("#")) { String temp = findByCRCreateSmartSearchWC(CR.getSearchTxtWeb().toLowerCase(), "B.descrizioneSearchAv"); if (!temp.isEmpty()) wc.addWc(temp); smartSearch = true; } if (CR.getFlgEscludiWeb() == 0L) wc.addWc("(A.flgEscludiWeb=0)"); if (CR.getFlgNascondi() == 0L) { wc.addWc("(A.flgNascondi=0 or A.flgNascondi is null)"); wc.addWc("(B.flgNascondi=0 or B.flgNascondi is null)"); wc.addWc("(C.flgNascondi=0 or C.flgNascondi is null)"); } else if (CR.getFlgNascondi() > 0L) { wc.addWc("A.flgNascondi=" + CR.getFlgNascondi()); wc.addWc("B.flgNascondi=" + CR.getFlgNascondi()); wc.addWc("C.flgNascondi=" + CR.getFlgNascondi()); } if (!CR.getFlgDisponibilita().isEmpty()) { StringTokenizer st = new StringTokenizer(CR.getFlgDisponibilita(), ","); StringBuilder cli = new StringBuilder("("); while (st.hasMoreTokens()) { long token = Long.parseLong(st.nextToken()); if (token == 1L) { wc.addWc("A.flgNoleggio>0"); continue; } if (token == 1L) wc.addWc("A.quantita>0"); } } if (CR.getFlgNoleggio() == 10L) wc.addWc("A.flgNoleggio!=1"); if (!CR.getCarId_listaS().isEmpty()) { boolean needOr = false; StringTokenizer st = new StringTokenizer(CR.getCarId_listaS(), ","); StringBuilder cli = new StringBuilder("("); while (st.hasMoreTokens()) { String token = st.nextToken(); if (!token.isEmpty() && !token.equals("0")) { if (token.startsWith("c")) { if (st.hasMoreTokens()) { cli.append(") and ( "); needOr = false; } continue; } if (needOr) cli.append(" or "); cli.append("A.caratteristicheListeId like '%," + token + ",%'"); needOr = true; } } cli.append(")"); if (cli.length() > 2) wc.addWc(cli.toString()); } if (!smartSearch) { if (CR.getId_tipoSel() != 0L) wc.addWc("(A.id_tipo=" + CR.getId_tipoSel() + " or C.indici like'%:" + CR.getId_tipoSel() + ":%'or A.id_tipo2=" + CR.getId_tipoSel() + " or C2.indici like'%:" + CR.getId_tipoSel() + ":%')"); if (CR.getPrezzoDa() > 0.0D) wc.addWc("A.prezzoPubblicoIva>=" + CR.getPrezzoDa()); if (CR.getPrezzoA() > 0.0D) wc.addWc("A.prezzoPubblicoIva<=" + CR.getPrezzoA()); } if (getParm("B2B").isTrue() && CR.getId_clifor() > 0L) s_Sql_Find.append(" inner join ARTICOLO_CLIENTE AS AC ON (B.id_articolo=AC.id_articolo or B.id_articoloVariante=AC.id_articoloVariante or A.id_tipo=AC.id_tipo)"); String occurrence = findWebByArticoloCRCreateSmartSearchOccurrence(CR.getSearchTxtWeb().toLowerCase(), "B.descrizioneSearchAv"); if (!occurrence.isEmpty()) if (getParm("USE_SEARCH_LAST_2_OCCURRENCE").isTrue()) { wc.addHavingWc(" occorrenze >= (select max" + occurrence.replace(")) as occorrenze", ")-1) as occorrenze") + " from ARTICOLO_VARIANTE AS B )"); } else { wc.addHavingWc(" occorrenze = (select max" + occurrence + " from ARTICOLO_VARIANTE AS B )"); } } public static final String getKitArt(long l_flgKit) { return Tipo.getKit(l_flgKit); } public long getFlgRateale0() { return this.flgRateale0; } public void setFlgRateale0(long flgRateale0) { this.flgRateale0 = flgRateale0; } public boolean isArticoloConfezioneOk() { if (getId_articolo() == 0L) return true; if (getTipo().getTipologiaArticolo().getFlgAFT() != 3L) return true; Vectumerator vecAAT = findArticoliTessuto(); if (vecAAT.getTotNumberOfRecords() == 0) return false; return true; } public boolean isArticoloInWishList(long l_id_users) { if (l_id_users == 0L || getId_articolo() == 0L) return false; Wishlist item = new Wishlist(getApFull()); item.setId_articolo(getId_articolo()); Wishlist wl = new Wishlist(getApFull()); wl.findByUserItem(l_id_users, item); if (wl.getId_wishlist() > 0L) return true; return false; } public boolean isReadyForWeb(String lang) { boolean debug = false; if (getId_articolo() == 0L) return false; if (getPrezzoPubblico() <= 0.0D) { DBAdapter.printDebug(debug, "Articolo.isReadyForWeb false per prezzoPubblico <=0"); return false; } if (getDescTxtLang("descrizioneBreve", lang).isEmpty() && getNome(lang).isEmpty()) { DBAdapter.printDebug(debug, "Articolo.isReadyForWeb false per descrizioneBreve vuota"); return false; } if (getDescrizioneCommerciale(lang).isEmpty()) { DBAdapter.printDebug(debug, "Articolo.isReadyForWeb false per descrizioneCommerciale vuota"); return false; } if (!isImgExist(1)) { DBAdapter.printDebug(debug, "Articolo.isReadyForWeb false per nessuna foto"); return false; } return true; } public long getMaxLenNomeMarketplace() { long maxlen = 80L; if (getFlgSubito() == 1L || getFlgEbay() == 1L) if (getFlgSubito() == 1L) maxlen = 50L; return maxlen; } public long getMaxLenDescMarketplace() { long maxlen = 3990L; if (getFlgSubito() == 1L || getFlgEbay() == 1L) if (getFlgSubito() == 1L) maxlen = 1990L; return maxlen; } public boolean isEbayLinkOk() { if (isEbayPubblicato() && !getEbayItemId().isEmpty()) return true; return false; } public boolean isCheckAvail() { return getParm("CC_CHECK_AVAIL").isTrue(); } public long getPrezzoVenditaComeStreetPrice() { if (getStreetPrice() == 0.0D) return -2L; if (getPrezzoBase() < getStreetPrice()) return -1L; if (getPrezzoBase() > getStreetPrice()) return 1L; return 0L; } public static final String getUsato(long l_flgUsato) { if (l_flgUsato == 0L) return "No"; if (l_flgUsato == 2L) return "Si Ditta"; if (l_flgUsato == 1L) return "Si Privato"; if (l_flgUsato == 99L) return "Si Tutti"; if (l_flgUsato == -1L) return "-"; return "??"; } public String getUsato() { return getUsato(getFlgUsato()); } public String getDescrizioneSearch() { return (this.descrizioneSearch == null) ? "" : this.descrizioneSearch.trim(); } public void setDescrizioneSearch(String descrizioneSearch) { this.descrizioneSearch = descrizioneSearch; } public ResParm addProgettista(ArticoloProgettista row) { ResParm rp = new ResParm(true); ArticoloProgettista bean = new ArticoloProgettista(getApFull()); bean.findByProgettistaArticolo(row.getId_progettista(), row.getId_articolo()); if (bean.getDBState() == 1) { bean.setPercProvvigione(row.getPercProvvigione()); bean.setNota(row.getNota()); rp = bean.save(); } else { row.setDBState(0); rp = row.save(); } return rp; } public String getScaffale() { return (this.scaffale == null) ? "" : this.scaffale.trim(); } public void setScaffale(String scaffale) { this.scaffale = scaffale; } public long getFlgContoVendita() { return this.flgContoVendita; } public void setFlgContoVendita(long flgContoVendita) { this.flgContoVendita = flgContoVendita; } public ByteArrayOutputStream creaTulps(boolean definitivo) { ByteArrayOutputStream ba = new ByteArrayOutputStream(); SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy"); int cellLeading = 10; NumberFormat nf = getNf(); try { this.document = new Document(PageSize.A5.rotate(), 10.0F, 10.0F, 70.0F, 10.0F); this.writer = PdfWriter.getInstance(this.document, ba); this.document.open(); Table pdfcorpo = new Table(40); pdfcorpo.setWidth(100.0F); pdfcorpo.setBorder(0); pdfcorpo.setBorderWidth(0.0F); pdfcorpo.setBorderColor(new Color(255, 255, 255)); pdfcorpo.setPadding(2.0F); pdfcorpo.setSpacing(0.0F); pdfcorpo.setWidths(colWidthsRighe40); Vectumerator vec = findArticolixStampTulps(); while (vec.hasMoreElements()) { Articolo row = (Articolo)vec.nextElement(); System.out.println(row.getDescrizione()); creaUnTulps(row, pdfcorpo, definitivo); this.document.add((Element)pdfcorpo); if (vec.hasMoreElements()) { this.document.newPage(); pdfcorpo = new Table(40); pdfcorpo.setWidth(100.0F); pdfcorpo.setBorder(0); pdfcorpo.setBorderWidth(0.0F); pdfcorpo.setBorderColor(new Color(255, 255, 255)); pdfcorpo.setPadding(2.0F); pdfcorpo.setSpacing(0.0F); pdfcorpo.setWidths(colWidthsRighe40); } } this.document.close(); this.document = null; } catch (Exception e) { e.printStackTrace(); } return ba; } public ByteArrayOutputStream creaTulpsArticolo(boolean definitivo) { ByteArrayOutputStream ba = new ByteArrayOutputStream(); if (getFlgUsato() > 0L) { SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy"); int cellLeading = 10; NumberFormat nf = getNf(); try { this.document = new Document(PageSize.A5.rotate(), 10.0F, 10.0F, 70.0F, 10.0F); this.writer = PdfWriter.getInstance(this.document, ba); this.document.open(); Table pdfcorpo = new Table(40); pdfcorpo.setWidth(100.0F); pdfcorpo.setBorder(0); pdfcorpo.setBorderWidth(0.0F); pdfcorpo.setBorderColor(new Color(255, 255, 255)); pdfcorpo.setPadding(2.0F); pdfcorpo.setSpacing(0.0F); pdfcorpo.setWidths(colWidthsRighe40); creaUnTulps(this, pdfcorpo, definitivo); this.document.add((Element)pdfcorpo); this.document.close(); this.document = null; } catch (Exception e) { e.printStackTrace(); } } return ba; } private void creaUnTulps(Articolo row, Table pdfcorpo, boolean definitivo) { ByteArrayOutputStream ba = new ByteArrayOutputStream(); SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy"); int cellLeading = 10; NumberFormat nf = getNf(); try { Cell cellVuota = new Cell(new Chunk(" ", PDF_fPiccolo)); cellVuota.setVerticalAlignment(4); cellVuota.setHorizontalAlignment(1); cellVuota.setLeading((float)cellLeading); cellVuota.setBorder(0); cellVuota.setColspan(40); pdfcorpo.addCell(cellVuota); Font PDF_fIntestazione = new Font(2, 10.0F, 1); String temp = row.getCodice() + " - " + row.getCodice() + " " + row.getMarca().getDescrizione(); if (!row.getNMatricola().isEmpty()) temp = temp + " Mat. N. " + temp; Cell cell = new Cell(new Chunk("ARTICOLO: " + temp, PDF_fIntestazione)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(1); cell.setLeading((float)cellLeading); cell.setColspan(40); pdfcorpo.addCell(cell); Date dataUltimoMovimento = new ArticoloUsato(getApFull()).getDataUltimoMovimento(row.getId_articolo()); dataUltimoMovimento = getToday(); if (dataUltimoMovimento != null) { cell = new Cell(new Chunk("Data Stampa: " + getDataFormat().format(dataUltimoMovimento), PDF_fPiccoloB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(40); pdfcorpo.addCell(cell); } pdfcorpo.addCell(cellVuota); int col1 = 4, col2 = 20, col3 = 4, col4 = 4, col5 = 4, col6 = 4; cell = new Cell(new Chunk("Movimento", PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col1); pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Venditore/Compratore", PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col2); pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Documento", PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col3); pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Data", PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col4); pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Importo/\nImponibile", PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col5); pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Iva", PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col6); pdfcorpo.addCell(cell); ArticoloUsato au = new ArticoloUsato(getApFull()); Vectumerator vec = au.findByArticolo(row.getId_articolo(), 0, 0); while (vec.hasMoreElements()) { au = (ArticoloUsato)vec.nextElement(); if (au.getFlgTipoDocumento() == 1L) { cell = new Cell(new Chunk("ACQUISTO", PDF_fPiccoloB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col1); pdfcorpo.addCell(cell); temp = au.getIntestazione() + " Cod. Fisc. " + au.getIntestazione(); try { if (au.getFornitore().getPIva().isEmpty()) { temp = temp + " Nato il " + temp + " a " + getDataFormat().format(au.getFornitore().getDataNascita()) + " (" + au.getFornitore().getDescrizioneComuneNascita() + "). Doc. Id.: " + au.getFornitore().getProvinciaComuneNascita(); } else { temp = temp + " - Partita Iva: " + temp; } temp = temp + " - " + temp; } catch (Exception e) {} cell = new Cell(new Chunk(temp, PDF_fPiccolo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col2); pdfcorpo.addCell(cell); cell = new Cell(new Chunk(au.getNumeroDocumento(), PDF_fPiccolo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col3); pdfcorpo.addCell(cell); cell = new Cell(new Chunk(df.format(au.getDataDocumento()), PDF_fPiccolo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col4); pdfcorpo.addCell(cell); cell = new Cell(new Chunk(nf.format(au.getArticolo().getCostoNetto()), PDF_fPiccolo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col5); pdfcorpo.addCell(cell); if (au.getArticolo().getIva().getFlgTipo() == "R") { temp = "RM"; } else { temp = nf.format(au.getArticolo().getCostoNettoIva()); } cell = new Cell(new Chunk(temp, PDF_fPiccolo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col6); pdfcorpo.addCell(cell); } else { if (au.getFlgTipoDocumento() == 2L) { cell = new Cell(new Chunk("VENDITA", PDF_fPiccoloB)); } else if (au.getFlgTipoDocumento() == 3L) { cell = new Cell(new Chunk("RESO", PDF_fPiccoloB)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col1); pdfcorpo.addCell(cell); temp = au.getIntestazione() + " Cod. Fisc. " + au.getIntestazione(); if (au.getCliente().getFlgAzienda() == 1L) temp = temp + " " + temp; cell = new Cell(new Chunk(temp, PDF_fPiccolo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col2); pdfcorpo.addCell(cell); cell = new Cell(new Chunk(au.getRigaDocumento().getDocumento().getNumeroDocumento(), PDF_fPiccolo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col3); pdfcorpo.addCell(cell); cell = new Cell(new Chunk(df.format(au.getRigaDocumento().getDocumento().getDataDocumento()), PDF_fPiccolo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col4); pdfcorpo.addCell(cell); cell = new Cell(new Chunk(nf.format(au.getImporto()), PDF_fPiccolo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col5); pdfcorpo.addCell(cell); if (au.getArticolo().getIva().getFlgTipo() == "R") { temp = "RM"; } else { temp = nf.format(au.getRigaDocumento().getTotIvaRiga4()); } cell = new Cell(new Chunk(temp, PDF_fPiccolo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col5); pdfcorpo.addCell(cell); } if (definitivo && au.getTmstStampa() == null) { au.setTmstStampa(getTimestamp().toString()); au.save(); } } cell = new Cell(new Chunk("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------", PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(40); pdfcorpo.addCell(cell); } catch (Exception e) { e.printStackTrace(); } } public Vectumerator findArticolixStampTulps() { String s_Sql_Find = "select A.* from ARTICOLO as A inner join ARTICOLO_USATO AS B ON A.id_articolo=B.id_articolo"; String s_Sql_order = " order by B.dataDocumento, A.nome"; WcString wc = new WcString(); wc.addWc("A.flgUsato>0"); wc.addWc("(B.tmstStampa is null or B.tmstStampa='')"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + String.valueOf(wc)); return findRows(stmt); } catch (Exception e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public boolean isArticoloUsatoAcquistato() { ArticoloUsato au = new ArticoloUsato(getApFull()); return au.isArticoloAcquistato(getId_articolo()); } public boolean isArticoloUsatoReso() { ArticoloUsato au = new ArticoloUsato(getApFull()); return au.isArticoloReso(getId_articolo()); } public boolean isArticoloUsatoVenduto() { ArticoloUsato au = new ArticoloUsato(getApFull()); return au.isArticoloVenduto(getId_articolo()); } public void aggiornaPrezzoNettoConCostoNuovo() { if (getCostoNuovo() > 0.0D) { double l_ricarico = getPercRicarico(); if (l_ricarico <= 0.0D); setCostoPrecedente(getCostoNetto()); setImponibilePrecedente(getPrezzoBase()); setCostoNetto(getCostoNuovo()); DoubleOperator prNetto = new DoubleOperator(getCostoNetto()); prNetto.multiply(l_ricarico + 100.0D); prNetto.divide(100.0F); prNetto.setScale(2, 5); double prPubblicoConIva = conIva(prNetto.getResult(), (double)getIva().getAliquota()); if (prPubblicoConIva >= getParm("CC_ARROTONDA_PREZZO_A_EURO_SOPRA").getNumero()) { prPubblicoConIva = arrotonda(prPubblicoConIva, 1.0D); } else { prPubblicoConIva = arrotonda(prPubblicoConIva, getParm("CC_ARROTONDA_DECIMALE_PER_PREZZI_BASSI").getNumero()); } double prNettoFinale = scorporaIva(prPubblicoConIva, (double)getIva().getAliquota()); ListinoArticolo listinoArticoloBase = getListinoArticoloBase(); listinoArticoloBase.setPrezzoLA(prNettoFinale); ResParm rp = listinoArticoloBase.save(); setCostoNuovo(0.0D); setDataUltimoCosto(getToday()); setPrezzoArticolo(null); super.save(); } } public String getIdTipoSearch() { return (this.idTipoSearch == null) ? "" : this.idTipoSearch.trim(); } public void setIdTipoSearch(String idTipoSearch) { this.idTipoSearch = idTipoSearch; } public long getTipoOrdineSearch() { return this.tipoOrdineSearch; } public void setTipoOrdineSearch(long tipoOrdineSearch) { this.tipoOrdineSearch = tipoOrdineSearch; } public String getTipoDescrizioneSearch() { return (this.tipoDescrizioneSearch == null) ? "" : this.tipoDescrizioneSearch.trim(); } public void setTipoDescrizioneSearch(String tipoDescrizioneSearch) { this.tipoDescrizioneSearch = tipoDescrizioneSearch; } public Vectumerator findWebByArticoloCR(ArticoloCR CR, int pageNumber, int pageRows) { String occurrenceFind, orderBy; if (CR.getSearchTxtWeb().length() > 3 && CR.getSearchTxtWeb().trim().startsWith("*")) return AB_EMPTY_VECTUMERATOR; StringBuilder sb = new StringBuilder(); boolean debug = false; Timer timer = new Timer(); if (debug) { timer.start(); sb.append(">>>>>>>>>>>>>>>>>>>>>>\nFINDWEBARTICOLO: "); java.util.Date d = new java.util.Date(System.currentTimeMillis()); sb.append(getApFull().getReqUrl()); sb.append("\n"); sb.append(d.toString()); sb.append(" ip: "); sb.append(getApFull().getReqIpAddress()); } if (CR.getSearchTxtWeb().indexOf("%20") >= 0) CR.setSearchTxtWeb(CR.getSearchTxtWeb().replaceAll("%20", " ")); String occurrence = findWebByArticoloCRCreateSmartSearchOccurrence(CR.getSearchTxtWeb().toLowerCase(), "A.descrizioneSearch"); if (!occurrence.isEmpty()) { occurrenceFind = occurrence + ", "; } else { occurrenceFind = ""; } StringBuffer s_Sql_Find = new StringBuffer("select " + occurrenceFind + " A.* from ARTICOLO AS A inner join TIPO AS C on C.id_tipo=A.id_tipo "); if (occurrence.isEmpty()) { orderBy = " order by "; } else { orderBy = " order by occorrenze desc,"; } String s_Sql_Order = orderBy; if (CR.getFlgOrderBy() == 0L) { s_Sql_Order = orderBy + "A.nome " + orderBy; } else if (CR.getFlgOrderBy() == 11L) { s_Sql_Order = orderBy + "A.id_articolo " + orderBy; } else if (CR.getFlgOrderBy() == 1L) { s_Sql_Order = orderBy + "M.descrizione " + orderBy + ", A.codice, A.nome " + CR.getFlgOrderType(); } else if (CR.getFlgOrderBy() == 2L) { s_Sql_Order = orderBy + "A.tipoOrdineSearch, A.tipoDescrizioneSearch , A.nome "; } else if (CR.getFlgOrderBy() == 3L) { s_Sql_Order = orderBy + "A.tipoOrdineSearch, A.tipoDescrizioneSearch desc , A.nome desc"; } else if (CR.getFlgOrderBy() == 4L) { s_Sql_Order = orderBy + "A.prezzoPubblicoIvaOrd ,A.tipoOrdineSearch, A.tipoDescrizioneSearch , A.nome"; } else if (CR.getFlgOrderBy() == 5L) { s_Sql_Order = orderBy + " A.prezzoPubblicoIvaOrd desc ,A.tipoOrdineSearch, A.tipoDescrizioneSearch ,A.nome"; } else if (CR.getFlgOrderBy() == 7L) { s_Sql_Order = orderBy + "A.quantita desc, C.descrizioneR , A.nome "; } if (s_Sql_Order.equals(orderBy)) s_Sql_Order = orderBy + "A.nome " + orderBy; WcString wc = new WcString(); findWebByArticoloCRCreateWC(CR, s_Sql_Find, wc); try { if (debug) { sb.append("\n"); sb.append(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find) + wc.toString()); } PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find) + wc.toString()); Vectumerator vec = findRows(stmt, pageNumber, pageRows); if (debug) { timer.stop(); sb.append("\nDurata query: ms "); sb.append(timer.getDurataMilliSec()); sb.append("\n"); sb.append("\n<<<<<<<<<<<<"); System.out.println(sb.toString()); } return vec; } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } protected void findWebByArticoloCRCreateWC(ArticoloCR CR, StringBuffer s_Sql_Find, WcString wc) { if (CR.getTag().indexOf("NOLEGGIO") >= 0) { if (CR.getFlgDisponibilita().isEmpty()) { CR.setFlgDisponibilita("1"); } else if (CR.getFlgDisponibilita().indexOf("1") < 0) { CR.setFlgDisponibilita("1,2"); } if (CR.getFiltri_id().isEmpty() && !CR.getFlgDisponibilita().isEmpty()) CR.setFiltri_id("D," + CR.getFlgDisponibilita()); } else { if (CR.getTag().indexOf("USATO") >= 0) if (CR.getFlgCondizioni().isEmpty()) { CR.setFlgCondizioni("3"); } else if (CR.getFlgCondizioni().indexOf("3") < 0) { CR.setFlgCondizioni(CR.getFlgCondizioni() + ",3"); } if (CR.getTag().indexOf("STOCK") >= 0) if (CR.getFlgCondizioni().isEmpty()) { CR.setFlgCondizioni("2"); } else if (CR.getFlgCondizioni().indexOf("2") < 0) { CR.setFlgCondizioni(CR.getFlgCondizioni() + ",2"); } if (CR.getFiltri_id().isEmpty() && !CR.getFlgCondizioni().isEmpty()) CR.setFiltri_id("C," + CR.getFlgCondizioni()); } if (CR.getFlgOrderBy() == 1L) s_Sql_Find.append(" inner join MARCA as M on A.id_marca=M.id_marca"); if (!CR.getTagArticolo().isEmpty()) { wc.addWc("A.tagArticolo like '%," + CR.getTagArticolo() + ",%'"); } else if (!CR.getSearchTxtWeb().isEmpty() && !CR.getSearchTxtWeb().equals("*")) { if (!CR.getSearchTxtWeb().startsWith("#")) { String temp = findByCRCreateSmartSearchWC(CR.getSearchTxtWeb().toLowerCase(), "A.descrizioneSearch"); if (!temp.isEmpty()) wc.addWc(temp); } } if (CR.getFlgEscludiWeb() == 0L) wc.addWc("(A.flgEscludiWeb=0)"); if (CR.getFlgDisponibile() > 0L) wc.addWc("A.quantita>0"); if (CR.getFlgNascondi() == 0L) { wc.addWc("(A.flgNascondi=0 or A.flgNascondi is null)"); wc.addWc("(C.flgNascondi=0 or C.flgNascondi is null)"); } else if (CR.getFlgNascondi() > 0L) { wc.addWc("A.flgNascondi=" + CR.getFlgNascondi()); wc.addWc("C.flgNascondi=" + CR.getFlgNascondi()); } if (!CR.getFlgDisponibilita().isEmpty()) { StringTokenizer st = new StringTokenizer(CR.getFlgDisponibilita(), ","); while (st.hasMoreTokens()) { long token = Long.parseLong(st.nextToken()); if (token == 1L) { wc.addWc("A.flgNoleggio>0"); continue; } if (token == 2L) wc.addWc("A.quantita>0"); } } if (!CR.getFlgCondizioni().isEmpty()) { StringTokenizer st = new StringTokenizer(CR.getFlgCondizioni(), ","); StringBuilder sbFlgStockOfferte = new StringBuilder("("); while (st.hasMoreTokens()) { String token = st.nextToken(); sbFlgStockOfferte.append("A.flgStockOfferte=" + token); if (st.hasMoreTokens()) sbFlgStockOfferte.append(" or "); } sbFlgStockOfferte.append(")"); wc.addWc(sbFlgStockOfferte.toString()); } if (CR.getId_articoloEscluso() > 0L) wc.addWc("A.id_articolo!=" + CR.getId_articoloEscluso()); if (CR.getFlgNoleggio() == 10L) wc.addWc("A.flgNoleggio!=1"); if (!CR.getId_marche().isEmpty()) { StringTokenizer st = new StringTokenizer(CR.getId_marche(), ","); StringBuilder wcmarche = new StringBuilder("("); while (st.hasMoreTokens()) { long token = Long.parseLong(st.nextToken()); wcmarche.append("A.id_marca= " + token); if (st.hasMoreTokens()) wcmarche.append(" or "); } wcmarche.append(")"); wc.addWc(wcmarche.toString()); } if (!CR.getCarId_listaS().isEmpty()) { boolean needOr = false; StringTokenizer st = new StringTokenizer(CR.getCarId_listaS(), ","); StringBuilder cli = new StringBuilder("("); while (st.hasMoreTokens()) { String token = st.nextToken(); if (!token.isEmpty() && !token.equals("0")) { if (token.startsWith("c")) { if (st.hasMoreTokens()) { cli.append(") and ( "); needOr = false; } continue; } if (needOr) cli.append(" or "); cli.append("A.caratteristicheListeId like '%," + token + ",%'"); needOr = true; } } cli.append(")"); if (cli.length() > 2) wc.addWc(cli.toString()); } if (CR.getId_tipoSel() != 0L) wc.addWc("A.idTipoSearch like'%:" + CR.getId_tipoSel() + ":%'"); if (CR.getPrezzoDa() > 0.0D) wc.addWc("A.prezzoPubblicoIvaOrd>=" + CR.getPrezzoDa()); if (CR.getPrezzoA() > 0.0D) wc.addWc("A.prezzoPubblicoIvaOrd<=" + CR.getPrezzoA()); if (!CR.getLastItems().isEmpty()) { boolean firstElement = true; StringTokenizer st = new StringTokenizer(CR.getLastItems(), ","); StringBuilder sb = new StringBuilder("("); while (st.hasMoreTokens()) { String item = st.nextToken().trim(); if (!item.isEmpty()) { if (firstElement) { firstElement = false; } else { sb.append(" or "); } sb.append("A.id_articolo=" + item); } } if (!firstElement) { sb.append(")"); wc.addWc(sb.toString()); } else { wc.addWc("A.id_articolo=-1"); } } String occurrence = findWebByArticoloCRCreateSmartSearchOccurrence(CR.getSearchTxtWeb().toLowerCase(), "A.descrizioneSearch"); if (!occurrence.isEmpty()) if (getParm("USE_SEARCH_LAST_2_OCCURRENCE").isTrue()) { wc.addHavingWc(" occorrenze >= (select max" + occurrence.replace(")) as occorrenze", ")-1) as occorrenze") + " from ARTICOLO AS A )"); } else { wc.addHavingWc(" occorrenze = (select max" + occurrence + " from ARTICOLO AS A )"); } } public double getPrezzoPubblicoArticoloMinByCR(ArticoloCR CR) { String occurrenceFind; StringBuilder sb = new StringBuilder(); boolean debug = false; Timer timer = new Timer(); if (debug) { timer.start(); sb.append(">>>>>>>>>>>>>>>>>>>>>>\nPREZZO MIN findWebByArticoloCR: "); java.util.Date d = new java.util.Date(System.currentTimeMillis()); sb.append(getApFull().getReqUrl()); sb.append("\n"); sb.append(d.toString()); sb.append(" ip: "); sb.append(getApFull().getReqIpAddress()); } String occurrence = findWebByArticoloCRCreateSmartSearchOccurrence(CR.getSearchTxtWeb().toLowerCase(), "A.descrizioneSearch"); if (!occurrence.isEmpty()) { occurrenceFind = occurrence + ", "; } else { occurrenceFind = ""; } StringBuffer s_Sql_Find = new StringBuffer("select " + occurrenceFind + " min(prezzoPubblicoIvaOrd) as _max from ARTICOLO AS A inner join TIPO AS C on C.id_tipo=A.id_tipo "); try { WcString wc = new WcString(); ArticoloCR CR2 = CR.getClone(); CR2.setPrezzoA(0.0D); CR2.setPrezzoDa(0.0D); CR2.setFlgNoleggio(10L); findWebByArticoloCRCreateWC(CR2, s_Sql_Find, wc); if (debug) { sb.append("\n"); sb.append(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find)); } PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find)); double res = getMax(stmt); if (debug) { timer.stop(); sb.append("\nDurata query: ms "); sb.append(timer.getDurataMilliSec()); sb.append("\n"); sb.append("\n<<<<<<<<<<<<"); System.out.println(sb.toString()); } return res; } catch (SQLException|CloneNotSupportedException e) { handleDebug(e); return 0.0D; } } public synchronized ResParm aggiornaUltimoCosto(double l_costoNuovo, Date l_dataCarico) { ResParm rp = new ResParm(true); if ((getDataUltimoCosto() == null || getDateDiff(getDataUltimoCosto(), l_dataCarico) >= 0L) && l_costoNuovo != getCostoNetto()) { setDataUltimoCosto(l_dataCarico); setCostoNetto(l_costoNuovo); setCostoNuovo(0.0D); rp = super.save(); } return rp; } public void setSimboliLavaggio(SimboliLavaggio simboliLavaggio) { this.simboliLavaggio = simboliLavaggio; } public double getCostoAcquisto(Clifor l_clifor) { double costoAcquistoCLifor = getCostoAcquistoUltimo(l_clifor); if (costoAcquistoCLifor != 0.0D) return costoAcquistoCLifor; if (getCostoNetto() != 0.0D) return getCostoNetto(); return getCostoAcquistoUltimo(); } public double getCostoAcquistoConIva() { if (getCostoNetto() != 0.0D) return getCostoNettoIva(); return getCostoAcquistoUltimoConIva(); } public double getImportoRata(String tabfin, long l_durata) { if (getPrezzoPubblicoIva() > 0.0D) { ConselTabfin ctf = new ConselTabfin(getApFull()); ctf.findByTipoValoreDurata(tabfin, (double)getPrezzoPubblicoIvaL(), l_durata); return ctf.getImportoRata(); } return -1.0D; } public long getPrezzoPubblicoIvaL() { return Math.round(getPrezzoPubblicoIva()); } public double getRicaricoEffettivoDaCostoNetto() { return getRicaricoCalc(getCostoNetto()); } public ResParm creaFileInventarioCsv(ArticoloCR CR) { int numRecord = 0; ResParm rp = new ResParm(true); try { int i = 0; int se1 = 10; int se2 = 100; String fileCsv = "inventario.csv"; String filename = getDocBase() + getDocBase() + getParm("PATH_TMP").getTesto(); new File(filename).delete(); FileWr outFile = new FileWr(filename, "UTF-8", false); Vectumerator vec = findByCR(CR, 0, 0); System.out.println("creaFileInventario. n. record: " + vec.getTotNumberOfRecords()); while (vec.hasMoreElements()) { i++; Articolo rowbean = (Articolo)vec.nextElement(); String s1 = rowbean.getRecordInventario(); outFile.writeLine(s1); if (se1 <= 0 || i % se1 == 0); if (se2 <= 0 || i % se2 == 0); } outFile.closeFile(); rp.setStatus(true); rp.setMsg("Generazione file inventario avvenuta con successo.
Numero Record: " + numRecord); CR.setFileName(fileCsv); } catch (Exception e) { handleDebug(e); rp.setException(e); rp.setStatus(false); } return rp; } public ResParm creaFileReportVenditeCsv(ArticoloCR CR) { int numRecord = 0; ResParm rp = new ResParm(true); if (CR.getDataDocumentoDa() == null && CR.getDataDocumentoA() == null) return new ResParm(false, "Errore! Immettere almeno una data documento nei criteri"); try { String fileCsv = "reportVendite" + CR.getId_users() + "_" + getNow().getTime() + ".csv"; CR.setFileName(fileCsv); String filename = getDocBase() + getDocBase() + getParm("PATH_TMP").getTesto(); new File(filename).delete(); FileWr outFile = new FileWr(filename, "UTF-8", false); String intestazione = "data Inserimento;id_articolo;codice articolo;codici fornitori;descrizione;famiglia;sotto famiglia;marca;costo netto;qta caricata;qta venduta;num. vendite;giacenza;;scaffale;eBay;stockOfferte;google;pr. vend. netto;pr. pubblico;link"; Vectumerator vec = new RigaDocumento(getApFull()).findReportVenditeByArticoloCR(CR); String s1 = intestazione; outFile.writeLine(s1); Articolo currentArticolo = null; double qtaVenduta = 0.0D; long numVendite = 0L; while (vec.hasMoreElements()) { RigaDocumento rowbean = (RigaDocumento)vec.nextElement(); if (currentArticolo == null) currentArticolo = rowbean.getArticolo(); if (currentArticolo.getId_articolo() != rowbean.getId_articolo()) { qtaVenduta = rowbean.getMSQtaCaricataScaricataByArticolo(currentArticolo.getId_articolo(), -1L, CR.getDataDocumentoDa(), CR.getDataDocumentoA()); double qtaCaricata = rowbean.getMSQtaCaricataScaricataByArticolo(currentArticolo.getId_articolo(), 1L, CR.getDataDocumentoDa(), CR.getDataDocumentoA()); s1 = currentArticolo.getRecordReportVendite(qtaCaricata, qtaVenduta, numVendite); outFile.writeLine(s1); numVendite = 0L; currentArticolo = rowbean.getArticolo(); } numVendite++; if (!vec.hasMoreElements()) { qtaVenduta = rowbean.getMSQtaCaricataScaricataByArticolo(currentArticolo.getId_articolo(), -1L, CR.getDataDocumentoDa(), CR.getDataDocumentoA()); double qtaCaricata = rowbean.getMSQtaCaricataScaricataByArticolo(currentArticolo.getId_articolo(), 1L, CR.getDataDocumentoDa(), CR.getDataDocumentoA()); s1 = currentArticolo.getRecordReportVendite(qtaCaricata, qtaVenduta, numVendite); outFile.writeLine(s1); } } Articolo articolo = new Articolo(getApFull()); vec = articolo.findArticoliNonVenduti(CR, true, 0, 0); RigaDocumento rd = new RigaDocumento(getApFull()); if (vec.hasMoreElements()) { outFile.writeLine("\n\n\nARTICOLI NON VENDUTI CON GIACENZA >0\n\n" + intestazione); while (vec.hasMoreElements()) { Articolo row = (Articolo)vec.nextElement(); qtaVenduta = rd.getMSQtaCaricataScaricataByArticolo(row.getId_articolo(), -1L); double qtaCaricata = rd.getMSQtaCaricataScaricataByArticolo(row.getId_articolo(), 1L); s1 = row.getRecordReportVendite(qtaCaricata, qtaVenduta, 0L); outFile.writeLine(s1); } } vec = articolo.findArticoliNonVenduti(CR, false, 0, 0); if (vec.hasMoreElements()) { outFile.writeLine("\n\n\nARTICOLI NON VENDUTI SENZA GIACENZA \n\n" + intestazione); while (vec.hasMoreElements()) { Articolo row = (Articolo)vec.nextElement(); qtaVenduta = rd.getMSQtaCaricataScaricataByArticolo(row.getId_articolo(), -1L); double qtaCaricata = rd.getMSQtaCaricataScaricataByArticolo(row.getId_articolo(), 1L); s1 = row.getRecordReportVendite(qtaCaricata, qtaVenduta, 0L); outFile.writeLine(s1); } } outFile.closeFile(); rp.setStatus(true); rp.setMsg("Generazione file report vendite avvenuta con successo.
Numero Record: " + numRecord); } catch (Exception e) { handleDebug(e); rp.setException(e); rp.setStatus(false); } return rp; } private String getRecordInventario() { StringBuffer temp = new StringBuffer(); String sep = ";"; temp.append(getId_articolo()); temp.append(sep); temp.append(getCodice()); temp.append(sep); temp.append(getNome().replaceAll("€", "€").replace(";", " ")); temp.append(sep); temp.append(getTipo().getDescrizione()); temp.append(sep); temp.append(getTipo2().getDescrizione()); temp.append(sep); temp.append(getMarca().getDescrizione()); temp.append(sep); temp.append(getNf().format(getQuantita())); temp.append(sep); temp.append(getNf().format(getCostoNetto())); temp.append(sep); temp.append(getNf().format(getPrezzoPubblico())); if (getFlgUsato() > 0L) { temp.append(sep); temp.append(getNf().format(getCostoNetto())); temp.append(sep); temp.append(getNf().format(getPrezzoPubblico())); } return temp.toString(); } private String getRecordReportVendite(double qtaCaricata, double qtaVenduta, long numVendite) { StringBuffer temp = new StringBuffer(); String sep = ";"; temp.append(getDataFormat().format(getCreateTmst())); temp.append(sep); temp.append("\"" + getId_articolo() + "\""); temp.append(sep); temp.append(getCodice()); temp.append(sep); temp.append(getCodiciAlternativi()); temp.append(sep); temp.append(getNome().replaceAll("€", "€").replace(";", " ")); temp.append(sep); temp.append(getTipo().getDescrizione()); temp.append(sep); temp.append(getTipo2().getDescrizione()); temp.append(sep); temp.append(getMarca().getDescrizione()); temp.append(sep); temp.append(getNf().format(getCostoNetto())); temp.append(sep); temp.append(getNf().format(qtaCaricata)); temp.append(sep); temp.append(getNf().format(qtaVenduta)); temp.append(sep); temp.append(getNf().format(numVendite)); temp.append(sep); temp.append(getNf().format(getQuantita())); temp.append(sep); temp.append(sep); temp.append(getScaffale()); temp.append(sep); temp.append((getFlgEbay() == 1L) ? "s" : ""); temp.append(sep); temp.append(getStockOfferte()); temp.append(sep); temp.append((getFlgGoogle() == 1L) ? "s" : ""); temp.append(sep); temp.append(getNf().format(getPrice())); temp.append(sep); temp.append(getNf().format(getPriceWVat())); temp.append(sep); temp.append(getLinkPreview()); return temp.toString(); } private LinkedHashMap getRecordXmlGoogle(String lang) { String str1, condition; if (lang.isEmpty()) lang = "it"; NumberFormat nf2 = NumberFormat.getInstance(Locale.US); nf2.setMaximumFractionDigits(2); nf2.setMinimumFractionDigits(2); LinkedHashMap map = new LinkedHashMap<>(); String wwwSite = getWwwAddressParm(); map.put("g:id", getCodice()); if (!getDescTxtLangScript("nomeMarketplace", "it").isEmpty()) { map.put("g:title", getDescTxtLangScript("nomeMarketplace", "it").replaceAll("€", "€").replace(";", " ")); } else { map.put("g:title", getNome()); } if (!getDescrizioneMarketplace(lang).isEmpty()) { map.put("g:description", getDescrizioneMarketplace(lang)); } else { map.put("g:description", getDescrizioneBreve(lang)); } ArticoloCR CR = new ArticoloCR(); CR.setLang(lang); map.put("g:link", wwwSite + wwwSite); map.put("g:image_link", wwwSite + "/_img/_imgArt/" + wwwSite); if (new File(getDocBase() + "/_img/_imgArt/" + getDocBase()).exists()) map.put("g:additional_image_link", wwwSite + "/_img/_imgArt/" + wwwSite); switch (getDispoLevel()) { case 0: str1 = "out of stock"; case 1: str1 = "in stock"; case 2: str1 = "in stock"; break; } String dispo = ""; map.put("g:availability", dispo); if (isOffertaValida()); if (isPrezzoBarratoValido()); if (isOffertaValida()) { map.put("g:price", nf2.format(getPrezzoBaseIva()) + " EUR"); map.put("g:sale_price", nf2.format(getPrezzoPubblicoIva()) + " EUR"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); } else if (isPrezzoBarratoValido()) { map.put("g:price", nf2.format(getPrezzoIvatoBarrato()) + " EUR"); map.put("g:sale_price", nf2.format(getPrezzoPubblicoIva()) + " EUR"); } else { map.put("g:price", nf2.format(getPrezzoPubblicoIva()) + " EUR"); } map.put("g:product_type", getTipo().getDescrizioneCompletaGreater(lang)); map.put("g:brand", getMarca().getDescrizione()); if (!getCodiceProduttore().isEmpty()) map.put("g:mpn", getCodiceProduttore()); if (!getCodiceEan().isEmpty()) map.put("g:gtin", getCodiceEan()); if (getCodiceEan().isEmpty()) map.put("g:identifier_exists", "no"); if (getFlgStockOfferte() == 3L) { condition = "used"; } else { condition = "new"; } map.put("g:condition", condition); StringBuilder sb = new StringBuilder(); Nazione nazione = new Nazione(getApFull()); Vectumerator vec = nazione.findAllAttive(lang); while (vec.hasMoreElements()) { Nazione row = (Nazione)vec.nextElement(); sb.append(row.getCodice()); sb.append(":::"); sb.append(nf2.format(conIva(row.getCostoSpedizione(), (double)getIva().getAliquota()))); sb.append(" EUR"); if (vec.hasMoreElements()) sb.append(" "); } map.put("g:shipping", sb.toString()); return map; } public Vectumerator findArticoliNonVenduti(ArticoloCR CR, boolean conGiacenza, int pageNumber, int pageRows) { String s_Sql_Find = "select A.* from RIGA_DOCUMENTO as A inner join DOCUMENTO AS B on A.id_documento=B.id_documento inner join ARTICOLO AS C on A.id_articolo=C.id_articolo inner join TIPO_DOCUMENTO AS TD ON B.id_tipoDocumento=TD.id_tipoDocumento"; String s_Sql_order = " order by CM.codice"; if (CR.getFlgEscludiWeb() >= 0L || CR.getId_tipo() != 0L || CR.getFlgNascondi() >= 0L || !CR.getFlgReport().isEmpty()) s_Sql_Find = s_Sql_Find + " inner join TIPO AS T ON T.id_tipo=C.id_tipo"; WcString wc = new WcString(); String s_Sql_FindM = "select CM.* from ARTICOLO as CM"; if (CR.getFlgEscludiWeb() >= 0L || CR.getId_tipo() != 0L || CR.getFlgNascondi() >= 0L || !CR.getFlgReport().isEmpty()) s_Sql_FindM = s_Sql_FindM + " inner join TIPO AS TM ON TM.id_tipo=CM.id_tipo"; s_Sql_FindM = s_Sql_FindM + " left join ("; String S_Sql_join = ") as R on CM.id_articolo=R.id_articolo "; WcString wcM = new WcString(); wcM.addWc("R.id_rigaDocumento is null"); if (conGiacenza) { wcM.addWc("CM.quantita>=1"); } else { wcM.addWc("(CM.quantita is null or CM.quantita<=0)"); } if (!CR.getCodice().isEmpty()) wcM.addWc("CM.codice like'" + CR.getCodice() + "%'"); if (CR.getId_iva() != 0L) wcM.addWc("CM.id_iva=" + CR.getId_iva()); if (CR.getId_clifor() != 0L) wcM.addWc("CM.id_fornitore=" + CR.getId_clifor()); if (CR.getFlgQta() == 1L) if (CR.getQtaDa() == 0L) { wcM.addWc("(CM.quantita<=" + CR.getQtaA() + ")"); } else { wcM.addWc("(CM.quantita>=" + CR.getQtaDa() + ")"); wcM.addWc("(CM.quantita<=" + CR.getQtaA() + ")"); } if (CR.getFlgUsato() >= 0L) wcM.addWc("CM.flgUsato=" + CR.getFlgUsato()); if (!CR.getScaffale().isEmpty()) if (CR.getScaffale().indexOf("*") > 0) { String temp = CR.getScaffale().replace("*", "%"); wcM.addWc("CM.scaffale like'" + temp + "'"); } else { wcM.addWc("CM.scaffale ='" + CR.getScaffale() + "'"); } if (!CR.getSearchTxt().isEmpty() && !CR.getSearchTxt().equals("*")) if (CR.getSearchTxt().startsWith(",")) { wcM.addWc("CM.codiciAlternativi like'%" + CR.getSearchTxt() + ",%'"); } else { wcM.addWc("(CM.codice like'%" + CR.getSearchTxt() + "%' or CM.descrizioneSearch like'%" + CR.getSearchTxt() + "%')"); } if (CR.getId_marca() != 0L) wcM.addWc("CM.id_marca=" + CR.getId_marca()); if (!CR.getDescrizione().isEmpty()) wcM.addWc("CM.descrizione like'%" + CR.getDescrizione() + "%'"); if (CR.getId_tipo() != 0L) wcM.addWc("(TM.id_tipo=" + CR.getId_tipo() + " or TM.indici like'%:" + CR.getId_tipo() + ":%')"); if (CR.getFlgEscludiWeb() == 0L) { wcM.addWc("(CM.flgEscludiWeb=0 or CM.flgEscludiWeb is null)"); } else if (CR.getFlgEscludiWeb() > 0L) { wcM.addWc("CM.flgEscludiWeb=" + CR.getFlgEscludiWeb()); } if (CR.getFlgWebNoVendita() == 0L) { wcM.addWc("(CM.flgWebNoVendita=0 or CM.flgWebNoVendita is null)"); } else if (CR.getFlgWebNoVendita() > 0L) { wcM.addWc("CM.flgWebNoVendita=" + CR.getFlgWebNoVendita()); } if (CR.getFlgStockOfferte() > 0L) if (CR.getFlgStockOfferte() == 99L) { wcM.addWc("(CM.flgStockOfferte=1 and (CM.dataScadenzaOfferta is null or CM.dataScadenzaOfferta>=?))"); } else { wcM.addWc("CM.flgStockOfferte=" + CR.getFlgStockOfferte()); } wc.addWc("TD.flgMovMagazzino =-1"); wc.addWc("(B.flgStatoOrdineWww is null or B.flgStatoOrdineWww <> 99)"); if (!CR.getCodice().isEmpty()) wc.addWc("C.codice like'" + CR.getCodice() + "%'"); if (CR.getId_iva() != 0L) wc.addWc("C.id_iva=" + CR.getId_iva()); if (CR.getId_clifor() != 0L) wc.addWc("C.id_fornitore=" + CR.getId_clifor()); if (CR.getFlgQta() == 1L) if (CR.getQtaDa() == 0L) { wc.addWc("(C.quantita<=" + CR.getQtaA() + ")"); } else { wc.addWc("(C.quantita>=" + CR.getQtaDa() + ")"); wc.addWc("(C.quantita<=" + CR.getQtaA() + ")"); } if (CR.getFlgUsato() >= 0L) wc.addWc("C.flgUsato=" + CR.getFlgUsato()); if (!CR.getScaffale().isEmpty()) if (CR.getScaffale().indexOf("*") > 0) { String temp = CR.getScaffale().replace("*", "%"); wc.addWc("C.scaffale like'" + temp + "'"); } else { wc.addWc("C.scaffale ='" + CR.getScaffale() + "'"); } if (!CR.getSearchTxt().isEmpty() && !CR.getSearchTxt().equals("*")) if (CR.getSearchTxt().startsWith(",")) { wc.addWc("C.codiciAlternativi like'%" + CR.getSearchTxt() + ",%'"); } else { wc.addWc("(C.codice like'%" + CR.getSearchTxt() + "%' or C.descrizioneSearch like'%" + CR.getSearchTxt() + "%')"); } if (CR.getId_marca() != 0L) wc.addWc("C.id_marca=" + CR.getId_marca()); if (!CR.getDescrizione().isEmpty()) wc.addWc("C.descrizione like'%" + CR.getDescrizione() + "%'"); if (CR.getId_tipo() != 0L) wc.addWc("(T.id_tipo=" + CR.getId_tipo() + " or T.indici like'%:" + CR.getId_tipo() + ":%')"); if (CR.getFlgEscludiWeb() == 0L) { wc.addWc("(C.flgEscludiWeb=0 or C.flgEscludiWeb is null)"); } else if (CR.getFlgEscludiWeb() > 0L) { wc.addWc("C.flgEscludiWeb=" + CR.getFlgEscludiWeb()); } if (CR.getFlgWebNoVendita() == 0L) { wc.addWc("(C.flgWebNoVendita=0 or C.flgWebNoVendita is null)"); } else if (CR.getFlgWebNoVendita() > 0L) { wc.addWc("C.flgWebNoVendita=" + CR.getFlgWebNoVendita()); } if (CR.getFlgStockOfferte() > 0L) if (CR.getFlgStockOfferte() == 99L) { wc.addWc("(C.flgStockOfferte=1 and (C.dataScadenzaOfferta is null or C.dataScadenzaOfferta>=?))"); } else { wc.addWc("C.flgStockOfferte=" + CR.getFlgStockOfferte()); } if (CR.getDataDocumentoDa() != null) wc.addWc("B.dataDocumento>=?"); if (CR.getDataDocumentoA() != null) wc.addWc("B.dataDocumento<=? "); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_FindM + s_Sql_FindM + s_Sql_Find + String.valueOf(wc) + S_Sql_join + String.valueOf(wcM)); int dataCount = 1; if (CR.getDataDocumentoDa() != null) { stmt.setDate(dataCount, CR.getDataDocumentoDa()); dataCount++; } if (CR.getDataDocumentoA() != null) { stmt.setDate(dataCount, CR.getDataDocumentoA()); dataCount++; } Vectumerator vec = findRows(stmt); return vec; } catch (Exception e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public double getQuantitaDB() { return this.quantitaDB; } public void setQuantitaDB(double quantitaDB) { this.quantitaDB = quantitaDB; } public long getFlgModImportazione() { return this.flgModImportazione; } public static final String getModImportazione(long l_flgModImportazione) { switch ((int)l_flgModImportazione) { case 9: return "Controllato"; case 2: return "Modificato"; case 0: return "Non Trovato"; case 1: return "Nuovo"; case 4: return "Trovato NON Disponibile"; case 3: return "Trovato NON Modificato"; } return ""; } public String getModImportazione() { return getModImportazione(getFlgModImportazione()); } public static final String getPriceTypeAmz(long l_flgPriceTypeAmz) { switch ((int)l_flgPriceTypeAmz) { case 1: return "Prezzo+Sped. Percentile"; case 2: return "Prezzo+Sped.fissa"; case 0: return "Prezzo Senza Sped."; } return ""; } public String getPriceTypeAmz() { return getPriceTypeAmz(getFlgPriceTypeAmz()); } public void setFlgModImportazione(long flgModImportazione) { this.flgModImportazione = flgModImportazione; } public static final String getEscludiWebArt(long l_flgEscludiWebArt) { if (l_flgEscludiWebArt == -1L) return "Da Tipo"; if (l_flgEscludiWebArt == 1L) return "Non Visibile"; if (l_flgEscludiWebArt == 2L) return "Sospeso"; if (l_flgEscludiWebArt == 0L) return "Visibile"; return "??"; } public static final String getGoogle(long l_flgGoogle) { if (l_flgGoogle == 0L) return "No"; if (l_flgGoogle == 1L) return "Free Listing"; if (l_flgGoogle == 2L) return "Full Listing (ads)"; if (l_flgGoogle == 3L) return "Search All (ads+free)"; if (l_flgGoogle < 0L) return ""; return "??"; } public final String getGoogle() { return getGoogle(getFlgGoogle()); } public static final String getEscludiWeb(long l_flgEscludiWebArt) { return getEscludiWebArt(l_flgEscludiWebArt); } public String getEscludiWebArt() { return getEscludiWebArt(getFlgEscludiWebArt()); } public void caricaImmaginaDaRemoto(String urlImage) { caricaImmaginaDaRemoto(urlImage, 1L); } public void caricaImmaginaDaRemoto(String urlImage, long imgNumber) { if (getDBState() == 1) { String filename = getDocBase() + getDocBase() + getPathImg(); DBAdapter.getFileFromUrl(urlImage, filename); } } public long getFlgDisponibilitaWeb() { return this.flgDisponibilitaWeb; } public void setFlgDisponibilitaWeb(long flgDisponibilita) { this.flgDisponibilitaWeb = flgDisponibilita; } public static final String getDisponibilitaWeb(long l_flgDisponibilita) { if (l_flgDisponibilita == 0L) return "Disponibile"; if (l_flgDisponibilita == 1L) return "In Ordine"; if (l_flgDisponibilita == 2L) return "Non Disponibile"; return "??"; } public String getDisponibilitaWeb() { return getDisponibilitaWeb(getFlgDisponibilitaWeb()); } public String getCodicePrimoLiberoBySerie(String serie) { long numDaSottrarre = Long.valueOf(serie) * 10000L; String s_Sql_Find = " SELECT * FROM ( select codice as idorig, CONVERT(codice,UNSIGNED INTEGER)-" + numDaSottrarre + " as idn, (@row_number:=@row_number + 1) AS codice from ARTICOLO WHERE codice like '" + serie + "%' order by codice) AS B WHERE B.idn<>B.codice limit 1;"; try { update("SET @row_number = 0;"); PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find); Vectumerator vec = findRows(stmt); if (!vec.hasMoreElements()) return serie + "0001"; Articolo art = (Articolo)vec.nextElement(); return serie + serie; } catch (Exception e) { handleDebug(e); return ""; } } public String getEscludiWeb() { return getEscludiWebArt(getFlgEscludiWeb()); } public ResParm creaFileXmlGoogleOLD(ArticoloCR CR) { int numRecord = 0; ResParm rp = new ResParm(true); try { String googleFile = "google_" + System.currentTimeMillis() + ".xml"; String filename = getDocBase() + getDocBase() + getParm("PATH_TMP").getTesto(); new File(filename).delete(); FileWr outFile = new FileWr(filename, "UTF-8", false); CR.setFlgGoogle(1L); Vectumerator vec = findByCR(CR, 0, 0); String title = getParm("TITLE").getTesto(); String site = getParm("P_WWW_ADDRESS").getTesto(); outFile.writeLine(""); outFile.writeLine(""); outFile.writeLine(" " + title + ""); outFile.writeLine(" "); outFile.writeLine(" " + String.valueOf(getTimestamp()) + ""); StringBuffer temp = new StringBuffer(); String lt = "<", gt = ">", ltc = ""); LinkedHashMap product = rowbean.getRecordXmlGoogle(CR.getLang()); for (Map.Entry entry : product.entrySet()) { temp = new StringBuffer(" "); temp.append(lt); temp.append(entry.getKey()); temp.append(gt); String value = entry.getValue(); if (value.indexOf(">") >= 0) value = value.replace(">", ">"); if (value.indexOf("<") >= 0) value = value.replace("<", "<"); temp.append(value); temp.append(ltc); temp.append(entry.getKey()); temp.append(gt); outFile.writeLine(temp.toString()); } outFile.writeLine(" "); } outFile.writeLine(""); outFile.closeFile(); rp.setStatus(true); rp.setReturnObj(googleFile); rp.setMsg("Generazione file GOOGLE XML avvenuta con successo.
Numero Record: " + numRecord); } catch (Exception e) { handleDebug(e); rp.setException(e); rp.setStatus(false); } return rp; } private String findByCRCreateSmartSearchWC(String searchTxt, String searchColumn) { StringBuilder sb = new StringBuilder(); String LIKE_START = " like '%"; String LIKE_END = "%' "; String P_OPEN = "("; String P_CLOSE = ")"; String OR = " OR "; String AND = " AND "; if (!searchTxt.isEmpty() && !searchTxt.equals("*")) { StringTokenizer st = new StringTokenizer(searchTxt, " "); StringBuffer txt = new StringBuffer("("); String token2 = null; Vector vt = findByCRCreateSmartSearchBuildTokenVector(searchTxt); if (vt.size() == 0) return ""; sb.append("("); if (vt.size() == 1) { sb.append(searchColumn); sb.append(" like '%"); sb.append(vt.get(0)); sb.append("%' "); } else { for (int i = 0; i < vt.size() - 1; i++) { for (int j = i + 1; j < vt.size(); j++) { sb.append("("); sb.append(searchColumn); sb.append(" like '%"); sb.append(vt.get(i)); sb.append("%' "); sb.append(" AND "); sb.append(searchColumn); sb.append(" like '%"); sb.append(vt.get(j)); sb.append("%' "); sb.append(")"); if (i != vt.size() - 2 || j != vt.size() - 1) sb.append(" OR "); } } } sb.append(")"); } return sb.toString(); } public String findWebByArticoloCRCreateSmartSearchOccurrence(String searchTxt, String searchColumn) { StringBuilder sb = new StringBuilder(); if (!searchTxt.isEmpty() && !searchTxt.equals("*")) { String CHAR_LEN = "LEAST(1,CHAR_LENGTH("; String CHAR_LEN_REPLACE = ") - CHAR_LENGTH( REPLACE ("; String P_OPEN = "("; String P_CLOSE = ")"; String COMMA = ","; String APX = "'"; StringTokenizer st = new StringTokenizer(searchTxt, " "); StringBuffer txt = new StringBuffer("("); String token2 = null; Vector vt = findByCRCreateSmartSearchBuildTokenVector(searchTxt); if (vt.size() > 0) { sb.append("("); for (int i = 0; i < vt.size(); i++) { sb.append("LEAST(1,CHAR_LENGTH("); sb.append(searchColumn); sb.append(") - CHAR_LENGTH( REPLACE ("); sb.append(searchColumn); sb.append(","); sb.append("'"); sb.append(vt.get(i)); sb.append("'"); sb.append(","); sb.append("'"); String temp = String.format("%" + vt.get(i).length() - 1 + "s", "").replace(' ', 'x'); sb.append(temp); sb.append("'"); sb.append(")"); sb.append(")"); sb.append(")"); if (i < vt.size() - 1) sb.append("+"); } sb.append(") as occorrenze "); } } return sb.toString(); } private Vector findByCRCreateSmartSearchBuildTokenVector(String searchTxt) { if (!searchTxt.isEmpty() && !searchTxt.equals("*")) { StringTokenizer st = new StringTokenizer(searchTxt, " "); StringBuffer txt = new StringBuffer("("); String token2 = null; Vector vt = new Vector<>(); while (st.hasMoreTokens()) { String token = prepareInputMySqlString(st.nextToken(), true); if (token.length() > 1) { vt.add(token); if (token.contains(",")) { token2 = token.replace(",", "."); } else if (token.contains(".")) { token2 = token.replace(".", ","); } else { token2 = null; } if (token2 != null) vt.add(token2); } } return vt; } return null; } public ResParm creaFileCsvFacebooke(ArticoloCR CR) { int numRecord = 0; ResParm rp = new ResParm(true); try { String filename = getDocBase() + getDocBase() + "facebook.csv"; new File(filename).delete(); FileWr outFile = new FileWr(filename, "UTF-8", false); Vectumerator vec = findByCR(CR, 0, 0); outFile.writeLine(""); outFile.writeLine(" TuttoFoto.com Online Store"); outFile.writeLine(" "); outFile.writeLine(" " + String.valueOf(getTimestamp()) + ""); StringBuffer temp = new StringBuffer(); String lt = "<", gt = ">", ltc = ""); LinkedHashMap product = rowbean.getRecordXmlGoogle(CR.getLang()); for (Map.Entry entry : product.entrySet()) { temp = new StringBuffer(" "); temp.append(lt); temp.append(entry.getKey()); temp.append(gt); String value = entry.getValue(); if (value.indexOf(">") >= 0) value = value.replace(">", ">"); if (value.indexOf("<") >= 0) value = value.replace("<", "<"); temp.append(value); temp.append(ltc); temp.append(entry.getKey()); temp.append(gt); outFile.writeLine(temp.toString()); } outFile.writeLine(" "); } outFile.writeLine(""); outFile.closeFile(); rp.setStatus(true); rp.setMsg("Generazione file GOOGLE XML avvenuta con successo.
Numero Record: " + numRecord); } catch (Exception e) { handleDebug(e); rp.setException(e); rp.setStatus(false); } return rp; } public ByteArrayOutputStream creaListinoPdf(ArticoloCR CR) { boolean debug = false; String debugInfo = "Articolo.creaListinoPdf "; NumberFormat nf3 = NumberFormat.getInstance(); nf3.setMaximumFractionDigits(3); nf3.setMinimumFractionDigits(3); NumberFormat nf0 = NumberFormat.getInstance(); nf0.setMaximumFractionDigits(0); nf0.setMinimumFractionDigits(0); int col1 = 3, col2 = 5, col3 = 20, col4 = 4, col5 = 2, col6 = 6; ByteArrayOutputStream ba = new ByteArrayOutputStream(); String titoloReport = ""; try { this.document = new Document(PageSize.A4, 20.0F, 20.0F, 10.0F, 10.0F); titoloReport = "Listino Prodotti"; int cellLeading = 8; SimpleDateFormat tf = new SimpleDateFormat("HH:mm:ss"); Date today = getToday(); titoloReport = titoloReport + ". Stampato il " + titoloReport + " " + getDataFormat().format(today); this.writer = PdfWriter.getInstance(this.document, ba); Phrase pH = new Phrase(titoloReport + " - Pag. n. "); HeaderFooter header = new HeaderFooter(pH, true); header.setAlignment(2); header.setBorder(0); this.document.setHeader(header); this.document.open(); creaIntestazioneReport(titoloReport, CR.getDescrizioneCR()); Cell blankCell = new Cell(); blankCell.addElement(new Chunk(" ", PdfFontFactory.PDF_A_PiccoloBianco)); blankCell.setBorder(0); blankCell.setColspan(40); this.pdfcorpo.addCell(blankCell); Cell cell = new Cell(); cell.addElement(new Chunk("Codice", PdfFontFactory.PDF_fPiccoloB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col1); this.pdfcorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("Marca", PdfFontFactory.PDF_fPiccoloB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col2); this.pdfcorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("Descrizione", PdfFontFactory.PDF_fPiccoloB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col3); this.pdfcorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("Scaffale", PdfFontFactory.PDF_fPiccoloB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col4); this.pdfcorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("Giac.", PdfFontFactory.PDF_fPiccoloB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col5); this.pdfcorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk("Prezzo Pub. con iva", PdfFontFactory.PDF_fPiccoloB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col6); this.pdfcorpo.addCell(cell); CR.setFlgOrderBy(2L); Vectumerator vec = findByCR(CR, 0, 0); long currentTipo = -1L; while (vec.hasMoreElements()) { Articolo rowArticolo = (Articolo)vec.nextElement(); if (debug) System.out.println(debugInfo + debugInfo + " - " + rowArticolo.getNome()); cell = new Cell(); cell.addElement(new Chunk(rowArticolo.getCodice(), PdfFontFactory.PDF_fPiccolo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(col1); this.pdfcorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(rowArticolo.getMarca().getDescrizione(), PdfFontFactory.PDF_fPiccolo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(col2); this.pdfcorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk( rowArticolo.getTipo().getDescrizione() + " - " + rowArticolo.getTipo().getDescrizione(), PdfFontFactory.PDF_fPiccolo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(col3); this.pdfcorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(rowArticolo.getScaffale(), PdfFontFactory.PDF_fPiccolo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setColspan(col4); this.pdfcorpo.addCell(cell); cell = new Cell(); cell.addElement(new Chunk(nf0.format(rowArticolo.getQuantita()), PdfFontFactory.PDF_fPiccolo)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setColspan(col5); this.pdfcorpo.addCell(cell); cell = new Cell(); if (rowArticolo.getFlgNoleggio() == 1L) { cell.addElement(new Chunk("Nol.: " + getNf().format(rowArticolo.getPrezzoNoleggioIva()), PdfFontFactory.PDF_fPiccolo)); } else if (rowArticolo.getFlgNoleggio() == 2L) { cell.addElement(new Chunk("Nol.: " + getNf().format(rowArticolo.getPrezzoNoleggioIva()), PdfFontFactory.PDF_fPiccolo)); cell.addElement(new Chunk("\nVend.:" + getNf().format(rowArticolo.getPrezzoBaseIva()), PdfFontFactory.PDF_fPiccolo)); } else { cell.addElement(new Chunk(getNf().format(rowArticolo.getPrezzoBaseIva()), PdfFontFactory.PDF_fPiccolo)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setColspan(col6); this.pdfcorpo.addCell(cell); } this.document.add((Element)this.pdfcorpo); this.document.close(); this.document = null; } catch (Exception e) { e.printStackTrace(); } return ba; } public static final String aggiustaStringaNumero(String numero, boolean isLocale) { if (isLocale) { if (numero.indexOf(".") > 0) numero = numero.replace(".", ""); if (numero.indexOf(",") > 0) numero = numero.replace(",", "."); } else if (numero.indexOf(",") > 0) { numero = numero.replace(",", ""); } return numero; } public static final synchronized ResParm aggiornaListino(ApplParmFull apFull, String filename) { String TAG_THREAD_MSG = "aggiorna LISTINO "; Timer timer = new Timer(); timer.start(); StatusMsg.updateMsgByTag(apFull, "aggiorna LISTINO ", "...inizio ..."); ResParm rp = new ResParm(true); String testata = "Cod.Art."; long totRighe = 0L; int se1 = 10; int se2 = 100; long articoliTrovati = 0L, articoliAggiornati = 0L, articoliNonTrovati = 0L; boolean isLocale = apFull.getParm("DOCBASE").getTesto().contains("acolzi"); System.out.println("aggiornaListino: islocale: " + isLocale); try { Workbook wb = null; wb = Workbook.getWorkbook(new File(filename)); Sheet sheet = wb.getSheet(0); int numero_righe_vuote = 0; int i = 1; while (numero_righe_vuote < 10) { jxl.Cell cellCodice = null; try { cellCodice = sheet.getCell(0, i); } catch (Exception e) {} if (cellCodice != null) { jxl.Cell cellPrezzoAcquisto = sheet.getCell(4, i); jxl.Cell cellPrezzoVendita = sheet.getCell(5, i); String s = cellCodice.getContents(); s = s.trim(); if (s.endsWith(",00")) s = s.substring(0, s.length() - 3); if (!s.isEmpty()) { numero_righe_vuote = 0; Articolo articolo = new Articolo(apFull); articolo.findByCodiceFornitoreSerie(s, ""); if (articolo.getDBState() == 1) { articoliTrovati++; String pa = cellPrezzoAcquisto.getContents().trim(); NumberFormulaCell cell = (NumberFormulaCell)cellPrezzoAcquisto; double paValue = cell.getValue(); pa = String.valueOf(paValue); String paDB = String.valueOf(articolo.getCostoNetto()); if (!pa.isEmpty() && !paDB.equals(pa)) { articolo.setCostoNetto(paValue); articolo.superSave(); } String pv = cellPrezzoVendita.getContents().trim(); NumberCell cellPV = (NumberCell)cellPrezzoVendita; double pvValue = cellPV.getValue(); pv = String.valueOf(pvValue); String pvDB = String.valueOf(articolo.getPrezzoBase()); ListinoArticolo la = articolo.getListinoArticoloBase(); if (!pv.isEmpty()) { if (!pvDB.equals(pv)) la.setPrezzoLA(pvValue); if (!pvDB.equals(pv) || !paDB.equals(pa)) { articoliAggiornati++; la.save(); } } } else { articoliNonTrovati++; } } else { numero_righe_vuote++; } StatusMsg.updateMsgByTag(apFull, "aggiorna LISTINO ", "Controllo Listino in corso: righe processate: " + i + " articoli aggiornati: " + articoliAggiornati + " TROVATI: " + articoliTrovati + " NON TROVATI: " + articoliNonTrovati); i++; if (i == 528) System.out.println("pioooo"); if (se1 > 0 && i % se1 == 0) System.out.print("."); if (se2 > 0 && i % se2 == 0) System.out.println(i); continue; } numero_righe_vuote++; } System.out.println("Fine"); String str = "Articoli trovati: " + articoliTrovati + "
articoli NON trovati: " + articoliNonTrovati + "
articoli aggiornati: " + articoliAggiornati; totRighe = (long)i; rp.setMsg("Import listino xls eseguito con successo.
" + str); } catch (Exception e) { e.printStackTrace(); } timer.stop(); StatusMsg.updateMsgByTag(apFull, "aggiorna LISTINO ", "Import listino xls eseguito con successo.Righe processate: " + totRighe + " durata: " + timer.getDurataSec() + " sec."); StatusMsg.deleteMsgByTag(apFull, "aggiorna LISTINO "); String msg = "Articoli trovati: " + articoliTrovati + "
articoli NON trovati: " + articoliNonTrovati + "
articoli aggiornati: " + articoliAggiornati; return rp; } public static final synchronized ResParm confrontaListinoXls(ApplParmFull apFull, String filename) { String TAG_THREAD_MSG = "CONFRONTA LISTINO "; Timer timer = new Timer(); timer.start(); StatusMsg.updateMsgByTag(apFull, "CONFRONTA LISTINO ", "...inizio ..."); ResParm rp = new ResParm(true); boolean debug = false; String testata = "Cod.Art."; long totRighe = 0L; int i = 0; int se1 = 10; int se2 = 100; String codiceFornitore = ""; String articoloTrovato = ""; boolean isLocale = apFull.getParm("DOCBASE").getTesto().contains("acolzi"); System.out.println("confrontaListinoXls: islocale: " + isLocale); try { Workbook wb = null; WritableWorkbook copy = null; WritableFont arial12font = new WritableFont(WritableFont.ARIAL, 12); arial12font.setColour(Colour.WHITE); WritableFont arial12fontBlack = new WritableFont(WritableFont.ARIAL, 12); WritableCellFormat arial12dgreen = new WritableCellFormat(arial12font); WritableCellFormat arial12green = new WritableCellFormat(arial12fontBlack); WritableCellFormat arial12orange = new WritableCellFormat(arial12font); WritableCellFormat arial12red = new WritableCellFormat(arial12font); WritableCellFormat arial12Normale = new WritableCellFormat(arial12fontBlack); arial12dgreen.setBackground(Colour.DARK_GREEN); arial12green.setBackground(Colour.LIGHT_GREEN); arial12orange.setBackground(Colour.ORANGE); arial12red.setBackground(Colour.DARK_RED); wb = Workbook.getWorkbook(new File(filename)); Articolo articolo = new Articolo(apFull); copy = Workbook.createWorkbook(new File( articolo.getDocBase() + articolo.getDocBase() + "controllo_listino_" + articolo.getParm("PATH_TMP").getTesto() + ".xls"), wb); WritableSheet sheet = copy.getSheet(0); int numero_righe_vuote = 0, numArticoliTrovati = 0, numArticoliNonTrovati = 0; i = 1; int colCodice = 0, colPrezzoAcquisto = 4, colPrezzoVendita = 5, colPrezzoAcquistoDB = 6, colRicaricoDb = 7; int colPrezzoVenditaDb = 8, colVenditaNuova = 9, colVisibile = 10, colFamiglia = 11, colSottofamiglia = 12; int colCodiceTF = 13; while (numero_righe_vuote < 10) { WritableCell cellCodice = sheet.getWritableCell(colCodice, i); WritableCell cellPrezzoAcquisto = sheet.getWritableCell(colPrezzoAcquisto, i); WritableCell cellPrezzoVendita = sheet.getWritableCell(colPrezzoVendita, i); WritableCell cellPrezzoAcquistoDB = sheet.getWritableCell(colPrezzoAcquistoDB, i); WritableCell cellRicaricoDB = sheet.getWritableCell(colRicaricoDb, i); WritableCell cellPrezzoVenditaDB = sheet.getWritableCell(colPrezzoVenditaDb, i); WritableCell cellVenditaNuova = sheet.getWritableCell(colVenditaNuova, i); WritableCell cellVisibile = sheet.getWritableCell(colVisibile, i); WritableCell cellFamiglia = sheet.getWritableCell(colFamiglia, i); WritableCell cellSottofamiglia = sheet.getWritableCell(colSottofamiglia, i); WritableCell cellCodiceTF = sheet.getWritableCell(colCodiceTF, i); Label label = new Label(4, i, ""); String s = cellCodice.getContents(); s = s.trim(); if (!s.isEmpty()) { numero_righe_vuote = 0; System.out.println("" + i + ": " + i); articolo.findByCodiceFornitoreSerie(s, ""); codiceFornitore = s; articoloTrovato = ""; if (articolo.getDBState() == 1) { Number number; numArticoliTrovati++; articoloTrovato = articolo.getCodice() + " - " + articolo.getCodice(); if (articolo.getFlgEscludiWeb() == 0L) { label = new Label(colVisibile, i, "VISIBILE", (CellFormat)arial12dgreen); sheet.addCell((WritableCell)label); } else if (articolo.getFlgEscludiWeb() == 2L) { label = new Label(colVisibile, i, "SOSPESO", (CellFormat)arial12orange); sheet.addCell((WritableCell)label); } else if (articolo.getFlgEscludiWeb() == 1L) { label = new Label(colVisibile, i, "NON VISIBILE", (CellFormat)arial12orange); sheet.addCell((WritableCell)label); } String pa = cellPrezzoAcquisto.getContents().trim(); NumberFormulaCell cell = (NumberFormulaCell)cellPrezzoAcquisto; double paValue = cell.getValue(); pa = String.valueOf(paValue); if (debug) System.out.println("CONFRONTA LISTINO pa:" + pa + " pavalue: " + paValue); String tt = cellPrezzoVendita.getContents().trim(); String paDB = String.valueOf(articolo.getCostoNetto()); if (paDB.equals(pa)) { number = new Number(colPrezzoAcquistoDB, i, articolo.getCostoNetto(), (CellFormat)arial12dgreen); } else { number = new Number(colPrezzoAcquistoDB, i, articolo.getCostoNetto(), (CellFormat)arial12orange); } sheet.addCell((WritableCell)number); String pv = cellPrezzoVendita.getContents().trim(); if (debug) System.out.println("CONFRONTA LISTINO pv:" + pv); String pvDB = String.valueOf(articolo.getPrezzoBase()); if (pvDB.equals(pv)) { number = new Number(colPrezzoVenditaDb, i, articolo.getPrezzoBase(), (CellFormat)arial12dgreen); } else { number = new Number(colPrezzoVenditaDb, i, articolo.getPrezzoBase(), (CellFormat)arial12orange); } sheet.addCell((WritableCell)number); label = new Label(colRicaricoDb, i, "" + articolo.getPercRicarico() + " (" + articolo.getPercRicarico() + ")", (CellFormat)arial12Normale); sheet.addCell((WritableCell)label); pa = aggiustaStringaNumero(pa, isLocale); try { if (debug) System.out.println("CONFRONTA LISTINO ricaricoeffettivodacostonetto:" + articolo.getRicaricoEffettivoDaCostoNetto() + " pavalue: " + paValue); Double paD = paValue; DoubleOperator dop = new DoubleOperator(articolo.getRicaricoEffettivoDaCostoNetto()); dop.add(100); dop.multiply(paD.doubleValue()); dop.divide(100.0F); dop.setScale(2, 5); number = new Number(colVenditaNuova, i, dop.getResult(), (CellFormat)arial12Normale); sheet.addCell((WritableCell)number); } catch (Exception e) { if (debug) { System.out.println("CONFRONTA LISTINO eccezione:"); e.printStackTrace(); } label = new Label(colVenditaNuova, i, "ERR. NUMERO " + pa, (CellFormat)arial12red); sheet.addCell((WritableCell)label); } label = new Label(colFamiglia, i, articolo.getTipo().getTipoPadre().getDescrizione(), (CellFormat)arial12Normale); sheet.addCell((WritableCell)label); label = new Label(colSottofamiglia, i, articolo.getTipo().getDescrizione(), (CellFormat)arial12Normale); sheet.addCell((WritableCell)label); label = new Label(colCodiceTF, i, articolo.getCodice(), (CellFormat)arial12Normale); sheet.addCell((WritableCell)label); } else { numArticoliNonTrovati++; label = new Label(colVisibile, i, "NON TROVATO", (CellFormat)arial12red); sheet.addCell((WritableCell)label); } } else { numero_righe_vuote++; } StatusMsg.updateMsgByTag(apFull, "CONFRONTA LISTINO ", " righe processate: " + i + " trovati: " + numArticoliTrovati + " NON Trovati: " + numArticoliNonTrovati); i++; if (se1 > 0 && i % se1 == 0) System.out.print("."); if (se2 > 0 && i % se2 == 0) System.out.println(i); } System.out.println("Fine"); totRighe = (long)i; rp.setMsg("Import listino xls e confronto eseguito con successo: Clicca qui per aprire il file"); copy.write(); copy.close(); } catch (Exception e) { System.out.println("ERRORE!!! riga " + i + " cod. fornitore: " + codiceFornitore + " articolo: " + articoloTrovato); rp.setStatus(false); rp.setMsg(e); } timer.stop(); StatusMsg.updateMsgByTag(apFull, "CONFRONTA LISTINO ", "Controllo listino xls eseguito con successo. Righe processate: " + totRighe + " durata: " + timer.getDurataSec() + " sec."); StatusMsg.deleteMsgByTag(apFull, "CONFRONTA LISTINO "); System.out.println("DURATA: " + timer.getDurataSec() + " sec. Risultato CONFRONTO:\n" + rp.getMsg() + "\n\nCONTROLLO LISTINO concluso\n****************"); return rp; } public double getPrezzoPubblicoIvaOrd() { if (getFlgNoleggio() == 1L) return getPrezzoNoleggioIva(); return getPrezzoPubblicoIva(); } public void setPrezzoPubblicoIvaOrd(double prezzoPubblicoIvaOrd) { this.prezzoPubblicoIvaOrd = prezzoPubblicoIvaOrd; } private String getRecordCsvMultigestionale() { StringBuffer temp = new StringBuffer(); String sep = ";"; String nome = getMarca().getDescrizione() + " " + getMarca().getDescrizione(); if (!getDescTxtLangScript("nomeMarketplace", "it").isEmpty()) nome = getDescTxtLangScript("nomeMarketplace", "it").replaceAll("€", "€").replace(";", " "); String descrizioneSubito = getDescTxtLangScript("descrizioneMarketplace", "it"); if (descrizioneSubito.isEmpty()) descrizioneSubito = getDescTxtLangScript("descrizioneCommerciale", "it"); if (descrizioneSubito.isEmpty()) descrizioneSubito = nome; descrizioneSubito = convertHtmlToString(descrizioneSubito); descrizioneSubito = descrizioneSubito.replace("\n", "
"); descrizioneSubito = descrizioneSubito.replace(";", " "); temp.append(getCodice()); temp.append(sep); temp.append(nome); temp.append(sep); temp.append(descrizioneSubito); temp.append(sep); long prPubblicoConIva = Math.round(getPrezzoPubblicoIva()); if ((double)prPubblicoConIva != getPrezzoPubblicoIva()) System.out.println("getRecordCsvMultigestionale: prezzo arrotondato. " + getPrezzoPubblicoIva() + " --> " + prPubblicoConIva); temp.append(prPubblicoConIva); temp.append(".00"); temp.append(sep); temp.append(getNf0().format(getQuantita())); temp.append(sep); String imageName = getPathImg() + getPathImg(); String imageFileName = getDocBase() + getDocBase(); if (new File(imageFileName).exists()) { temp.append(getWwwAddressParm() + getWwwAddressParm()); } else { temp.append(" "); } temp.append(sep); boolean primaImmagine = true; for (int i = 2; i < 20; i++) { imageName = getPathImg() + getPathImg(); imageFileName = getDocBase() + getDocBase(); if (new File(imageFileName).exists()) { if (primaImmagine) { primaImmagine = false; } else { temp.append(","); } temp.append(getWwwAddressParm() + getWwwAddressParm()); } } if (primaImmagine) temp.append(" "); temp.append(sep); temp.append(getCodiceEan()); temp.append(sep); temp.append(""); temp.append(sep); temp.append(getMarca().getDescrizione()); return temp.toString(); } public ResParm creaFileCvsSubito_it(ArticoloCR CR) { int numRecord = 0; ResParm rp = new ResParm(true); try { String fileCsv = "exportSubito" + CR.getId_users() + "_" + getNow().getTime() + ".csv"; CR.setFileName(fileCsv); String filename = getDocBase() + getDocBase() + getParm("PATH_TMP").getTesto(); new File(filename).delete(); FileWr outFile = new FileWr(filename, "UTF-8", false); String intestazione = "id;title;description;price;quantity;image_link;additional_image_link;gtin;sku_code;brand"; CR.setFlgSubito(1L); Vectumerator vec = findByCR(CR, 0, 0); String s1 = intestazione; outFile.writeLine(s1); Articolo currentArticolo = null; double qtaVenduta = 0.0D; long numVendite = 0L; while (vec.hasMoreElements()) { Articolo rowbean = (Articolo)vec.nextElement(); if (rowbean.getPrezzoPubblico() > 0.0D) { s1 = rowbean.getRecordCsvMultigestionale(); outFile.writeLine(s1); } } outFile.closeFile(); rp.setStatus(true); rp.setMsg("Generazione file report vendite avvenuta con successo.
Numero Record: " + numRecord); } catch (Exception e) { handleDebug(e); rp.setException(e); rp.setStatus(false); } return rp; } public long getFlgSubito() { return this.flgSubito; } public void setFlgSubito(long flgSubito) { this.flgSubito = flgSubito; } public ResParm cambiaFlg(String l_flg) { ResParm rp = new ResParm(true); if (getId_tipo() > 0L) { if (l_flg.equals("flgNascondi")) { setFlgNascondi((getFlgNascondi() == 1L) ? 0L : 1L); } else if (l_flg.equals("flgEbay")) { setFlgEbay((getFlgEbay() == 1L) ? 0L : 1L); } else if (l_flg.equals("flgAmazon")) { setFlgAmazon((getFlgAmazon() == 0L) ? 1L : ((getFlgAmazon() == 1L) ? 2L : 0L)); } else if (l_flg.equals("flgSubito")) { setFlgSubito((getFlgSubito() == 1L) ? 0L : 1L); } else if (l_flg.equals("flgRateale0")) { setFlgRateale0((getFlgRateale0() == 1L) ? 0L : 1L); } else if (l_flg.equals("flgGoogle")) { setFlgGoogle((getFlgGoogle() + 1L) % 3L); } else if (l_flg.equals("flgTrovaprezzi")) { setFlgTrovaprezzi((getFlgTrovaprezzi() == 1L) ? 0L : 1L); } else if (l_flg.equals("flgIdealo")) { setFlgIdealo((getFlgIdealo() == 1L) ? 0L : 1L); } else if (l_flg.equals("flgEbay")) { setFlgEbay((getFlgEbay() == 1L) ? 0L : 1L); } else if (l_flg.equals("flgEscludiWebArt")) { setFlgEscludiWebArt((getFlgEscludiWebArt() == 0L) ? 1L : ((getFlgEscludiWebArt() == 1L) ? 2L : 0L)); } else if (l_flg.equals("flgModImportazione")) { setFlgModImportazione(9L); } rp = save(); } else { rp.setStatus(false); rp.setMsg("Tipo non trovato!"); } return rp; } public String getTagArticolo() { return (this.tagArticolo == null) ? "" : this.tagArticolo.trim(); } public void setTagArticolo(String tag) { this.tagArticolo = tag; } public double getPercScontoRispettoAOfferta() { if (!isOffertaValida() || getPrezzoBaseIva() == 0.0D) return 0.0D; DoubleOperator dop = new DoubleOperator(getPriceWVat()); dop.setScale(2, 5); dop.divide(getPrezzoBaseIva()); dop.multiply(100); dop.subtract(100); return dop.getResult(); } public String getCodicePromozioneA() { return (this.codicePromozioneA == null) ? "" : this.codicePromozioneA.trim(); } public void setCodicePromozioneA(String codicePromozioneA) { this.codicePromozioneA = codicePromozioneA; } public double getStreetPriceIva() { return DBAdapter.conIva(this.streetPrice, (double)getIva().getAliquota()); } public double getCostoPrecedente() { return this.costoPrecedente; } public double getCostoPrecedenteiva() { return DBAdapter.conIva(getCostoPrecedente(), (double)getIva().getAliquota()); } public void setCostoPrecedente(double costoPrecedente) { this.costoPrecedente = costoPrecedente; } public double getImponibilePrecedente() { return this.imponibilePrecedente; } public double getImponibilePrecedenteIva() { return DBAdapter.conIva(getImponibilePrecedente(), (double)getIva().getAliquota()); } public void setImponibilePrecedente(double imponibilePrecedente) { this.imponibilePrecedente = imponibilePrecedente; } public String getCodicePromozione() { return getCodicePromozioneA(); } public ByteArrayOutputStream creaRegistroDaVidimare(RegistroUsato ru) { ByteArrayOutputStream ba = new ByteArrayOutputStream(); int pageNumber = 1; long l_id = 0L; ResParm rp = new ResParm(false, "Attenzione! Creazione file registro usato fallita miseramente!"); ru.setResParm(rp); try { this.document = new Document(PageSize.A4, 20.0F, 20.0F, 20.0F, 10.0F); this.writer = PdfWriter.getInstance(this.document, ba); this.document.open(); int cellLeading = 8; float imgLogoWidth = 100.0F; Image imgLogo = Image.getInstance(getDocBase() + getDocBase()); if (imgLogoWidth > 0.0F) imgLogo.scaleToFit(imgLogoWidth, imgLogoWidth); imgLogo.scaleToFit(imgLogoWidth, imgLogoWidth); Cell cell1 = new Cell(); cell1.add(new Chunk(imgLogo, 0.0F, 0.0F)); String header = getParm("HEAD_DOC1").getTesto(); cell1.add(new Chunk("\n" + header, PDF_fPiccolissimo)); cell1.setLeading(10.0F); cell1.setColspan(8); cell1.setBorder(0); Cell cell2 = new Cell(); header = getParm("HEAD_DOC2").getTesto(); cell2.add(new Chunk(header, PDF_fPiccolissimo)); cell2.setLeading(10.0F); cell2.setBorder(0); cell2.setColspan(7); Cell cellSpazio = new Cell(); cellSpazio.add(new Chunk("", PDF_fPiccolissimo)); cellSpazio.setLeading(10.0F); cellSpazio.setBorder(0); cellSpazio.setColspan(20); for (int i = (int)ru.getPaginaInizio(); (long)i < ru.getPaginaFine(); i += 2) { this.pdfcorpo = new Table(20); this.pdfcorpo.setWidth(100.0F); this.pdfcorpo.setPadding(2.0F); this.pdfcorpo.setSpacing(0.0F); this.pdfcorpo.setWidths(colWidthsRighe20); this.pdfcorpo.setBorder(0); this.pdfcorpo.addCell(cell1); this.pdfcorpo.addCell(cell2); Cell cell = new Cell(); cell.add(new Chunk("" + i, PDF_fMedioB)); cell.setLeading(10.0F); cell.setBorder(0); cell.setHorizontalAlignment(2); cell.setColspan(5); this.pdfcorpo.addCell(cell); for (int j = 0; j < 65; j++) this.pdfcorpo.addCell(cellSpazio); this.pdfcorpo.addCell(cell1); this.pdfcorpo.addCell(cell2); cell = new Cell(); cell.add(new Chunk("" + i + 1, PDF_fMedioB)); cell.setLeading(10.0F); cell.setBorder(0); cell.setHorizontalAlignment(2); cell.setColspan(5); this.pdfcorpo.addCell(cell); this.document.add((Element)this.pdfcorpo); this.document.newPage(); } this.document.close(); this.document = null; String nomeFile = "regusato_" + Calendar.getInstance().getTimeInMillis() + ".pdf"; createFileFromByteArray(ba, nomeFile); System.out.println("Creato file registro usato " + nomeFile); ru.setFileName(nomeFile); ru.setResParm(new ResParm(true, "File registro usato da vidimare creato correttamente")); } catch (Exception e) { e.printStackTrace(); } return ba; } public boolean isPrezzoBarratoValido() { if (getPrezzoIvatoBarrato() > 0.0D && getPrezzoIvatoBarrato() > getPrezzoPubblicoIva(null)) return true; return false; } public boolean isPrezzoVenditaSalito() { if (getImponibilePrecedente() > 0.0D && getImponibilePrecedente() < getPrezzoBase()) return true; return false; } public boolean isPrezzoVenditaSceso() { if (getImponibilePrecedente() > 0.0D && getImponibilePrecedente() > getPrezzoBase()) return true; return false; } public boolean isCostoAcquistoSalito() { if (getCostoPrecedente() > 0.0D && getCostoNuovo() > 0.0D && getCostoPrecedente() < getCostoNuovo()) return true; return false; } public boolean isCostoAcquistoSceso() { if (getCostoPrecedente() > 0.0D && getCostoNuovo() > 0.0D && getCostoPrecedente() > getCostoNuovo()) return true; return false; } public String getCCLinkDettaglioCanonical(String lang) { ArticoloCR CR = new ArticoloCR(); CR.setLang(lang); return getWwwAddressParm() + getWwwAddressParm(); } public String getCCLinkDettaglio() { ArticoloCR CR = new ArticoloCR(getApFull()); if (getId_articoloTaglia() > 0L) { CR.setId_articoloTaglia(getId_articoloTaglia()); CR.setId_taglia(getArticoloTaglia().getId_taglia()); if (getId_articoloVariante() > 0L) { if (getId_articoloVarianteKit() > 0L) { CR.setId_articoloVarianteKit(getId_articoloVarianteKit()); return getCCLinkDettaglioTK(CR); } return getCCLinkDettaglioT(CR); } return getCCLinkDettaglioT(CR); } return getCCLinkDettaglioA(CR); } public String getCCLinkDettaglioA(ArticoloCR CR) { String lang = (CR == null || CR.getLang().isEmpty()) ? "it" : CR.getLang(); StringBuilder sb = new StringBuilder(); StringBuilder sbCmd = new StringBuilder(); if (getId_articoloVariante() == 0L) { sb.append(convertStringToLink(getDescrizioneNomeUrl()).toLowerCase()); } else { sb.append(convertStringToLink(getArticoloVariante().getDescrizioneNomeUrl()).toLowerCase()); } sb.append("-"); if (!getTipo().getDescrizioneLink(lang).isEmpty()) { sb.append(getTipo().getDescrizioneLink(lang).replace(" ", "-").toLowerCase()); } else { sb.append(getTipo().getDescrizioneCompletaMinus(lang).toLowerCase()); } sb = new StringBuilder(eliminaDoppioniInStringa(sb.toString().toLowerCase(), "-", 1, false)); sbCmd.append("+"); sbCmd.append("d"); sbCmd.append("-"); sbCmd.append(getId_articolo()); sbCmd.append("-"); sbCmd.append((getId_articoloVariante() == 0L) ? "" : getId_articoloVariante()); sbCmd.append("-"); if (CR != null) sbCmd.append(CR.getSearchTxtWeb()); sbCmd.append("-"); sbCmd.append(lang); sbCmd.append(".html"); if (getParm("CC_LINK_WEB_CON_MARCA").isTrue()) if (sb.toString().toLowerCase().indexOf(getMarca().getDescrizione().toLowerCase()) < 0) sb.insert(0, getMarca().getDescrizione().toLowerCase() + "-"); long realMaxlinkLength = 80L - (long)getWwwAddressParm().length(); if ((long)(sb.length() + sbCmd.length()) > realMaxlinkLength) { if (realMaxlinkLength - (long)sbCmd.length() + 1L > 0L) { String pre = sb.substring(0, (int)(realMaxlinkLength - (long)sbCmd.length() + 1L)); if (pre.lastIndexOf("-") > 0) pre = pre.substring(0, pre.lastIndexOf("-")); return pre.toLowerCase() + pre.toLowerCase(); } return sb.toString().toLowerCase() + sb.toString().toLowerCase(); } return sb.toString().toLowerCase() + sb.toString().toLowerCase(); } public static final String getCCSeoMinimalTemplate(String template, long maxSize, long parmSize) { if ((long)template.length() + parmSize - 1L <= maxSize) return template; StringTokenizer st = new StringTokenizer(template, "."); LinkedHashSet tokenPreTag = new LinkedHashSet<>(); LinkedHashSet tokenPostTag = new LinkedHashSet<>(); String tokenTag = ""; boolean tagFound = false; while (st.hasMoreTokens()) { String token = st.nextToken(); if (token.indexOf("#") >= 0) { tokenTag = token; tagFound = true; continue; } if (tagFound) { tokenPostTag.add(token); continue; } tokenPreTag.add(token); } StringBuilder sbResult = new StringBuilder(); boolean maxSizeSuperata = false; for (String token : tokenPreTag) { if ((long)(token.length() + tokenTag.length() + 2) + parmSize <= maxSize) { sbResult.append(token); sbResult.append(". "); continue; } maxSizeSuperata = true; break; } if (!maxSizeSuperata) { sbResult.append(tokenTag); sbResult.append(". "); for (String token : tokenPostTag) { if ((long)(token.length() + sbResult.length() + 2) + parmSize <= maxSize) { sbResult.append(token); sbResult.append(". "); continue; } maxSizeSuperata = true; break; } } return sbResult.toString().trim(); } public String getCCLinkDettaglioFullMessaging(ArticoloCR CR) { return (Attivita.getDefaultInstance(getApFull()).getWwwAddress() + Attivita.getDefaultInstance(getApFull()).getWwwAddress()).replace("+", "%2B"); } public String getTFLinkDettaglio2(ArticoloCR CR) { String lang = (CR == null || CR.getLang().isEmpty()) ? "it" : CR.getLang(); StringBuilder sb = new StringBuilder(); sb.append(convertStringToLink(getMarca().getDescrizione())); sb.append("-"); sb.append(convertStringToLink(getDescrizioneNomeUrl())); sb.append("-"); sb.append(getTipo().getDescrizioneCompletaPlus(lang)); sb.append("-"); if (CR == null) { sb.append("articolo"); } else { sb.append(translate("articolo", lang)); } sb.append("-"); sb.append(getId_articolo()); sb.append("-"); sb.append((getId_articoloVariante() == 0L) ? "" : getId_articoloVariante()); sb.append("-"); sb.append(lang); sb.append(".html"); return sb.toString(); } public String getCCLinkDettaglioT(ArticoloCR CR) { StringBuilder sb = new StringBuilder(); sb.append(convertStringToLink(getDescrizioneNomeUrl())); sb.append("-"); sb.append(getTipo().getDescrizioneCompletaMinus(CR.getLang())); sb.append("+"); sb.append("dt"); sb.append("-"); sb.append(getId_articolo()); sb.append("-"); sb.append((getId_articoloVariante() == 0L) ? "" : getId_articoloVariante()); sb.append("-"); sb.append((CR.getId_taglia() == 0L) ? "" : CR.getId_taglia()); sb.append("-"); sb.append(CR.getSearchTxtWeb()); sb.append("-"); sb.append(CR.getLang()); sb.append(".html"); return sb.toString().toLowerCase(); } public String getCCLinkDettaglioTK(ArticoloCR CR) { StringBuilder sb = new StringBuilder(); sb.append(convertStringToLink(getDescrizioneNomeUrl())); sb.append("-"); sb.append(getTipo().getDescrizioneCompletaMinus(CR.getLang())); sb.append("+"); sb.append("dtk"); sb.append("-"); sb.append(getId_articolo()); sb.append("-"); sb.append((getId_articoloVariante() == 0L) ? "" : getId_articoloVariante()); sb.append("-"); sb.append((CR.getId_taglia() == 0L) ? "" : CR.getId_taglia()); sb.append("-"); sb.append((getId_articoloVarianteKit() == 0L) ? "" : getId_articoloVarianteKit()); sb.append("-"); sb.append(CR.getSearchTxtWeb()); sb.append("-"); sb.append(CR.getLang()); sb.append(".html"); return sb.toString().toLowerCase(); } public String getCCLinkDettaglioKitTK_XXXXX(ArticoloCR CR) { StringBuilder sb = new StringBuilder(); sb.append(convertStringToLink(getDescrizioneNomeUrl())); sb.append("-"); sb.append(getTipo().getDescrizioneCompletaPlus(CR.getLang())); sb.append("+"); sb.append("dktk"); sb.append("-"); sb.append(getId_articolo()); sb.append("-"); sb.append((getId_articoloVariante() == 0L) ? "" : getId_articoloVariante()); sb.append("-"); sb.append((CR.getId_taglia() == 0L) ? "" : CR.getId_taglia()); sb.append("-"); sb.append((getId_articoloVarianteKit() == 0L) ? "" : getId_articoloVarianteKit()); sb.append("-"); sb.append(CR.getSearchTxtWeb()); sb.append("-"); sb.append(CR.getLang()); sb.append(".html"); return sb.toString(); } public String getCCLinkEbay() { if (getEbayOfferId().isEmpty() || getEbayItemId().isEmpty()) return ""; return "https://www.ebay.it/itm/" + getEbayItemId(); } public String getCCLinkAddItemRow(ArticoloCR CR) { StringBuilder sb = new StringBuilder(); sb.append("+"); sb.append("addItemRow"); sb.append("-"); sb.append(getId_articolo()); sb.append("-"); sb.append("1"); sb.append("-"); sb.append(CR.getFlgTipoVisualizzazione()); sb.append("-"); sb.append(CR.getId_tipoSel()); sb.append("-"); sb.append(CR.getFiltri_id()); sb.append("-"); sb.append(CR.getSearchTxtWeb()); sb.append("-"); sb.append(CR.getFlgOrderBy()); sb.append("-"); sb.append(CR.getPageNumber()); sb.append("-"); sb.append(CR.getPageRow()); sb.append(".html"); return sb.toString(); } public ResParm creaFileXmlIdealo(ArticoloCR CR) { ResParm rp = creaFileXmlGoogle(CR, false, true); String temp = (String)rp.getReturnObj(); String fileXml = getDocBase() + getDocBase() + this.apFull.getParm("PATH_TMP").getTesto(); String idealoFile = "_idealo/idealo-f3.xml"; String idealoPermanentFileName = getDocBase() + getDocBase(); try { DBAdapter.copyFile(fileXml, idealoPermanentFileName); rp.setMsg(rp.getMsg() + "
Copia su file IDEALO XML tmp " + rp.getMsg() + " avvenuta con successo."); rp.setReturnObj(idealoFile); } catch (Exception e) { rp.setStatus(false); rp.setException(e); } return rp; } public ResParm creaFileTxtMicrosoft(ArticoloCR CR) { ResParm rp = new ResParm(true); String TAG_THREAD_MSG = "MICROSOFT MERCHANT CREAZIONE FILE "; try { StatusMsg.updateMsgByTag(getApFull(), TAG_THREAD_MSG, "creazione file txt...."); boolean soloLink = false; int numRecord = 0; String tagIdealo = ""; Attivita attivita = Attivita.getDefaultInstance(getApFull()); String msFile = "ms_" + System.currentTimeMillis() + ".xml"; String filename = getDocBase() + getDocBase() + getParm("PATH_TMP").getTesto(); String msPermanentFileName = getDocBase() + "_feed/" + getDocBase(); File xmlFile = new File(filename); String theDir = xmlFile.getAbsolutePath().substring(0, xmlFile.getAbsolutePath().lastIndexOf(File.separator) + 1); File theDirFile = new File(theDir); if (!theDirFile.exists()) theDirFile.mkdirs(); new File(filename).delete(); File theDirFileMs = new File(getDocBase() + "_feed/"); if (!theDirFileMs.exists()) theDirFileMs.mkdirs(); org.w3c.dom.Element e = null; CR.setFlgGoogle(1L); CR.setFlgReadyForWeb(1L); CR.setFlgEscludiWeb(0L); if (CR.getPrezzoDa() == 0.0D) CR.setPrezzoDa(attivita.getPGooglePrezzoPubblicoMinimoXExport()); if (CR.getQtaDa() == 0L && attivita.getPGoogleQtaMinimaXExport() > 0L) { CR.setQtaDa(attivita.getPGoogleQtaMinimaXExport()); CR.setFlgQta(1L); } Vectumerator vec = findByCR(CR, 0, 0); String title = getParm("TITLE").getTesto(); String site = getParm("P_WWW_ADDRESS").getTesto(); String lang = CR.getLang(); if (lang.isEmpty()) { lang = "it"; CR.setLang(lang); } NumberFormat nf2 = NumberFormat.getInstance(Locale.US); nf2.setMaximumFractionDigits(2); nf2.setMinimumFractionDigits(2); String wwwSite = getWwwAddressParm(); FileWr fw = new FileWr(msPermanentFileName); String SEP = "/t"; String intestazione = "id/ttitle/tbrand/tlink/tprice/tdescription/timage_link/tmpn\tgtin/tavailability/tcondition/tproduct_type/tproduct_category/tbingads_grouping\tbingads_label/tcustom_label_0/tcustom_label_1/tcustom_label_2/tcustom_label_3/tcustom_label_4/tbingads_redirect/tsale_price/tsale_price_effective_date"; fw.writeLine(intestazione); int currentRecord = 0; while (vec.hasMoreElements()) { currentRecord++; StatusMsg.updateMsgByTag(getApFull(), TAG_THREAD_MSG, "creazione file txt...." + currentRecord + " su " + vec.getTotNumberOfRecords()); Articolo rowbean = (Articolo)vec.nextElement(); if (rowbean.getFlgUsaVarianti() == 0L) { numRecord++; fw.writeLine(rowbean.getRecordMicrosoftMerchant(lang, CR)); boolean bool = false; continue; } ArticoloVarianteCR CRAv = new ArticoloVarianteCR(); CRAv.setId_articolo(rowbean.getId_articolo()); CRAv.setFlgQta(CR.getFlgQta()); CRAv.setQtaDa(CR.getQtaDa()); CRAv.setQtaA(CR.getQtaA()); Vectumerator vecAV = new ArticoloVariante(getApFull()).findByCR(CRAv, 0, 0); while (vecAV.hasMoreElements()) { ArticoloVariante rowAV = (ArticoloVariante)vecAV.nextElement(); numRecord++; } } fw.closeFile(); rp.setStatus(true); rp.setReturnObj(msFile); rp.setMsg("Generazione file MICROSOFT TXT " + msPermanentFileName + " avvenuta con successo.
Numero Record: " + numRecord); } catch (Exception e) { handleDebug(e); rp.setException(e); rp.setStatus(false); } StatusMsg.deleteMsgByTag(getApFull(), TAG_THREAD_MSG); return rp; } public String getCCDataLayerDetail() { return GoogleDataLayerBuilder.getDettaglioProdotto("eec.detail", this); } public String getDispoLevelSchema() { switch (getDispoLevel()) { case 0: return "https://schema.org/OutOfStock"; case 1: return "https://schema.org/LimitedAvailability"; case 2: return "https://schema.org/InStock"; } return ""; } public long getFlgGoogleDB() { return this.flgGoogleDB; } public void setFlgGoogleDB(long flgGoogleDB) { this.flgGoogleDB = flgGoogleDB; } public ArticoloVariante getArticoloVarianteKit() { this.articoloVarianteKit = (ArticoloVariante)getSecondaryObject(this.articoloVarianteKit, ArticoloVariante.class, getId_articoloVarianteKit()); return this.articoloVarianteKit; } public long getId_articoloVarianteKit() { return this.id_articoloVarianteKit; } public void setArticoloVarianteKit(ArticoloVariante articoloVarianteKit) { this.articoloVarianteKit = articoloVarianteKit; } public void setId_articoloVarianteKit(long id_articoloVarianteKit) { this.id_articoloVarianteKit = id_articoloVarianteKit; setArticoloVarianteKit(null); } public long getId_articoloTaglia() { return this.id_articoloTaglia; } public long getCountImportNonTrovato() { return this.countImportNonTrovato; } public void setCountImportNonTrovato(long countImportNonTrovato) { this.countImportNonTrovato = countImportNonTrovato; } public Date getDataUltimoImport() { return this.dataUltimoImport; } public void setDataUltimoImport(Date dataUltimoImport) { this.dataUltimoImport = dataUltimoImport; } public String getCodiciAlternativiLink() { StringBuilder sb = new StringBuilder(); sb.append(""); sb.append(getCodice()); sb.append(" "); Clifor fornitore = new Clifor(this.apFull); Vectumerator vecFor = fornitore.findFornitoriConImportPrefissoCodice(); HashMap hmCodici = new HashMap<>(); while (vecFor.hasMoreElements()) { Clifor row = (Clifor)vecFor.nextElement(); hmCodici.put(row.getImportPrefissoCodice(), row); } StringTokenizer st = new StringTokenizer(getCodiciAlternativi(), ","); try { while (st.hasMoreTokens()) { String token = st.nextToken(); int idx_ = token.indexOf("_"); if (idx_ > 0) { String prefix = token.substring(0, idx_); String codiceFornitore = token.substring(idx_ + 1); if (hmCodici.get(prefix) != null) { fornitore = hmCodici.get(prefix); if (!fornitore.getImportLinkFornitore().isEmpty()) { hmCodici.remove(codiceFornitore); sb.append(""); sb.append(token); sb.append(" "); if (st.hasMoreTokens()) sb.append(","); } } } } String codice = getCodiceEan(); if (codice.isEmpty()) codice = getCodiceProduttore(); if (!codice.isEmpty()) for (Map.Entry me : hmCodici.entrySet()) { fornitore = me.getValue(); if (!fornitore.getImportLinkFornitoreEan().isEmpty()) { sb.append(""); sb.append(me.getKey()); sb.append("_*"); sb.append(codice); sb.append(" "); } } return sb.toString().trim(); } catch (Exception e) { return getCodiciAlternativi(); } } public String getCCMetaDescriptionCalc(String lang) { String modello = getTipo().getMetaDescTemplateLeafWeb(lang); StringBuilder sb = new StringBuilder(); if (!modello.isEmpty()) { String tagDesc = getCCNome(lang).replace("(", "").replace(")", "").replace("\"", """); String offerta = ""; long parmSize = (long)tagDesc.length(); if (isOffertaValida()) { offerta = translate("Articolo in offerta", lang); parmSize = parmSize + (long)offerta.length() + 2L; } modello = getCCSeoMinimalTemplate(modello, 150L, parmSize); sb = new StringBuilder(modello.replace("#", tagDesc)); if (isOffertaValida()) { sb.append(". "); sb.append(translate("Articolo in offerta", lang)); } return sb.toString(); } sb.append(getCCNome(lang)); if ((long)(sb.length() + 1 + getTipo().getDescrizione(lang).length()) <= 150L) { sb.append(" "); sb.append(getTipo().getDescrizione(lang)); } if (!getCodiceProduttore().isEmpty() && (long)(sb.length() + 1 + getCodiceProduttore().length()) <= 150L) { sb.append(" "); sb.append(getCodiceProduttore()); } if (!getCodiceEan().isEmpty() && (long)(sb.length() + 1 + getCodiceEan().length()) <= 150L) { sb.append(" "); sb.append(getCodiceEan()); } StringBuilder sbCAR = new StringBuilder(); Vectumerator vec = getCaratteristicheArticolo(); while (vec.hasMoreElements()) { CaratteristicaArticolo row = (CaratteristicaArticolo)vec.nextElement(); if (sb.toString().toLowerCase().indexOf(row.getVal(lang).toLowerCase()) < 0) { sbCAR.append(row.getVal(lang)); if (vec.hasMoreElements()) sbCAR.append(", "); } } if (sbCAR.length() > 0 && (long)(sb.length() + 1 + sbCAR.length()) <= 150L) { sb.append(" "); sb.append(sbCAR.toString()); } if (isOffertaValida()) { sb.append(" "); sb.append(translate("articolo in offerta", lang)); } String result = sb.toString().replace("(", "").replace(")", "").replace("\"", """); return eliminaDoppioniInStringa(result); } public String getCCSeoTitle(String lang) { if (!getSeoTitle(lang).isEmpty()) return getSeoTitle(lang); return getCCSeoTitleCalc(lang); } public String getCCSeoTitleCalc(String lang) { String descTipo; StringBuilder sb = new StringBuilder(); Attivita attivita = Attivita.getDefaultInstance(getApFull()); sb.append(getCCNome(lang)); if (!getTipo().getDescrizioneSeo(lang).isEmpty()) { descTipo = getTipo().getDescrizioneSeo(lang); } else { descTipo = getTipo().getDescrizioneCompletaSpaces(lang); } int sbLen = sb.length() + descTipo.length(); if ((long)sbLen < 60L) { sb.append(" "); sb.append(descTipo); if ((long)(sb.length() + attivita.getNomeAttivitaSeo().length()) < 60L) { sb.append(" | "); sb.append(Attivita.getDefaultInstance(getApFull()).getNomeAttivitaSeo()); } } else if ((long)sb.length() > 60L) { if (!getCodiceProduttore().isEmpty()) { String title = sb.toString().substring(0, sb.toString().lastIndexOf(" ")).trim(); if ((long)title.length() <= 60L) return title; } sb = new StringBuilder(); if (!getCodiceProduttore().isEmpty()) { sb.append(getMarca().getDescrizione()); sb.append(" "); sb.append(getCodiceProduttore()); } else { sb.append(getCCNome(lang)); } sbLen = sb.length() + descTipo.length(); if ((long)sbLen < 60L) { sb.append(" "); sb.append(descTipo); if ((long)(sb.length() + attivita.getNomeAttivitaSeo().length()) < 60L) { sb.append(" | "); sb.append(Attivita.getDefaultInstance(getApFull()).getNomeAttivitaSeo()); } } } else { return sb.toString(); } return eliminaDoppioniInStringa(sb.toString()); } public String getCCKeyword(String lang) { StringBuilder sb = new StringBuilder(); if (!getCodiceProduttore().isEmpty()) { sb.append(getCodiceProduttore()); sb.append(", "); } sb.append(getDescrizioneCompleta(lang).replace(", ", ".").replace(" ", ", ")); sb.append(", "); sb.append(getTipo().getDescrizioneCompletaKeyword(lang)); if (!getCodiceEan().isEmpty()) { sb.append(", "); sb.append(getCodiceEan()); } String result = sb.toString().replace(" ,", ", ").replace(",,", ", ").replace("/", " "); return convertStringToHtml(eliminaDoppioniInStringa(result, 1, true)); } public Vectumerator findByCRMagazzino(ArticoloCR CR, int pageNumber, int pageRows) { boolean flgOttimizzo = false; if (pageNumber == 0 && pageRows == 0) flgOttimizzo = false; StringBuffer s_Sql_Find = new StringBuffer("SELECT A.* , SUM(M.kg) as kg, SUM(M.mt) as mt, SUM(M.nr) as nr FROM MOVIMENTO AS M INNER JOIN ARTICOLO AS A ON A.id_articolo=M.id_articolo "); String s_Sql_GrouBy = " group by M.id_articolo"; WcString s_sql_havinng = new WcString(); String s_Sql_Order = " order by A.nome"; if (!CR.getFlgReport().isEmpty()) { s_Sql_Order = " order by C.descrizioneCompleta,C.descrizione, A.nome"; } else if (CR.getFlgOrderBy() == 0L) { s_Sql_Order = " order by A.nome " + CR.getFlgOrderType(); } else if (CR.getFlgOrderBy() == 1L) { s_Sql_Order = " order by M.descrizione " + CR.getFlgOrderType() + ", A.codice, A.nome " + CR.getFlgOrderType(); } else if (CR.getFlgOrderBy() == 2L) { s_Sql_Order = " order by C.descrizione , A.nome "; } else if (CR.getFlgOrderBy() == 3L) { s_Sql_Order = " order by C.descrizione desc , A.nome desc"; } else if (CR.getFlgOrderBy() == 4L) { s_Sql_Order = " order by A.prezzoPubblico , C.descrizione , A.nome"; } else if (CR.getFlgOrderBy() == 5L) { s_Sql_Order = " order by A.prezzoPubblico desc , C.descrizione ,A.nome"; } WcString wc = new WcString(); findByCRCreateWC(CR, s_Sql_Find, wc); if (CR.getDataMovimento() != null) { s_Sql_Find.append(" inner join RIGA_DOCUMENTO AS RD ON M.id_rigaDocumento=RD.id_rigaDocumento inner join DOCUMENTO as DOC on RD.id_documento=DOC.id_documento"); wc.addWc("DOC.dataDocumento<=?"); } if (CR.getFlgQta() == 1L) if (CR.getQtaDa() == 0L) { s_sql_havinng.addHavingWc("nr<=" + CR.getQtaA()); } else { s_sql_havinng.addHavingWc("nr<=" + CR.getQtaA()); s_sql_havinng.addHavingWc("nr>=" + CR.getQtaDa()); } try { PreparedStatement stmt; if ((pageNumber == 0 && pageRows == 0) || !flgOttimizzo) { stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_GrouBy + s_sql_havinng.toString()); } else { if (pageNumber == 0) pageNumber = 1; int start = (pageNumber - 1) * pageRows; int stop = start + pageRows; stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_GrouBy + s_sql_havinng.toString() + " limit " + s_Sql_Order + "," + start); } findByCRCreateStmtDate(CR, stmt); if ((pageNumber == 0 && pageRows == 0) || !flgOttimizzo) { Vectumerator vectumerator = findRows(stmt, pageNumber, pageRows); if (!CR.getFlgReport().isEmpty()); return vectumerator; } Vectumerator vec = findRows(stmt, 1, pageRows); vec.setPageNumber(pageNumber); vec.setTotNumberOfRecords(findByCRTotRecord(CR)); return vec; } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public long getSitemapPriority() { return this.sitemapPriority; } public String getSitemapPriorityReal() { if (getSitemapPriority() > 100L || getSitemapPriority() == 50L || getSitemapPriority() < 0L) return ""; double sp = (double)getSitemapPriority() / 100.0D; return String.valueOf(sp); } public void setSitemapPriority(long sitemapPriority) { this.sitemapPriority = sitemapPriority; } public ResParm aggiornaPrezziEDispoByFornitori(double lastStreetprice, boolean isNuovo) { ResParm rp = new ResParm(false); boolean debug = false; if (getId_articolo() > 0L) { if (debug) System.out.println("######## aggiornaPrezziEDispoByFornitori: " + getEscludiWeb() + " " + getId_articolo() + " " + getCodice() + " qt: " + getQuantita() + " acq.:" + getCostoAcquisto() + " ---->"); ArticoloFornitore af = new ArticoloFornitore(getApFull()); af.findPiuConvenienteByArticolo(getId_articolo()); if (af.getId_articolo() > 0L && af.getFornitore().getFlgAbilitaAF() == 1L && af.getCostoTotale() > af.getFornitore().getValoreMinimoAbilitaAF()) { if (af.getDispTotR() > 0L) { setQuantita((double)af.getDispTotR()); if (getId_fornitoreCostoNuovo() != af.getId_fornitore() || getCostoNetto() != af.getCostoTotale()) { setCostoNuovo(af.getCostoTotale()); setId_fornitoreCostoNuovo(af.getId_fornitore()); if (af.isPromoAttiva()) { setDataScadenzaOffertaFornitore(af.getDataFinePromo()); } else { setDataScadenzaOffertaFornitore(null); } aggiornaPrezzoNettoConCostoNuovo(); if (!isNuovo) setFlgModImportazione(2L); } else { setCostoNuovo(0.0D); if (!isNuovo) setFlgModImportazione(3L); if (af.isPromoAttiva()) { setDataScadenzaOffertaFornitore(af.getDataFinePromo()); } else { setDataScadenzaOffertaFornitore(null); } } Double streetprice = Math.max(af.getStreetPrice(), lastStreetprice); if (streetprice > 0.0D) setStreetPrice(streetprice.doubleValue()); streetprice = getStreetPrice(); if (streetprice <= 0.0D || getPrezzoArticolo(null).getPrezzoBase() > streetprice); } else { System.out.println("aggiornaPrezziEDispoByFornitori ATTENZIONE!!!! NON DOVREI ESSERE QUI!!!!"); setQuantita(0.0D); setFlgModImportazione(2L); } } else { if (getQuantita() != 0.0D) { setFlgModImportazione(2L); setQuantita(0.0D); } else { setFlgModImportazione(3L); } if (debug) System.out.println(" aggiornaPrezziEDispoByFornitori NON HO NESSUN RECORD ARTICOLO FORNITORE..."); } if (getQuantita() == 0.0D) { if (getFlgEscludiWebArt() == 0L); } else if (getFlgEscludiWebArt() == 2L && getId_tipo() > 0L) { setFlgEscludiWebArt(0L); } rp = superSave(); if (debug) System.out.println("--------> aggiornaPrezziEDispoByFornitori: " + getEscludiWeb() + " " + getId_articolo() + " " + getCodice() + " qt: " + getQuantita() + " acq.:" + getCostoAcquisto() + "\n###########"); } return rp; } public static synchronized ResParm aggiornaDispoEPrezzoArticoloFornitore(Articolo bean, long qta, long l_flgEsculdiWeb, boolean aggiornaEbay) { if (bean.getId_articolo() == 0L) return new ResParm(true); ResParm rp = new ResParm(true); if (bean.getId_fornitoreCostoNuovo() > 0L && qta != 0L) { ArticoloFornitore af = new ArticoloFornitore(bean.getApFull()); af.findByFornitoreArticolo(bean.getId_fornitoreCostoNuovo(), bean.getId_articolo(), 1L); if (af.getDBState() == 1) { af.setDispSede(af.getDispSede() + qta); rp = af.save(); } } if (rp.getStatus()) { rp = bean.aggiornaPrezziEDispoByFornitori(bean.getStreetPrice(), false); if (rp.getStatus() && l_flgEsculdiWeb >= 0L) { bean.setFlgEscludiWebArt(l_flgEsculdiWeb); rp = bean.superSave(); } } return rp; } public ResParm aggiornaDispoEPrezziNonTrovatiByFornitori() { ResParm rp = new ResParm(false); boolean debug = false; if (getId_articolo() > 0L) { if (debug) System.out.println("######## aggiornaDispoByFornitori: " + getEscludiWeb() + " " + getId_articolo() + " " + getCodice() + " qt: " + getQuantita() + " acq.:" + getCostoAcquisto() + " ---->"); ArticoloFornitore af = new ArticoloFornitore(getApFull()); af.findPiuConvenienteByArticolo(getId_articolo()); if (af.getId_articolo() > 0L) { if (af.getDispTotR() > 0L) { setQuantita((double)af.getDispTotR()); if (getCostoNetto() != af.getCostoTotale()) { setCostoNuovo(af.getCostoTotale()); setId_fornitoreCostoNuovo(af.getId_fornitore()); aggiornaPrezzoNettoConCostoNuovo(); } else { setCostoNuovo(0.0D); } Double streetprice = af.getStreetPrice(); if (streetprice > 0.0D) setStreetPrice(streetprice.doubleValue()); streetprice = getStreetPrice(); if (streetprice > 0.0D && getPrezzoArticolo(null).getPrezzoBase() > streetprice) { ListinoArticolo listinoArticoloBase = getListinoArticoloBase(); listinoArticoloBase.setPrezzoLA(streetprice.doubleValue()); rp = listinoArticoloBase.save(); } } else { System.out.println("aggiornaDispoByFornitori ATTENZIONE!!!! NON DOVREI ESSERE QUI!!!!"); setQuantita(0.0D); setFlgModImportazione(2L); } } else { setQuantita(0.0D); if (debug) System.out.println(" aggiornaDispoByFornitori NON HO NESSUN RECORD ARTICOLO FORNITORE..."); } rp = superSave(); if (debug) System.out.println("--------> aggiornaDispoByFornitori: " + getEscludiWeb() + " " + getId_articolo() + " " + getCodice() + " qt: " + getQuantita() + " acq.:" + getCostoAcquisto() + "\n###########"); } return rp; } public String getKeywords() { return (this.keywords == null) ? "" : this.keywords.trim(); } public void setKeywords(String keywords) { this.keywords = keywords; } public String getReadyForWeb() { return (this.readyForWeb == null) ? "" : this.readyForWeb.trim(); } public void setReadyForWeb(String readyForWeb) { this.readyForWeb = readyForWeb; } public long getFlgB2b() { return this.flgB2b; } public void setFlgB2b(long flgB2b) { this.flgB2b = flgB2b; } public long getFlgB2bArt() { return this.flgB2bArt; } public void setFlgB2bArt(long flgB2bArt) { this.flgB2bArt = flgB2bArt; } public Vectumerator findWebByArticoloVarianteCROld(ArticoloCR CR, int pageNumber, int pageRows) { StringBuffer s_Sql_Find = new StringBuffer("select A.* from ARTICOLO AS A left join ARTICOLO_VARIANTE AS B ON A.id_articolo=B.id_articolo left JOIN TIPO AS C2 ON A.id_tipo2=C2.id_tipo inner join TIPO AS C on C.id_tipo=A.id_tipo"); if (!CR.getSearchTxtWeb().isEmpty() && !CR.getSearchTxtWeb().equals("*")) s_Sql_Find = new StringBuffer("select A.* from ARTICOLO as A left join ARTICOLO_VARIANTE AS B ON A.id_articolo=B.id_articolo inner join DESC_TXT_LANG AS X ON A.id_articolo=X.idTabella LEFT JOIN TIPO AS C2 ON A.id_tipo2=C2.id_tipo inner join TIPO AS C on C.id_tipo=A.id_tipo"); String s_Sql_Order = " order by A.ordine desc, C.ordine, A.id_articolo"; s_Sql_Order = " order by A.ordine desc,C.ordine,A.nome, A.id_articolo"; WcString wc = new WcString(); findWebByArticoloVarianteCRCreateWCOld(CR, s_Sql_Find, wc); try { PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find) + wc.toString()); return findRows(stmt, pageNumber, pageRows); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } protected void findWebByArticoloVarianteCRCreateWCOld(ArticoloCR CR, StringBuffer s_Sql_Find, WcString wc) { if (!CR.getSearchTxtWeb().isEmpty() && !CR.getSearchTxtWeb().equals("*")) { StringTokenizer st = new StringTokenizer(CR.getSearchTxtWeb().toLowerCase(), " "); StringBuffer txt = new StringBuffer("("); while (st.hasMoreTokens()) { String token = st.nextToken(); txt.append("(A.nome like '%" + token + "%' or X.descrizione254 like '%" + token + "%')"); if (st.hasMoreTokens()) txt.append(" and "); } txt.append(")"); if (txt.length() > 2) wc.addWc(txt.toString()); } if (CR.getFlgEscludiWeb() == 0L) wc.addWc("(A.flgEscludiWeb=0)"); if (CR.getFlgNascondi() == 0L) { wc.addWc("(A.flgNascondi=0 or A.flgNascondi is null)"); wc.addWc("(B.flgNascondi=0 or B.flgNascondi is null)"); wc.addWc("(C.flgNascondi=0 or C.flgNascondi is null)"); } else if (CR.getFlgNascondi() > 0L) { wc.addWc("A.flgNascondi=" + CR.getFlgNascondi()); wc.addWc("B.flgNascondi=" + CR.getFlgNascondi()); wc.addWc("C.flgNascondi=" + CR.getFlgNascondi()); } if (!CR.getFlgDisponibilita().isEmpty()) { StringTokenizer st = new StringTokenizer(CR.getFlgDisponibilita(), ","); StringBuilder cli = new StringBuilder("("); while (st.hasMoreTokens()) { long token = Long.parseLong(st.nextToken()); if (token == 1L) { wc.addWc("A.flgNoleggio>0"); continue; } if (token == 1L) wc.addWc("A.quantita>0"); } } if (CR.getFlgNoleggio() == 10L) wc.addWc("A.flgNoleggio!=1"); if (!CR.getCarId_listaS().isEmpty()) { boolean needOr = false; StringTokenizer st = new StringTokenizer(CR.getCarId_listaS(), ","); StringBuilder cli = new StringBuilder("("); while (st.hasMoreTokens()) { String token = st.nextToken(); if (!token.isEmpty() && !token.equals("0")) { if (token.startsWith("c")) { if (st.hasMoreTokens()) { cli.append(") and ( "); needOr = false; } continue; } if (needOr) cli.append(" or "); cli.append("A.caratteristicheListeId like '%," + token + ",%'"); needOr = true; } } cli.append(")"); if (cli.length() > 2) wc.addWc(cli.toString()); } if (CR.getId_tipoSel() != 0L) wc.addWc("(A.id_tipo=" + CR.getId_tipoSel() + " or C.indici like'%:" + CR.getId_tipoSel() + ":%'or A.id_tipo2=" + CR.getId_tipoSel() + " or C2.indici like'%:" + CR.getId_tipoSel() + ":%')"); if (CR.getPrezzoDa() > 0.0D) wc.addWc("A.prezzoPubblicoIva>=" + CR.getPrezzoDa()); if (CR.getPrezzoA() > 0.0D) wc.addWc("A.prezzoPubblicoIva<=" + CR.getPrezzoA()); } public String getEbayItemId() { return (this.ebayItemId == null) ? "" : this.ebayItemId.trim(); } public void setEbayItemId(String ebayItemId) { this.ebayItemId = ebayItemId; } public boolean isEbayAttivita() { return Attivita.getDefaultInstance(getApFull()).isEbay(); } public boolean isAmazonAttivita() { return Attivita.getDefaultInstance(getApFull()).isAmz(); } public String getEbayOfferId() { return (this.ebayOfferId == null) ? "" : this.ebayOfferId.trim(); } public void setEbayOfferId(String ebayOfferId) { this.ebayOfferId = ebayOfferId; } public ResParm cancellaArticoliVecchiCC(long countImportNonTrovatoDa) { ResParm rp = new ResParm(); int i = 0; int se1 = 10; int se2 = 100; long artCancellati = 0L, artNonCancellati = 0L; if (countImportNonTrovatoDa == 0L) countImportNonTrovatoDa = 30L; ArticoloCR CR = new ArticoloCR(); CR.setFlgModImportazione(0L); CR.setCountImportNonTrovatoDa(countImportNonTrovatoDa); Vectumerator vec = findByCR(CR, 0, 0); System.out.println("Tot Record: " + vec.getTotNumberOfRecords()); while (vec.hasMoreElements()) { Articolo row = (Articolo)vec.nextElement(); if (row.getFlgEscludiWeb() > 0L) { row.delete(); artCancellati++; } else { artNonCancellati++; } i++; if (se1 > 0 && i % se1 == 0) System.out.print("."); if (se2 > 0 && i % se2 == 0) System.out.println("" + i + " cancellati: " + i + " NON cancellati: " + artCancellati); } System.out.println("fine ciclo \nArt. cancellati: " + artCancellati + " NON cancellati: " + artNonCancellati); rp.setStatus(true); rp.setMsg("Art. cancellati: " + artCancellati + " NON cancellati: " + artNonCancellati); return rp; } public ResParm ebayPublishFull() { ResParm rp = new ResParm(); if (getId_articolo() == 0L) { rp.setStatus(false); rp.setMsg("Errore! Articolo nullo o non valido!"); } else { Attivita attivita = Attivita.getDefaultInstance(getApFull()); if (attivita.isEbayPubblicabile()) { EbayAbliaApi ebay = new EbayAbliaApi(getApFull()); if (ebay.isOAuthTokenValid()) { EbayResult res = new EbayResult(); res.setOk(true); if (getEbayOfferId().isEmpty()) { res = ebay.ebayCreateOrReplaceInventoryItem(this); if (res.isOk()) res = ebay.ebayCreateOffer(this); if (res.isOk()) res = ebay.ebayPublishOffer(this); if (res.isOk()) { rp.setStatus(true); rp.setMsg("Articolo pubblicato correttamente: id offerta " + getEbayOfferId()); } else { rp.setStatus(false); rp.setMsg("Errore! " + res.getMsg()); } } else { res = ebay.ebayCreateOrReplaceInventoryItem(this); if (res.isOk()) res = ebay.ebayUpdateOffer(this); if (res.isOk()) { rp.setStatus(true); rp.setMsg("Articolo aggiornato correttamente: id offerta " + getEbayOfferId()); } else { rp.setStatus(false); rp.setMsg("Errore! " + res.getMsg()); } } if (res.isOk() && getEbayItemId().isEmpty()) { System.out.println("ebaypublishfull: get offer.."); res = ebay.ebayGetOffer(this); if (res.isOk()) { rp.setStatus(true); rp.setMsg(rp.getMsg() + " itemid:" + rp.getMsg()); System.out.println("ebaypublishfull: get offer.. itemid:" + getEbayItemId()); } else { rp.setStatus(false); rp.setMsg(rp.getMsg() + " - Errore item id: " + rp.getMsg()); } } } else { rp.setStatus(false); rp.setMsg("Errore! User token non valido! Richiedere nuovo token oAuth!"); } } else { rp.setStatus(false); rp.setMsg("Errore! Mancano i profiles id su attivita!"); } } return rp; } public ResParm amzCatalogItem() { ResParm rp = new ResParm(); if (getId_articolo() == 0L) { rp.setStatus(false); rp.setMsg("Errore! Articolo nullo o non valido!"); } else { Attivita attivita = Attivita.getDefaultInstance(getApFull()); AmzSellerApi asa = new AmzSellerApi(attivita); AmzResult aRes = asa.amzGetCatalogItems(this, "it"); if (aRes.isOk()) { rp.setStatus(true); rp.setMsg(aRes.getMsg()); } else { rp.setStatus(false); rp.setMsg("Errore! Oggetto con ean " + getCodiceEanNoZero() + " non trovato! " + aRes.getMsg()); } } return rp; } public ResParm amzPostPricing(ArticoloCR CR, String currentLang) { ResParm rp = new ResParm(); Attivita attivita = Attivita.getDefaultInstance(getApFull()); AmzSellerApi asa = new AmzSellerApi(attivita); AmzResult aRes = asa.amzPostPricing(CR, currentLang); if (aRes.isOk()) { rp.setStatus(true); rp.setMsg(aRes.getMsg()); } else { rp.setStatus(false); rp.setMsg("Errore! " + aRes.getMsg()); } return rp; } public ResParm amzUpdateOffer() { ResParm rp = new ResParm(); if (getId_articolo() == 0L) { rp.setStatus(false); rp.setMsg("Errore! Articolo nullo o non valido!"); } else { Attivita attivita = Attivita.getDefaultInstance(getApFull()); AmzSellerApi asa = new AmzSellerApi(attivita); AmzResult aRes = asa.amzPutListingsItem(this, "it"); if (aRes.isOk()) { rp.setStatus(true); rp.setMsg(aRes.getMsg()); } else { rp.setStatus(false); rp.setMsg("Errore! " + aRes.getMsg()); } } return rp; } public ResParm amzUpdateOfferAuto() { ResParm rp = new ResParm(); if (getId_articolo() == 0L) { rp.setStatus(false); rp.setMsg("Errore! Articolo nullo o non valido!"); } else { Attivita attivita = Attivita.getDefaultInstance(getApFull()); AmzSellerApi asa = new AmzSellerApi(attivita); AmzResult aRes = asa.amzPutListingsItem(this, "it"); if (aRes.isOk()) { rp.setStatus(true); rp.setMsg(aRes.getMsg()); if (getFlgAmazon() != 1L) { setFlgAmazon(1L); superSave(); } } else { rp.setStatus(false); rp.setMsg("Errore! Oggetto con ean " + getCodiceEanNoZero() + " non trovato!"); if (getFlgAmazon() != 2L) { setFlgAmazon(2L); superSave(); } } } return rp; } public ResParm amzDeleteItem() { ResParm rp = new ResParm(); if (getId_articolo() == 0L) { rp.setStatus(false); rp.setMsg("Errore! Articolo nullo o non valido!"); } else { Attivita attivita = Attivita.getDefaultInstance(getApFull()); AmzSellerApi asa = new AmzSellerApi(attivita); AmzResult aRes = asa.amzDelListingsItem(this, "it"); if (aRes.isOk()) { rp.setStatus(true); rp.setMsg(aRes.getMsg()); if (getFlgAmazon() == 1L) { setFlgAmazon(0L); superSave(); } } else { rp.setStatus(false); rp.setMsg("Errore! Oggetto con ean " + getCodiceEanNoZero() + " non trovato!"); if (getFlgAmazon() != 2L) { setFlgAmazon(2L); superSave(); } } } return rp; } public ResParm ebayPublishUpdate() { ResParm rp = new ResParm(); if (getId_articolo() == 0L) { rp.setStatus(false); rp.setMsg("Errore! Articolo nullo o non valido!"); } else { Attivita attivita = Attivita.getDefaultInstance(getApFull()); if (attivita.isEbayPubblicabile()) { EbayAbliaApi ebay = new EbayAbliaApi(getApFull()); if (ebay.isOAuthTokenValid()) { EbayResult res = new EbayResult(); res.setOk(true); if (getEbayOfferId().isEmpty()) { rp.setStatus(false); rp.setMsg("Errore! Offerid vuoto. !!"); } else { if (getQtaSuEbay() != getQtaEbayDaInviare()) res = ebay.ebayCreateOrReplaceInventoryItem(this); if (res.isOk()) res = ebay.ebayUpdateOffer(this); if (res.isOk()) { rp.setStatus(true); rp.setMsg("Articolo aggiornato correttamente: id offerta " + getEbayOfferId()); } else { rp.setStatus(false); rp.setMsg("Errore! " + res.getMsg()); } if (res.isOk() && getEbayItemId().isEmpty()) { res = ebay.ebayGetOffer(this); if (res.isOk()) { rp.setStatus(true); rp.setMsg(rp.getMsg() + " itemid:" + rp.getMsg()); } else { rp.setStatus(false); rp.setMsg(rp.getMsg() + " - Errore item id: " + rp.getMsg()); } } } } else { rp.setStatus(false); rp.setMsg("Errore! User token non valido! Richiedere nuovo token oAuth!"); } } else { rp.setStatus(false); rp.setMsg("Errore! Mancano i profiles id su attivita!"); } } return rp; } public ResParm ebayCreateUpdateItem() { ResParm rp = new ResParm(); if (getId_articolo() == 0L) { rp.setStatus(false); rp.setMsg("Errore! Articolo nullo o non valido!"); } else { Attivita attivita = Attivita.getDefaultInstance(getApFull()); if (attivita.isEbayPubblicabile()) { EbayAbliaApi ebay = new EbayAbliaApi(getApFull()); if (ebay.isOAuthTokenValid()) { EbayResult res = new EbayResult(); res.setOk(true); res = ebay.ebayCreateOrReplaceInventoryItem(this); if (res.isOk()) { rp.setStatus(true); rp.setMsg("Articolo inserito o aggiornato correttamente"); } else { rp.setStatus(false); rp.setMsg("Errore! " + res.getMsg()); } } else { rp.setStatus(false); rp.setMsg("Errore! User token non valido! Richiedere nuovo token oAuth!"); } } else { rp.setStatus(false); rp.setMsg("Errore! Mancano i profiles id su attivita!"); } } return rp; } public Vectumerator findNCheckEbayArticoliInVendita() { Vectumerator res = new Vectumerator(); String TAG_THREAD_MSG = "CHECK GIACENZA EBAY "; StatusMsg.updateMsgByTag(getApFull(), "CHECK GIACENZA EBAY ", "...inizio ..."); EbayAbliaApi ebayApi = new EbayAbliaApi(getApFull()); int pageRow = 100; int pageNumber = 1; int totEbayArt = 0; EbayResult er = new EbayResult(); Articolo bean = new Articolo(getApFull()); HashSet hsItemid = new HashSet<>(); do { er = ebayApi.getEbayInventoryItems(pageNumber, pageRow); if (!er.isOk()) continue; for (ItemType item : (ItemType[])er.getResult()) { totEbayArt++; StatusMsg.updateMsgByTag(getApFull(), "CHECK GIACENZA EBAY ", "" + totEbayArt + " - " + totEbayArt + " " + item.getItemID() + " " + item.getSKU()); if (hsItemid.contains(item.getItemID())) { er.setOk(false); break; } hsItemid.add(item.getItemID()); bean = new Articolo(getApFull()); bean.findByCodice(item.getSKU()); if (bean.getId_articolo() > 0L) { if (bean.getQuantita() <= 0.0D) { bean.setNome(item.getItemID() + " " + item.getItemID()); res.add(bean); } } else { bean.setCodice(item.getSKU()); bean.setNome(item.getItemID() + " " + item.getItemID() + " SU EBAY MA NON SUL DB."); res.add(bean); } } pageNumber++; } while (er.isOk()); StatusMsg.deleteMsgByTag(getApFull(), "CHECK GIACENZA EBAY "); return res; } public long getId_listinoEbay() { if (this.id_listinoEbay == 0L && getApFull() != null) this.id_listinoEbay = getTipo().getId_listinoEbay(); return this.id_listinoEbay; } public Listino getListinoEbay() { this.listinoEbay = (Listino)getSecondaryObject(this.listinoEbay, Listino.class, getId_listinoEbay()); return this.listinoEbay; } public void setId_listinoEbay(long id_listinoEbay) { this.id_listinoEbay = id_listinoEbay; setListinoEbay(null); } public void setListinoEbay(Listino listinoEbay) { this.listinoEbay = listinoEbay; } public double getPrezzoSuEbayIva() { return this.prezzoSuEbayIva; } public void setPrezzoSuEbayIva(double prezzoSuEbayIva) { this.prezzoSuEbayIva = prezzoSuEbayIva; } public String getTFLinkDettaglioPre14_12_2020(ArticoloCR CR) { String lang = (CR == null || CR.getLang().isEmpty()) ? "it" : CR.getLang(); StringBuilder sb = new StringBuilder(); sb.append(convertStringToLink(getMarca().getDescrizione()).replace('+', '-')); sb.append("-"); sb.append(getTipo().getDescrizione(lang)); sb.append("-"); sb.append(convertStringToLink(getDescrizioneNomeUrl()).replace('+', '-')); sb.append("+"); if (CR == null) { sb.append("articolo"); } else { sb.append(translate("articolo", lang)); } sb.append("-"); sb.append(getId_articolo()); sb.append("-"); sb.append((getId_articoloVariante() == 0L) ? "" : getId_articoloVariante()); sb.append("-"); sb.append(lang); sb.append(".html"); return sb.toString(); } public long getQtaEbay() { return this.qtaEbay; } public long getQtaEbayDaInviare() { if (getQtaEbay() == 0L) return (long)getAvail(); return (long)Math.min((double)getQtaEbay(), getAvail()); } public long getQtaAmzDaInviare() { if (getQtaAmz() == 0L) return (long)getQuantitaEffettiva(); return (long)Math.min((double)getQtaAmz(), getQuantitaEffettiva()); } public boolean isEbayPrezzoQtaAllineati() { if (getPrezzoArticoloEbayIva().getPrezzoFinale() != getPrezzoSuEbayIva() || getQtaSuEbay() != getQtaEbayDaInviare()) return false; return true; } public boolean isAmzPrezzoQtaAllineati() { if (getPrezzoArticoloAmazonIva().getPrezzoFinale() != getPrezzoSuAmzIva() || getQtaSuAmz() != getQtaEbayDaInviare()) return false; return true; } public boolean isAmazonPrezzoQtaAllineati() { if (getPrezzoArticoloAmazonIvaExport("it", 1L) != getPrezzoSuAmzIva() || getQtaSuAmz() != getQtaAmzDaInviare()) return false; return true; } public static final void addImpression(Articolo bean) { bean.setImpression(bean.getImpression() + 1L); bean.setTmstLastImpression(DBAdapter.getTimestamp()); bean.superSave(); } public void setQtaEbay(long qtaEbay) { this.qtaEbay = qtaEbay; } public long getQtaSuEbay() { return this.qtaSuEbay; } public void setQtaSuEbay(long qtaSuEbay) { this.qtaSuEbay = qtaSuEbay; } public long getImpression() { return this.impression; } public void setImpression(long impression) { this.impression = impression; } public Timestamp getTmstLastImpression() { return this.tmstLastImpression; } public void setTmstLastImpression(Timestamp tmstLastImpression) { this.tmstLastImpression = tmstLastImpression; } public final ResParm startThreadAllineaEbay(ApplParmFull apFull, ArticoloCR CR) { if (!isThreadAllineaArticoloEbay()) { new ThreadAllineaEbay(apFull, CR); return new ResParm(true, "Thread allinea ebay avviato"); } return new ResParm(false, "ATTENZIONE!! Thread in esecuzione!!!"); } public final ResParm startThreadAllineaAmz(ApplParmFull apFull, ArticoloCR CR) { return startThreadAllineaAmz2(apFull, CR); } public final ResParm startThreadAllineaAmz2(ApplParmFull apFull, ArticoloCR CR) { if (!isThreadAllineaArticoloAmz()) { new ThreadAllineaAmz(this, apFull, CR); return new ResParm(true, "Thread allinea amz avviato"); } return new ResParm(false, "ATTENZIONE!! Thread in esecuzione!!!"); } public final ResParm startThreadCreaSitemaps(ApplParmFull apFull, ArticoloCR CR) { if (!isThreadCreateSitemaps()) { threadCreaSitemaps = true; ThreadCreaSitemaps t = new ThreadCreaSitemaps(apFull, CR); t.start(); ResParm rp = new ResParm(true, "Thread crea sitemaps avviato"); rp.setExtraInfo("thread", t); return rp; } return new ResParm(false, "ATTENZIONE!! Thread in esecuzione!!!"); } public final ResParm startThreadPostItemOfferAmz(ApplParmFull apFull, ArticoloCR CR) { if (!isThreadPostItemOfferAmz()) { new ThreadAmzPostItemsOffersBatch(this, apFull, CR); return new ResParm(true, "Thread post item offer batch avviato"); } return new ResParm(false, "ATTENZIONE!! Thread in esecuzione!!!"); } public static boolean isThreadAllineaArticoloEbay() { return threadAllineaArticoloEbay; } public static boolean isThreadAllineaArticoloAmz() { return threadAllineaArticoloAmz; } public static boolean isThreadCreateSitemaps() { return threadCreaSitemaps; } public static boolean isThreadCancellazione() { return threadCancellazione; } public static boolean isThreadIcecatAuto() { return threadIcecatAuto; } public String getCartItemDescriptionCC(String lang) { String space = " "; StringBuilder sb = new StringBuilder(); if (getId_articoloVariante() > 0L) { sb.append(getArticoloVariante().getCartItemDescription(lang)); } else { sb.append(getCCNome(lang)); } if (getId_articoloVarianteKit() > 0L) { sb.append(" "); sb.append("+"); sb.append(" "); sb.append(getArticoloVarianteKit().getCCNome(lang)); } if (getId_articoloTaglia() > 0L) { sb.append(" "); sb.append(getArticoloTaglia().getTaglia().getCodice()); } return sb.toString(); } public final ResParm sendAmzUpdateResultByEmail(ApplParmFull apFull, String title, Vectumerator vec, String msg) { ResParm rp = new ResParm(); String TDAP = "
"; String fileName = apFull.getParm("DOCBASE").getTesto() + "admin/art/_mailMessage/amzUpdate.html"; MailMessage mm = new MailMessage(apFull, fileName); NumberFormat nf = apFull.getNf(); Articolo articolo = new Articolo(apFull); ArticoloCR CR = new ArticoloCR(); StringBuilder sb = new StringBuilder(); mm.setDate("data", DBAdapter.getToday()); mm.setString("risultato", msg); String oggettoMessaggio = title + " " + title + " " + String.valueOf(DBAdapter.getToday()); while (vec.hasMoreElements()) { Articolo row = (Articolo)vec.nextElement(); String notes = row.getBeanNotes(); sb.append(""); sb.append(""); sb.append(""); sb.append(""); sb.append(""); sb.append(""); sb.append(""); sb.append(""); sb.append(""); sb.append(""); sb.append(""); sb.append(""); sb.append(""); if (row.getFlgAmzWarn() == 1L) { sb.append(""); sb.append(""); sb.append("\n"); } sb.append("
"); sb.append(""); sb.append(""); sb.append(""); StringTokenizer st = new StringTokenizer(articolo.getDescrizionePerMail(true), "|"); while (st.hasMoreTokens()) { sb.append(""); } sb.append(""); this.CR.setFlgIcecatAuto(1L); this.CR.setFlgReadyForWeb(0L); this.CR.setLangReadyForWeb("it"); String l_icecatLang = Articolo.this.getParm("LANG_AVAILABLE").getTesto(); boolean caricaImmagini = true; String previewSizeAllImages = "66"; String previewSizeImage1 = "50,200,350"; Vectumerator vec = articolo.findByCR(this.CR, 0, 0); int i = 0, icecatOK = 0, icecatKO = 0, totRecordIcecat = 0; while (vec.hasMoreElements()) { Articolo row = (Articolo)vec.nextElement(); boolean isIcecatOk = false; if (debug) System.out.println("ICECAT AUTO articolo" + row.getMarca().getDescrizione() + " " + row.getNome() + "..."); if (row.getTipo().getFlgIcecatNoAuto() == 0L) { totRecordIcecat++; rp.setStatus(true); i++; String temp = "Aggiornamento " + i + " su " + vec.getTotNumberOfRecords() + " " + row.getMarca().getDescrizione() + " " + row.getCodice() + " " + row.getNome(); StatusMsg.updateMsgByTag(Articolo.this.getApFull(), "ICECAT AUTO ", temp); if (!l_icecatLang.isEmpty()) { st = new StringTokenizer(l_icecatLang, ","); while (st.hasMoreTokens()) { String lang = st.nextToken(); caricaImmagini = true; StatusMsg.updateMsgByTag(Articolo.this.getApFull(), "ICECAT AUTO ", temp + " chiamata icecat " + temp + " ....."); if (debug) System.out.println("ICECAT AUTO chiamo icecat " + lang + "..."); rp = row.caricaIcecat(lang, caricaImmagini, 1); if (rp.getStatus()) { if (row.isReadyForWeb(lang)) isIcecatOk = true; if (!previewSizeAllImages.isEmpty()) { if (debug) System.out.println("ICECAT AUTO creo preview...."); row.creaPreviewH(previewSizeAllImages, 8, "ICECAT AUTO ", temp); } if (!previewSizeImage1.isEmpty()) { if (debug) System.out.println("ICECAT AUTO creo preview 1...."); row.creaPreviewH(previewSizeImage1, 1, "ICECAT AUTO ", temp); } caricaImmagini = false; if (debug) System.out.println("ICECAT AUTO chiamo icecat " + lang + ". ok: " + icecatOK + " ko: " + icecatKO); continue; } isIcecatOk = false; } } if (isIcecatOk) { icecatOK++; sb.append(""); st = new StringTokenizer(row.getDescrizionePerMail(false), "|"); while (st.hasMoreTokens()) { sb.append(""); } sb.append(""); row.save(); continue; } icecatKO++; } } sb.append("
"); String token = st.nextToken(); sb.append(token); sb.append("
"); String token = st.nextToken(); sb.append(token); sb.append("
"); timer.stop(); StatusMsg.updateMsgByTag(Articolo.this.getApFull(), "ICECAT AUTO ", "Aggiornamento concluso. DURATA: " + timer.getDurataHourMin() + "\n" + err.toString()); System.out.println("###### ICECAT AUTO CONCLUSO #####"); System.out.println("Aggiornamento concluso. DURATA: " + timer.getDurataHourMin()); System.out.println("Tot record: " + vec.getTotNumberOfRecords() + "- icecat OK: " + icecatOK + " icecat KO: " + icecatKO); System.out.println(err.toString()); System.out.println("############################################"); StringBuilder msg = new StringBuilder("DURATA: " + timer.getDurataHourMin()); msg.append("\n"); msg.append("Tot record: "); msg.append(vec.getTotNumberOfRecords()); msg.append(" - record icecat: "); msg.append(totRecordIcecat); msg.append(" - icecat OK: "); msg.append(icecatOK); msg.append(" - icecat KO: "); msg.append(icecatKO); StatusMsg.updateMsgByTag(Articolo.this.getApFull(), "ICECAT AUTO ", "Concluso. " + msg.toString()); boolean sendEmail = true; if (sendEmail) { MailProperties mp = new MailProperties(); String eMail = Articolo.this.getApFull().getParm("TO").getTesto(); mp.put("TO", eMail); mp.put("ISHTML", "true"); mp.setProperty("FROM", Articolo.this.getApFull().getParm("FROM").getTesto()); mp.put("SUBJECT", "ICECAT AUTO - ok: " + icecatOK + " su " + totRecordIcecat); mp.setProperty("BCC", ""); mp.setProperty("CC", ""); mp.put("MSG", "ICECAT AUTO concluso. \n" + msg.toString() + "
" + sb.toString()); try { Articolo.this.sendMailMessage(mp); } catch (Exception e) { e.printStackTrace(); } } try { sleep(10000L); } catch (Exception e) {} StatusMsg.deleteMsgByTag(Articolo.this.getApFull(), "ICECAT AUTO "); Articolo.threadIcecatAuto = false; System.out.println(rp.getMsg()); } } class ThreadCreaSitemaps extends Thread { private ApplParmFull apFull; private ArticoloCR ACR; private final String TAG_THREAD_MSG = "CREA SITEMAPS "; public ThreadCreaSitemaps(ApplParmFull apFull, ArticoloCR ACR) { this.apFull = apFull; this.ACR = ACR; } public void run() { boolean debug = false; ResParm rp = new ResParm(true); try { Timer timer = new Timer(); timer.start(); StatusMsg.updateMsgByTag(Articolo.this.getApFull(), "CREA SITEMAPS ", "...inizio ..."); StringBuffer msg = new StringBuffer("Inizio Thread crea sitemap...\n"); Articolo art = new Articolo(this.apFull); this.ACR.setFlgReadyForWeb(1L); this.ACR.setFlgEscludiWeb(0L); this.ACR.setLangReadyForWeb("it"); SitemapCR CR = new SitemapCR(this.apFull); CR.setACR(this.ACR); String lang = art.getParm("LANG_AVAILABLE").getTesto(); StringTokenizer st = new StringTokenizer(lang, ","); String filenamePre = "sitemap"; String filenameXml = ".xml"; while (st.hasMoreTokens()) { String currentLang = st.nextToken(); CR.setSitemapFilename("sitemap"); msg.append("creazione sitemap in lingua " + currentLang + " file " + CR.getSitemapFilename() + ".xml\n"); CR.setLangSitemap(currentLang); Sitemap sitemap = new Sitemap(this.apFull); StatusMsg.updateMsgByTag(Articolo.this.getApFull(), "CREA SITEMAPS ", "Sitemap lingua " + currentLang + " file unico in corso...."); CR.setFlgSitemapType(9L); rp = sitemap.creaFileXmlSitemap(CR); StatusMsg.updateMsgByTag(Articolo.this.getApFull(), "CREA SITEMAPS ", "Sitemap lingua " + currentLang + " file separati in corso...."); CR.setFlgSitemapType(10L); rp = sitemap.creaFileXmlSitemap(CR); msg.append(rp.getMsg()); msg.append("\n"); } msg.append("\nfine SITEMAP. Lap time:" + timer.getDurataHourMin()); StatusMsg.deleteMsgByTag(Articolo.this.getApFull(), "CREA SITEMAPS "); } catch (Exception e) { rp.setStatus(false); rp.setMsg("Errore in ThreadCreaSitemaps: " + e.getMessage()); e.printStackTrace(); } finally { Articolo.threadCreaSitemaps = false; } DBAdapter.printDebug(debug, rp.getMsg()); } } class ThreadUpdOfferAmz extends Thread { private ApplParmFull apFull; private ArticoloCR CR; private final String TAG_THREAD_MSG = "UPDATE OFFER AUTO AMAZON "; private long flgPriceTypeAmz; public ThreadUpdOfferAmz(Articolo this$0, ApplParmFull apFull, ArticoloCR CR, long flgPriceTypeAmz) {} public void run() { boolean debug = false; Timer timer = new Timer(); timer.start(); StatusMsg.updateMsgByTag(this.this$0.getApFull(), "UPDATE OFFER AUTO AMAZON ", "...inizio ..."); StringBuilder err = new StringBuilder(); ResParm rp = new ResParm(true); Articolo articolo = new Articolo(this.apFull); boolean isLocale = articolo.isLocalhost(); Vectumerator vec = articolo.findByCR(this.CR, 0, 0); Vectumerator vecRes = new Vectumerator(); int i = 0, daAggiornare = 0, changed = 0; while (vec.hasMoreElements()) { Articolo row = (Articolo)vec.nextElement(); i++; StatusMsg.updateMsgByTag(this.this$0.getApFull(), "UPDATE OFFER AUTO AMAZON ", "articolo " + i + " su " + vec.getTotNumberOfRecords() + ": " + changed + " aggiornati su " + daAggiornare); if (this.flgPriceTypeAmz >= 0L && row.getFlgPriceTypeAmz() != this.flgPriceTypeAmz) { row.setFlgPriceTypeAmz(this.flgPriceTypeAmz); row.superSave(); } if (!row.isAmazonPrezzoQtaAllineati()) { if (debug) System.out.println("UpdateOffer thread: articolo codice " + row.getCodice() + " " + row.getNome()); daAggiornare++; StringBuilder beanNote = new StringBuilder(this.this$0.getNf().format(row.getPrezzoSuAmzIva())); beanNote.append("->"); beanNote.append(this.this$0.getNf().format(row.getPrezzoArticoloAmazonIvaExport("it", 1L))); beanNote.append("
"); beanNote.append("q "); beanNote.append(this.this$0.getNf0().format(row.getQtaSuAmz())); beanNote.append("->"); beanNote.append(this.this$0.getNf0().format(row.getQtaAmzDaInviare())); if (!isLocale) { rp = row.amzUpdateOfferAuto(); if (rp.getStatus()) { changed++; beanNote.append("\nupdated"); } else { beanNote.append("\nErr.: "); beanNote.append(rp.getMsg()); err.append(row.getCodice() + " " + row.getCodice() + ": " + row.getNome()); } } else { beanNote.append("\nLocale! "); } row.setBeanNotes(beanNote.toString()); vecRes.add(row); } } timer.stop(); StatusMsg.updateMsgByTag(this.this$0.getApFull(), "UPDATE OFFER AUTO AMAZON ", "Aggiornamento concluso. DURATA: " + timer.getDurataHourMin() + "\n" + err.toString()); System.out.println("###### THREAD ALLINEA AMZ CONCLUSO #####"); System.out.println("Aggiornamento concluso. DURATA: " + timer.getDurataHourMin()); System.out.println("Tot record: " + vec.getTotNumberOfRecords() + ": " + changed + " aggiornati su " + daAggiornare); System.out.println(err.toString()); System.out.println("############################################"); StringBuilder msg = new StringBuilder("DURATA: " + timer.getDurataHourMin()); msg.append("\n"); msg.append("Tot record: "); msg.append(vec.getTotNumberOfRecords()); msg.append(": "); msg.append(changed); msg.append(" aggiornati su "); msg.append(daAggiornare); StatusMsg.updateMsgByTag(this.this$0.getApFull(), "UPDATE OFFER AUTO AMAZON ", "Aggiornamento concluso. Invio email risultato in corso..... "); this.this$0.sendAmzUpdateResultByEmail(this.apFull, "Amz Offer Auto", vecRes, msg.toString()); try { sleep(10000L); } catch (Exception e) {} StatusMsg.deleteMsgByTag(this.this$0.getApFull(), "UPDATE OFFER AUTO AMAZON "); Articolo.threadUpdateOfferAmz = false; System.out.println(rp.getMsg()); } } class ThreadAmzPostItemsOffersBatch extends Thread { private ApplParmFull apFull; private ArticoloCR CR; private final String TAG_THREAD_MSG = "PostItemsOffersBatch AMAZON "; public ThreadAmzPostItemsOffersBatch(Articolo this$0, ApplParmFull apFull, ArticoloCR CR) {} public void run() { boolean debug = false; Timer timer = new Timer(); timer.start(); StatusMsg.updateMsgByTag(this.this$0.getApFull(), "PostItemsOffersBatch AMAZON ", "...inizio ..."); StringBuilder err = new StringBuilder(); ResParm rp = new ResParm(true); Attivita attivita = Attivita.getDefaultInstance(this.this$0.getApFull()); this.CR.setTAG_THREAD_MSG("PostItemsOffersBatch AMAZON "); this.CR.setFlgAsinAmzNull(1L); Vectumerator vec = this.this$0.findByCR(this.CR, 0, 0); int i = 1; int totRecords = vec.getTotNumberOfRecords(); while (vec.hasMoreElements()) { Articolo row = (Articolo)vec.nextElement(); rp = row.amzCatalogItem(); if (!rp.getStatus()) { StatusMsg.updateMsgByTag(this.this$0.getApFull(), "PostItemsOffersBatch AMAZON ", "catalog asin " + i + " su " + totRecords + " " + row.getCodiceEanNoZero() + " " + row.getNome() + " " + rp.getErrMsg()); } else { StatusMsg.updateMsgByTag(this.this$0.getApFull(), "PostItemsOffersBatch AMAZON ", "catalog asin " + i + " su " + totRecords + " " + row.getCodiceEanNoZero() + " " + row.getNome() + " " + rp.getMsg()); } i++; } this.CR.setFlgAsinAmzNull(0L); vec = this.this$0.findByCR(this.CR, 1, 1); if (vec.getTotNumberOfRecords() > 0) { AmzSellerApi asa = new AmzSellerApi(attivita); AmzResult aRes = asa.amzPostItemsOffersBatch(this.CR, "it"); if (aRes.isOk()) { rp.setStatus(true); rp.setMsg(aRes.getMsg()); } else { rp.setStatus(false); rp.setMsg("Errore! " + aRes.getMsg()); } } else { rp.setStatus(false); rp.setMsg("Errore! non ci sono articoli con asin impostati!"); } timer.stop(); StatusMsg.updateMsgByTag(this.this$0.getApFull(), "PostItemsOffersBatch AMAZON ", "Aggiornamento concluso. DURATA: " + timer.getDurataHourMin() + "\n" + err.toString()); System.out.println("###### PostItemsOffersBatch AMAZON #####"); System.out.println("Aggiornamento concluso. DURATA: " + timer.getDurataHourMin()); System.out.println(err.toString()); System.out.println("############################################"); StringBuilder msg = new StringBuilder("DURATA: " + timer.getDurataHourMin()); StatusMsg.updateMsgByTag(this.this$0.getApFull(), "PostItemsOffersBatch AMAZON ", "Aggiornamento concluso...... "); try { sleep(10000L); } catch (Exception e) {} StatusMsg.deleteMsgByTag(this.this$0.getApFull(), "PostItemsOffersBatch AMAZON "); Articolo.threadPostItemOfferAmz = false; System.out.println(rp.getMsg()); } } class ThreadAllineaAmz extends Thread { private ApplParmFull apFull; private ArticoloCR CR; private final String TAG_THREAD_MSG = "ALLINEA AMAZON "; public ThreadAllineaAmz(Articolo this$0, ApplParmFull apFull, ArticoloCR CR) {} public void run() { boolean debug = false; Timer timer = new Timer(); timer.start(); StatusMsg.updateMsgByTag(this.this$0.getApFull(), "ALLINEA AMAZON ", "...inizio ..."); StringBuilder err = new StringBuilder(); ResParm rp = new ResParm(true); Articolo articolo = new Articolo(this.apFull); boolean isLocale = articolo.isLocalhost(); this.CR.setFlgAmazon(1L); Vectumerator vec = articolo.findByCR(this.CR, 0, 0); Vectumerator vecRes = new Vectumerator(); int i = 0, daAggiornare = 0, changed = 0; while (vec.hasMoreElements()) { Articolo row = (Articolo)vec.nextElement(); i++; StatusMsg.updateMsgByTag(this.this$0.getApFull(), "ALLINEA AMAZON ", "articolo " + i + " su " + vec.getTotNumberOfRecords() + ": " + changed + " aggiornati su " + daAggiornare); if (!row.isAmazonPrezzoQtaAllineati()) { if (debug) System.out.println("AllineAmz: articolo codice " + row.getCodice() + " " + row.getNome()); daAggiornare++; StringBuilder beanNote = new StringBuilder(this.this$0.getNf().format(row.getPrezzoSuAmzIva())); beanNote.append("->"); beanNote.append(this.this$0.getNf().format(row.getPrezzoArticoloAmazonIvaExport("it", 1L))); beanNote.append("
"); beanNote.append("q "); beanNote.append(this.this$0.getNf0().format(row.getQtaSuAmz())); beanNote.append("->"); beanNote.append(this.this$0.getNf0().format(row.getQtaAmzDaInviare())); if (!isLocale) { rp = row.amzUpdateOffer(); if (rp.getStatus()) { changed++; beanNote.append("\nupdated"); } else { beanNote.append("\nErr.: "); beanNote.append(rp.getMsg()); err.append(row.getCodice() + " " + row.getCodice() + ": " + row.getNome()); } } else { beanNote.append("\nLocale! "); } row.setBeanNotes(beanNote.toString()); vecRes.add(row); } } timer.stop(); StatusMsg.updateMsgByTag(this.this$0.getApFull(), "ALLINEA AMAZON ", "Aggiornamento concluso. DURATA: " + timer.getDurataHourMin() + "\n" + err.toString()); System.out.println("###### THREAD ALLINEA AMZ CONCLUSO #####"); System.out.println("Aggiornamento concluso. DURATA: " + timer.getDurataHourMin()); System.out.println("Tot record: " + vec.getTotNumberOfRecords() + ": " + changed + " aggiornati su " + daAggiornare); System.out.println(err.toString()); System.out.println("############################################"); StringBuilder msg = new StringBuilder("DURATA: " + timer.getDurataHourMin()); msg.append("\n"); msg.append("Tot record: "); msg.append(vec.getTotNumberOfRecords()); msg.append(": "); msg.append(changed); msg.append(" aggiornati su "); msg.append(daAggiornare); StatusMsg.updateMsgByTag(this.this$0.getApFull(), "ALLINEA AMAZON ", "Aggiornamento concluso. Invio email risultato in corso..... "); this.this$0.sendAmzUpdateResultByEmail(this.apFull, "Amz Allinea", vecRes, msg.toString()); try { sleep(10000L); } catch (Exception e) {} StatusMsg.deleteMsgByTag(this.this$0.getApFull(), "ALLINEA AMAZON "); Articolo.threadAllineaArticoloAmz = false; System.out.println(rp.getMsg()); } } public static volatile boolean threadCreaSitemaps = false; public static volatile boolean threadAllineaArticoloEbay = false; public static volatile boolean threadAllineaArticoloAmz = false; public static volatile boolean threadUpdateOfferAmz = false; public static volatile boolean threadPostItemOfferAmz = false; public static volatile boolean threadCancellazione = false; public static volatile boolean threadIcecatAuto = false; public static final int DISPO_LEVEL_IN_ARRIVO = 0; public static final int DISPO_LEVEL_SCARSA = 1; public static final int DISPO_LEVEL_ALTA = 2; private long flgRC; private long lavaggio; private long candeggio; private long stiratura; private long pulituraSecco; private long asciugatura; private long massaLineare; private long altezzaMinima; private SimboliLavaggio simboliLavaggio; private long id_articoloTaglia; private long flgNoListinoArt; private long countImportNonTrovato; private Date dataUltimoImport; private long flgTipoMagazzino; private double quantitaW; private long flgArticoloComponente; private ListinoArticolo listinoArticoloBase; private boolean quantitaDataCalcolate = false; private double quantitaEffettiva; private String nome; private long flgDispo; private long id_tipo2; private Tipo tipo2; private String caratteristicheListeId; private String googleFeedFileName; private String readyForWeb; private String notaArticolo; private String codiceEan; private Date dataUltimoCosto; private String descrizioneGoogle; private long flgEbay = 0L; private long flgGoogle; private long flgSubito; private long flgNoleggio; private long flgUsato; private String nMatricola; private double percRicarico; private double percRicaricoEffettivo; private double prezzoIvatoBarrato; private double prezzoNoleggio; private long flgSuperGaranzia; private double prezzoNettoBarrato; private double costoRivalutazione; private long flgStatoImport; private double costoNetto; private double costoNettoDb; private double costoManodopera; private double costoStiro; private double costoSpeseFisse; private double costoAccessori; private double totCostoConfezione = -1.0D; private long flgKit; private long flgKitArt; private long flgRateale0; private long flgB2b; private long flgB2bArt; private long id_statoUsato; private StatoUsato statoUsato; private String ebayItemId; private Listino listinoBase; private PrezzoArticolo prezzoArticolo; private PrezzoArticolo prezzoArticoloIva; private long flgPreventivoWwwArt; private long percCostoSpedizione; private String categoriaImport; private ArticoloVariante articoloVarianteBase; private Hashtable caratteristicheHT; private String seriale; private String codiceProduttore; private String codiciAlternativi; private Date dataFineVld; private Date dataScadenzaOfferta; private Date dataScadenzaOffertaFornitore; private String descrizioneCommerciale_it; private String altreCompatibilita; private String codiciMagazzino; private long flgWebNoVendita; private long flgAggiornaDati; private long flgFuoriListino; private long flgNascondi; private boolean flgNextPrev = false; private long flgStato; private long flgStockOfferte; private long flgUdm; private long id_articolo; private long id_fornitoreCostoNuovo; private Clifor fornitoreCostoNuovo; private long id_confezionistaDefault; private long id_articoloNext; private long id_articoloPrev; private long id_articoloVarianteBaseNext; private long id_articoloVarianteBasePrev; private long id_iva; private long id_marca; private long id_tipo; private long id_tipoTaglia; private Iva iva; private Marca marca; private long mesigar; private long ordine; private String pathAllegatoOld; private double percSconto; private double pesoKg; private long prenotatiArt; private double abbuonoPrezzoPubblico; private double prezzoVendor; private double qtaRiordino; private double ricaricoBase; private double streetPrice; private Tipo tipo; private ArticoloTaglia articoloTaglia; private TipoTaglia tipoTaglia; private long volumeCm3; private double volumeM3; private long id_tabellaTaglia; private TabellaTaglia tabellaTaglia; private long id_articoloVariante; private long flgSerialiMassivi = 0L; private String codice; private long flgUsaVarianti; private ArticoloVariante articoloVariante; private long flgStampaEtichette; private double prezzoPubblicoIvaOrd; private Date dataCambiamentoPrezzo; private double prezzoRivNuovo; private long flgUsaVariantiArt; private double ricaricoBaseNew; private long flgNoListino = 0L; private String compatibilita; private double quantita; private long flgStampaAccessori; private double costoRivalutazioneConIva; private long flgNegativo = 0L; private double quantitaData; private boolean quantitaCalcolate; private double quantitaInArrivo; private double quantitaImpegnata; private double qtaRiordinoNuovo; private String caratteristiche; private long sitemapPriority = 80L; private long id_caratteristica; private long flgEscludiWeb = 0L; private long flgAggGiacenza = 0L; private double costoNuovo; private long id_tipoAccessorio; private TipoAccessorio tipoAccessorio; private long flgEscludiWebArt; private long id_vetrina; private Vetrina vetrina; private double prezzoOfferta; private String quantitaMagazzinoMovimentoHtml; private String idTipoSearch; private String scaffale; private long flgContoVendita; private Date dataAggiornamento; private String descrizioneSearch; private long tipoOrdineSearch; private String tipoDescrizioneSearch; private double quantitaDB; private long flgModImportazione; private long flgDisponibilitaWeb; private String tagArticolo; private String codicePromozioneA; private double costoPrecedente; private double imponibilePrecedente; private String descrizioneCaratteristiche; private long flgGoogleDB; private long flgRichiediQuotazione; private ArticoloVariante articoloVarianteKit; private long id_articoloVarianteKit; private String keywords; private String ebayOfferId; private long qtaEbay = 2L; private long qtaMaxAcquistoWww; private long id_listinoEbay; private Listino listinoEbay; private double prezzoSuEbayIva; private long qtaSuEbay; private double prezzoSuAmzIva; private long qtaSuAmz; private String productTypeAmz; private long id_listinoAmazon; private Listino listinoAmazon; private long qtaAmz; private long flgAmazon; private long flgAmzWarn; private String asinAmz; private long flgPriceTypeAmz; private String descAmz; private long impression; private Timestamp tmstLastImpression; private long id_articoloTagliaKit; private double tariffaAmazon; private long flgControlloCostoAggArt; private long flgTipoSchedaArticoloWww; private String nomeSeo; private String erroriSeo; private Date dataChiamataIcecat; private long hashCodeCurrent; private long hashCodeIndexNow; private Clifor confezionistaDefault; public Articolo(ApplParmFull newApplParmFull) { super(newApplParmFull); } public long getFlgRichiediQuotazione() { return this.flgRichiediQuotazione; } public void setFlgRichiediQuotazione(long flgRichiediQuotazione) { this.flgRichiediQuotazione = flgRichiediQuotazione; } public ResParm addAccessorio(Accessorio row) { Accessorio bean = new Accessorio(getApFull()); if (row.getId_accessorio() != 0L) { bean.findByPrimaryKey(row.getId_accessorio()); } else { bean.findById_articoloId_associato(row.getId_articolo(), row.getId_articoloAssociato()); } if (bean.getDBState() == 1) { row.setDBState(bean.getDBState()); row.setId_accessorio(bean.getId_accessorio()); } ResParm rp = row.save(); if (rp.getStatus()) { if (row.getId_articolo() > 0L) rp.append(row.getArticolo().aggiornaCompatibilita()); if (row.getId_articoloAssociato() > 0L) rp.append(row.getArticoloAssociato().aggiornaCompatibilita()); } return rp; } public ResParm addKit(Kit row) { Kit bean = new Kit(getApFull()); if (row.getId_kit() != 0L) { bean.findByPrimaryKey(row.getId_kit()); } else { bean.findById_articoloPrimarioId_articoloSecondario(row.getId_articolo(), row.getId_articoloSecondario()); } if (bean.getDBState() == 1) { row.setDBState(bean.getDBState()); row.setId_kit(bean.getId_kit()); } ResParm rp = row.save(); return rp; } public ResParm addAllegato(AllegatoArticolo row) { AllegatoArticolo bean = new AllegatoArticolo(getApFull()); bean.findByArticoloNomeFile(row.getId_articolo(), row.getNomeFile()); if (bean.getDBState() == 1) return new ResParm(false, "Nome File Duplicato"); row.setDBState(0); ResParm rp = row.save(); return rp; } public ResParm addCaratteristica(CaratteristicaArticolo ab) { CaratteristicaArticolo bean = new CaratteristicaArticolo(getApFull()); CaratteristicaArticoloKey caK = new CaratteristicaArticoloKey(ab.getId_articolo(), ab.getId_caratteristica()); bean.findByPrimaryKey(caK); if (bean != null) { ab.setDBState(bean.getDBState()); } else { ab.setDBState(0); } ResParm rp = ab.save(); if (rp.getStatus()) rp.append(aggiornaCaratteristiche()); return rp; } private void addCaratteristicaInit(Caratteristica ca) { CaratteristicaArticolo bean = new CaratteristicaArticolo(getApFull()); CaratteristicaArticoloKey caK = new CaratteristicaArticoloKey(getId_articolo(), ca.getId_caratteristica()); bean.findByPrimaryKey(caK); if (bean.getDBState() == 0) { bean.setId_articolo(getId_articolo()); bean.setId_caratteristica(ca.getId_caratteristica()); bean.save(); } } private void addCaratteristicaFull(CaratteristicaArticolo ca) { CaratteristicaArticolo bean = new CaratteristicaArticolo(getApFull()); CaratteristicaArticoloKey caK = new CaratteristicaArticoloKey(getId_articolo(), ca.getId_caratteristica()); bean.findByPrimaryKey(caK); if (bean.getDBState() == 0) { bean.setId_articolo(getId_articolo()); bean.setId_caratteristica(ca.getId_caratteristica()); bean.setValD(ca.getValD()); bean.setValDouble(ca.getValDouble()); bean.setValI(ca.getValI()); bean.setValS(ca.getValS()); bean.setValSN(ca.getValSN()); bean.setId_lista(ca.getId_lista()); bean.save(); } } public ResParm addFornitore(ArticoloFornitore ab) { ResParm rp = new ResParm(true); ArticoloFornitore bean = new ArticoloFornitore(getApFull()); bean.findByPrimaryKey(ab.getId_articoloFornitore()); if (bean != null) { ab.setDBState(bean.getDBState()); } else { ab.setDBState(0); } if (ab.getFlgAbituale() == 1L) rp = ab.deleteFlgAbitualeArticolo(ab.getId_articolo()); rp.append(ab.save()); return rp; } public void aggiornaRicarichi(ArticoloCR CR) {} private void calcolaIdNextPrev(ArticoloCR CR) { long l_id_articolo = 0L; CR.setFlgOrderType("asc"); CR.setCurrentCodice(getCodice()); CR.setFlgOrderBy(0L); Vectumerator vec = findByCR(CR, 1, 5); while (vec.hasMoreElements()) { Articolo row = (Articolo)vec.nextElement(); if (row.getId_articolo() != getId_articolo()) { l_id_articolo = row.getId_articolo(); break; } } setId_articoloNext(l_id_articolo); l_id_articolo = 0L; CR.setFlgOrderType("desc"); vec = findByCR(CR, 1, 5); while (vec.hasMoreElements()) { Articolo row = (Articolo)vec.nextElement(); if (row.getId_articolo() != getId_articolo()) { l_id_articolo = row.getId_articolo(); break; } } setId_articoloPrev(l_id_articolo); setFlgNextPrev(true); } private void calcolaIdVarianteNextPrev(ArticoloCR CR) { long l_id_articoloVarianteBase = 0L; CR.setFlgOrderType("asc"); CR.setCurrentCodice(getCodice()); CR.setFlgOrderBy(0L); CR.setFlgNascondi(0L); Vectumerator vec = findByCR(CR, 1, 5); while (vec.hasMoreElements()) { Articolo row = (Articolo)vec.nextElement(); if (row.getId_articolo() != getId_articolo()) { l_id_articoloVarianteBase = row.getArticoloVarianteBase().getId_articoloVariante(); break; } } setId_articoloVarianteBaseNext(l_id_articoloVarianteBase); l_id_articoloVarianteBase = 0L; CR.setFlgOrderType("desc"); vec = findByCR(CR, 1, 5); while (vec.hasMoreElements()) { Articolo row = (Articolo)vec.nextElement(); if (row.getId_articolo() != getId_articolo()) { l_id_articoloVarianteBase = row.getArticoloVarianteBase().getId_articoloVariante(); break; } } setId_articoloVarianteBasePrev(l_id_articoloVarianteBase); setFlgNextPrev(true); } private long calcolaOrdine() { try { String s_sqlFind = "select max(ordine) as _max from ARTICOLO WHERE id_articolo!=" + getId_articolo(); PreparedStatement ps = getConn().prepareStatement(s_sqlFind); long res = (long)getMax(ps, true) + 1L; long decine = res / 10L; return (decine + 1L) * 10L; } catch (Exception e) { handleDebug(e); return 0L; } } public void caricaCaratteristiche() { Vectumerator vec = new Caratteristica(getApFull()).findCaratteristicheByTipo(getId_tipo(), 0, 0); while (vec.hasMoreElements()) addCaratteristicaInit((Caratteristica)vec.nextElement()); } public void caricaCaratteristicheDaArticoloSource(long l_id_articoloSource) { Articolo articoloSource = new Articolo(getApFull()); articoloSource.findByPrimaryKey(l_id_articoloSource); Vectumerator vec = articoloSource.getCaratteristicheArticolo(); while (vec.hasMoreElements()) { CaratteristicaArticolo ca = (CaratteristicaArticolo)vec.nextElement(); addCaratteristicaFull(ca); } } public ResParm delAccessorio(Accessorio row) { Accessorio bean = new Accessorio(getApFull()); bean.findByPrimaryKey(row.getId_accessorio()); Accessorio bean2 = new Accessorio(getApFull()); bean2.findByPrimaryKey(bean.getId_accessorio()); ResParm rp = bean.delete(); if (rp.getStatus()) { if (bean2.getId_articolo() > 0L) rp.append(bean2.getArticolo().aggiornaCompatibilita()); if (bean2.getId_articoloAssociato() > 0L) rp.append(bean2.getArticoloAssociato().aggiornaCompatibilita()); } return rp; } public ResParm delKit(Kit row) { Kit bean = new Kit(getApFull()); bean.findByPrimaryKey(row.getId_kit()); Accessorio bean2 = new Accessorio(getApFull()); bean2.findByPrimaryKey(bean.getId_kit()); ResParm rp = bean.delete(); return rp; } public ResParm delAllegato(AllegatoArticolo row) { AllegatoArticolo bean = new AllegatoArticolo(getApFull()); bean.findByPrimaryKey(row.getId_allegatoArticolo()); return bean.delete(); } public ResParm delArticoloVariante(ArticoloVariante ab) { ArticoloVariante bean = new ArticoloVariante(getApFull()); bean.findByPrimaryKey(ab.getId_articoloVariante()); return bean.delete(); } public ResParm delCaratteristica(CaratteristicaArticolo ca) { CaratteristicaArticolo bean = new CaratteristicaArticolo(getApFull()); CaratteristicaArticoloKey caK = new CaratteristicaArticoloKey(ca.getId_articolo(), ca.getId_caratteristica()); bean.findByPrimaryKey(caK); ResParm rp = bean.delete(); if (rp.getStatus()) rp.append(aggiornaCaratteristiche()); return rp; } protected void deleteCascade() { String targetDir = getDocBase() + getDocBase(); deleteImmagini(); deleteImmaginiRiduzioni(null); ResParm rp = delete("delete from LISTINO_ARTICOLO where id_articolo=" + getId_articolo()); rp = delete("delete from ARTICOLO_VARIANTE where id_articolo=" + getId_articolo()); rp = delete("delete from ARTICOLO_FORNITORE where id_articolo=" + getId_articolo()); rp = delete("delete from WISHLIST where id_articolo=" + getId_articolo()); rp = delete("delete from CARATTERISTICA_ARTICOLO where id_articolo=" + getId_articolo()); Vectumerator vecAa = getAllegati(0L); while (vecAa.hasMoreElements()) { AllegatoArticolo rowAa = (AllegatoArticolo)vecAa.nextElement(); rowAa.delete(); } } public void deleteImmagini() { File dir = new File(getDocBase() + getDocBase()); FilenameFilter imgFilter = new FilenameFilter() { public boolean accept(File dir, String name) { if (name.indexOf("" + Articolo.this.getId() + "_") == 0 && name.toLowerCase().endsWith("jpg")) return true; return false; } }; File[] files = dir.listFiles(imgFilter); for (File currentImg : files) currentImg.delete(); } public void deleteImmaginiSporche() { File dir = new File(getDocBase() + getDocBase()); System.out.println("deleteImmaginiSporche: " + String.valueOf(dir)); FilenameFilter imgFilter = new FilenameFilter() { public boolean accept(File dir, String name) { if (name.indexOf("" + Articolo.this.getId_articolo() + "_") == 0 && name.toLowerCase().endsWith("jpg")) { if (Articolo.this.getImgTmst().isEmpty()) { if (name.indexOf("__") < 0) return true; return false; } if (name.indexOf(Articolo.this.getImgTmst()) < 0) return true; return false; } return false; } }; File[] files = dir.listFiles(imgFilter); for (File currentImg : files) { System.out.println("deleteImmaginiSporche: " + String.valueOf(currentImg)); currentImg.delete(); } } public ResParm delFornitore(ArticoloFornitore ca) { ArticoloFornitore bean = new ArticoloFornitore(getApFull()); bean.findByPrimaryKey(ca.getId_articoloFornitore()); return bean.delete(); } public void findArticoloByCodice(String l_codice) { String s_Sql_Find = "select A.* from ARTICOLO AS A"; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc("A.codice='" + prepareInputMySqlString(l_codice, false) + "'"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public void findArticoloByCodiceFornitore(long l_id_fornitore, String l_cf) { String s_Sql_Find = "select A.* from ARTICOLO AS A, ARTICOLO_FORNITORE AS B"; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc("A.id_articolo= B.id_articolo"); wc.addWc("B.id_fornitore=" + l_id_fornitore); wc.addWc("B.codiceFornitore='" + l_cf + "'"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public Vectumerator getAccessori() { return getAccessori(0L, 0L, -1L); } public Vectumerator getAccessoriDisponibili() { return new Accessorio(getApFull()).findById_articoloAssociati(getId_articolo(), true, 0, 0); } public Vectumerator getAllegati(long l_id_tipoAllegatoDocumento) { return new AllegatoArticolo(getApFull()).findByArticoloTipo(getId_articolo(), l_id_tipoAllegatoDocumento, 0, 0); } public ArticoloVariante getArticoloVarianteBase() { if (this.articoloVarianteBase == null && getId_articolo() != 0L) { ArticoloVarianteCR CRAv = new ArticoloVarianteCR(); CRAv.setId_articolo(getId_articolo()); CRAv.setFlgEscludiWeb(0L); Vectumerator vec = new ArticoloVariante(getApFull()).findByCR(CRAv, 0, 0); if (vec.hasMoreElements()) { int nRec = vec.getTotNumberOfRecords(); int nVar = (int)(Math.random() * (double)nRec); this.articoloVarianteBase = (ArticoloVariante)vec.get(nVar); } } if (this.articoloVarianteBase == null) { logDebug(true, "getArticoloVarianteBase--> articolo: " + getId_articolo() + " " + getNome() + " senza varianti!!"); return new ArticoloVariante(getApFull()); } return this.articoloVarianteBase; } public ArticoloVariante getArticoloVarianteBasePrimoVisibile() { if (this.articoloVarianteBase == null && getId_articolo() != 0L) { this.articoloVarianteBase = new ArticoloVariante(getApFull()); this.articoloVarianteBase.findPrimoVisibileByArticolo(getId_articolo()); } if (this.articoloVarianteBase == null) { logDebug(true, "getArticoloVarianteBase--> articolo: " + getId_articolo() + " " + getNome() + " senza varianti!!"); return new ArticoloVariante(getApFull()); } return this.articoloVarianteBase; } public Vectumerator findArticoliComponenti() { ArticoloCR CR = new ArticoloCR(); CR.setFlgArticoloComponente(1L); return findByCR(CR, 0, 0); } public static synchronized Articolo duplica(Articolo beanSrc) { if (beanSrc.getId_articolo() > 0L) { Articolo beanDup = new Articolo(beanSrc.getApFull()); beanDup.findByPrimaryKey(beanSrc.getId_articolo()); beanDup.setId_articolo(0L); beanDup.setDBState(0); beanDup.setNome(beanDup.getNome() + " -copia-"); beanDup.setCodice(beanDup.getCodice() + " -copia-"); ResParm rp = beanDup.save(); if (rp.getStatus()) { Vectumerator vecVa = beanSrc.findArticoliVarianti(-1L, -1L); while (vecVa.hasMoreElements() && rp.getStatus()) { ArticoloVariante row = (ArticoloVariante)vecVa.nextElement(); row.setId_articoloVariante(0L); row.setId_articolo(beanDup.getId_articolo()); row.setDBState(0); rp = row.save(); } String targetDir = beanSrc.getDocBase() + beanSrc.getDocBase(); for (int i = 0; i < 20; i++) { if (new File(targetDir + targetDir).exists()) try { DBAdapter.copyFile(targetDir + targetDir, targetDir + targetDir); } catch (Exception e) { e.printStackTrace(); } } DescTxtLang dtl = new DescTxtLang(beanSrc.getApFull()); Vectumerator vecdtl = dtl.findAllTxtByIdLangTable(beanSrc.getId_articolo(), "", "ARTICOLO"); while (vecdtl.hasMoreElements()) { DescTxtLang rowDtl = (DescTxtLang)vecdtl.nextElement(); rowDtl.setIdTabella(beanDup.getId_articolo()); rowDtl.setDBState(0); rowDtl.save(); } Vectumerator vecAa = beanSrc.getAllegati(0L); while (vecAa.hasMoreElements()) { AllegatoArticolo rowAa = (AllegatoArticolo)vecAa.nextElement(); String fullFileName = rowAa.getNomeFileCompleto(); rowAa.setId_allegatoArticolo(0L); rowAa.setDBState(0); rowAa.setId_articolo(beanDup.getId_articolo()); rp = rowAa.save(); if (rp.getStatus()) if (new File(fullFileName).exists()) try { DBAdapter.copyFile(fullFileName, rowAa.getNomeFileCompleto()); } catch (Exception e) { e.printStackTrace(); } } return beanDup; } return null; } return null; } public boolean isUsaSeriale() { return (getTipo().getFlgTipoMagazzino() == 2L); } public CaratteristicaArticolo getCaratteristicaArticolo(long l_id_caratteristica) { Long l_key = new Long(l_id_caratteristica); if (getCaratteristicheHT().containsKey(l_key)) return (CaratteristicaArticolo)getCaratteristicheHT().get(l_key); if (getApFull() != null) { CaratteristicaArticolo ca = new CaratteristicaArticolo(getApFull()); ca.findById_articoloId_caratteristica(getId_articolo(), l_id_caratteristica); getCaratteristicheHT().put(l_key, ca); return ca; } return new CaratteristicaArticolo(); } public CaratteristicaArticolo getCaratteristicaArticoloOld(long l_id_caratteristica) { CaratteristicaArticolo ca = new CaratteristicaArticolo(getApFull()); ca.findById_articoloId_caratteristica(getId_articolo(), l_id_caratteristica); return ca; } public Vectumerator getCaratteristicheArticolo() { return new CaratteristicaArticolo(getApFull()).findById_articolo(getId_articolo(), 0, 0); } public String getCartItemDescription(String lang) { return getNome() + " " + getNome(); } public String getCartItemDescription2(String lang) { if (getDescrizioneCommerciale(lang).isEmpty()) return getDescrizioneTecnica(lang); return getDescrizioneCommerciale(lang); } public String getCartItemDescription3(String lang) { return getNome(); } public String getCartItemImage() { if (getId_articoloVariante() > 0L) return (getId_articoloVarianteKit() > 0L) ? ("_var/" + getPathIdStepDir() + getArticoloVariante().getImgFileName(getId_articoloVarianteKit() * 10L + 1L)) : ("_var/" + getPathIdStepDir() + getArticoloVariante().getImgFileName(1)); return getPathIdStepDir() + getPathIdStepDir(); } public long getCartItemUdm() { return getFlgUdm(); } public String getCodice() { return (this.codice == null) ? "" : this.codice; } public String getCodiceProduttore() { return (this.codiceProduttore == null) ? "" : this.codiceProduttore; } public double getCost() { return getCostoNetto(); } public double getCostoMinimo() { double cm = 0.0D; Vectumerator vec = getFornitori(); while (vec.hasMoreElements()) { ArticoloFornitore af = (ArticoloFornitore)vec.nextElement(); if (cm == 0.0D) { cm = af.getCostoTotale(); continue; } cm = Math.min(af.getCostoTotale(), cm); } return cm; } public String getDatoStrutturato(String lang) { String dispo, condition; if (getId_articolo() == 0L) return ""; ArticoloCR CR = new ArticoloCR(); CR.setLang(lang); StringBuilder sb = new StringBuilder(""); return sb.toString(); } public String getItemConditionSchema() { if (getFlgStockOfferte() == 3L) return "https://schema.org/UsedCondition"; return "https://schema.org/NewCondition"; } public Date getDataAggiornamento() { return this.dataAggiornamento; } public Date getDataFineVld() { return this.dataFineVld; } public Date getDataScadenzaOfferta() { return getListinoArticoloBase().getDataScadenzaOffertaLA(); } public Date getDataScadenzaOffertaWeb() { if (getListinoArticoloBase().isOffertaValida()) return getListinoArticoloBase().getDataScadenzaOffertaLA(); if (getId_fornitoreCostoNuovo() > 0L && getDataScadenzaOffertaFornitore() != null && DBAdapter.getDateDiff(getToday(), getDataScadenzaOffertaFornitore()) >= 0L) return getDataScadenzaOffertaFornitore(); return null; } public Date getImportListinoDataScadenzaOfferta() { return this.dataScadenzaOfferta; } public String getDescFlgOfferta() { if (isOfferta()) { if (getDataScadenzaOfferta() == null) return "Si"; return "Si " + -getDateDiff(getDataScadenzaOfferta(), null); } if (this.flgStockOfferte == 1L) return "Scad."; return "No"; } public String getDescrizione(String lang) { String temp = super.getDescrizione(lang); if (temp.isEmpty()) temp = getNome(lang); if (getParm("DOC_ARTICOLI_CON_CODICE").isTrue()) temp = getCodice() + " " + getCodice(); return temp; } public String getDescrizione(String lang, int stringCaseType) { String str = new String(); str = convertStringCase(getDescrizione(lang), stringCaseType); return str; } public String getDescrizioneCommerciale(String lang) { if (lang.isEmpty()) lang = "it"; return getDescTxtLang("descrizioneCommerciale", lang); } public String getDescrizioneMarketplace(String lang) { if (lang.isEmpty()) lang = "it"; return getDescTxtLang("descrizioneMarketplace", lang); } public String getDescrizioneMarketplaceWeb(String lang) { String temp = getDescrizioneMarketplace(lang); if (temp.isEmpty()) return getDescrizioneMarketplace("it"); return temp; } public String getSpecifiche(String lang) { if (lang.isEmpty()) lang = "it"; return getDescTxtLang("specifiche", lang); } public String getDescrizioneBreveWeb(String lang) { String temp = getDescrizioneBreve(lang); if (temp.isEmpty()) return getDescrizioneBreve("it"); return temp; } public String getDescrizioneCommercialeWeb(String lang) { String temp = getDescrizioneCommerciale(lang); if (temp.isEmpty()) return getDescrizioneCommerciale("it"); return temp; } public String getSpecificheWeb(String lang) { String temp = getSpecifiche(lang); if (temp.isEmpty()) return getSpecifiche("it"); return temp; } public String getSpecificheScript(String lang) { return DBAdapter.prepareScriptString(getSpecifiche(lang)); } public String getNomeMarketplace(String lang) { if (lang.isEmpty()) lang = "it"; return getDescTxtLang("nomeMarketplace", lang); } public String getNomeMarketplaceWeb(String lang) { String temp = getNomeMarketplace(lang); if (temp.isEmpty()) return getNomeMarketplace("it"); return temp; } public String getDescrizioneBreve(String lang) { if (lang.isEmpty()) lang = "it"; return getDescTxtLang("descrizioneBreve", lang); } public String getDescrizioneBreveScript(String lang) { return DBAdapter.prepareScriptString(getDescrizioneBreve(lang)); } public String getDescrizioneCompletaSenzaCodice(String lang) { String l_nome = getNome(); if (lang != null) l_nome = getNome(lang); StringBuilder sb = new StringBuilder(); if (getId_articoloVariante() == 0L) { if (getId_articoloTaglia() > 0L) { sb.append((getMarca().getDescrizione() + " " + getMarca().getDescrizione()).trim() + " [" + (getMarca().getDescrizione() + " " + getMarca().getDescrizione()).trim() + "]"); } else { sb.append((getMarca().getDescrizione() + " " + getMarca().getDescrizione()).trim()); } } else if (getId_articoloTaglia() > 0L) { sb.append(getArticoloVariante().getDescrizioneCompletaSenzaCodice(lang) + " [" + getArticoloVariante().getDescrizioneCompletaSenzaCodice(lang) + "]"); } else { sb.append(getArticoloVariante().getDescrizioneCompletaSenzaCodice(lang)); } return sb.toString(); } public String getDescrizioneTecnica(String lang) { if (lang.isEmpty()) lang = "it"; return convertStringToHtml(getDescTxtLang("descrizioneTecnica", lang)); } public double getDiscount() { return getPercSconto(); } public Vectumerator getDisponibilitaMovimento() { RigaDocumentoCR CR = new RigaDocumentoCR(); CR.setId_articolo(getId_articolo()); CR.setFlgInMagazzino(3L); return new RigaDocumento(getApFull()).findMagSaldiArticoloByCR(CR, 0, 0); } public Vectumerator getDisponibilitaMovimentoM() { MovimentoCR CR = new MovimentoCR(); CR.setId_articolo(getId_articolo()); CR.setFlgInMagazzino(3L); return new Movimento(getApFull()).findSaldiArticoloByCR(CR, 0, 0); } public long getFlgAggiornaDati() { return this.flgAggiornaDati; } public long getFlgFuoriListino() { return this.flgFuoriListino; } public long getFlgNascondi() { return this.flgNascondi; } public long getFlgStato() { return this.flgStato; } public long getFlgStockOfferte() { return this.flgStockOfferte; } public long getFlgUdm() { return this.flgUdm; } public Vectumerator getFornitori() { return new ArticoloFornitore(getApFull()).findById_articolo(getId_articolo(), 0, 0); } public Vectumerator getProgettistiArticolo() { return new ArticoloProgettista(getApFull()).findByArticolo(getId_articolo()); } public long getId_articolo() { return this.id_articolo; } public long getId_articoloNext(ArticoloCR CR) { if (!isFlgNextPrev()) calcolaIdNextPrev(CR); return this.id_articoloNext; } public long getId_articoloPrev(ArticoloCR CR) { if (!isFlgNextPrev()) calcolaIdNextPrev(CR); return this.id_articoloPrev; } public long getId_articoloVarianteBaseNext(ArticoloCR CR) { if (!isFlgNextPrev()) calcolaIdVarianteNextPrev(CR); return this.id_articoloVarianteBaseNext; } public long getId_articoloVarianteBasePrev(ArticoloCR CR) { if (!isFlgNextPrev()) calcolaIdVarianteNextPrev(CR); return this.id_articoloVarianteBasePrev; } public long getId_iva() { return this.id_iva; } public long getId_marca() { return this.id_marca; } public long getId_tipo() { return this.id_tipo; } public long getId_tipoTaglia() { return this.id_tipoTaglia; } public String getImgFileName(long imgNumber) { return getImgFileName((int)imgNumber); } public String getImgFileName(int imgNumber, String l_Tmst) { return "" + getId_articolo() + "_" + getId_articolo() + "_" + l_Tmst + ".jpg"; } public Object getItemId() { if (getId_articoloTaglia() > 0L && getId_articoloTagliaKit() > 0L) return new Long(getId_articoloTaglia()); return new Long(getId_articolo()); } public Iva getIva() { this.iva = (Iva)getSecondaryObject(this.iva, Iva.class, new Long(getId_iva())); return this.iva; } public double getIvaAliquota(long l_id_users) { return (double)getIvaByUser(l_id_users).getAliquota(); } public double getIvaAliquota(Clifor l_clifor) { return (double)getIvaByClifor(l_clifor).getAliquota(); } public long getId_iva(Clifor l_clifor) { return getIvaByClifor(l_clifor).getId_iva(); } public final Iva getIvaByUser(long l_id_users) { if (l_id_users == 0L) return getIva(); Users user = new Users(getApFull()); user.findByPrimaryKey(l_id_users); return getIvaByClifor(user.getClifor()); } public final Iva getIvaByClifor(Clifor clifor) { if (clifor == null || clifor.getId_clifor() == 0L) return getIva(); if (clifor.getFlgRC() == 1L) { if (getFlgRC() == 1L || getTipo().getFlgRC() == 1L) return getIvaReverseCharge(); } else if (clifor.getFlgArt8() == 1L) { return getIvaArt8C(); } DestinazioneDiversa dd = clifor.getCurrentDD(); if (clifor.isPrezzoWebEsente()) { if (dd.getId_destinazioneDiversa() > 0L) { if (clifor.getNazione().getCodice().equals("IT") && clifor.getFlgAzienda() == 1L && dd.getNazioneDD().getFlgCee() == 1L) return getIvaArt58(); if (clifor.getNazione().getFlgCee() == 1L && !clifor.getNazione().getCodice().equals("IT") && clifor.getFlgAzienda() == 1L && dd.getNazioneDD().getFlgCee() == 1L) return getIvaArt41(); return getIvaArt8A(); } if (clifor.getNazione().getFlgCee() == 1L) return getIvaArt41(); return getIvaArt8A(); } if (clifor.isIvaCeeOneStopShop()) { boolean oss = false; if (clifor.getFlgAzienda() == 0L && clifor.getNazione().getFlgCee() == 1L && !clifor.getNazione().getCodice().equals("IT")) if (dd.getId_destinazioneDiversa() > 0L) { if (dd.getNazioneDD().getFlgCee() == 1L && !dd.getNazioneDD().getCodice().equals("IT")) { oss = true; } else { oss = false; } } else { oss = true; } if (oss) { Nazione nazioneOss; if (dd.getId_destinazioneDiversa() > 0L) { nazioneOss = dd.getNazioneDD(); } else { nazioneOss = clifor.getNazione(); } if (nazioneOss.getId_iva() != 0L) return nazioneOss.getIva(); handleDebug("ERRORE! Articolo.getIvaByClifor Aliquota iva OSS per " + nazioneOss.getDescrizione() + " non impostata!!!!", 1); return getIva(); } return getIva(); } return getIva(); } public long getIvaItemId(long l_id_users) { return getIvaByUser(l_id_users).getId_iva(); } public String getLinkPreview() { if (getApFull() != null) { String temp = getParm("SERVERNAME").getTesto(); return temp + "Catalogo.abl?cmd=md&id_articolo=" + temp + "&id_tipoMenu=" + getId_articolo() + "&id_tipoSel=" + getId_tipo(); } return ""; } public String getLinkAmazon() { StringBuilder sb = new StringBuilder(); if (!getAsinAmz().isEmpty()) { if (sb.length() > 0) sb.append(", "); sb.append(""); sb.append("AZ_" + getAsinAmz()); sb.append(""); } else if (!getCodiceEan().isEmpty()) { if (sb.length() > 0) sb.append(", "); sb.append(""); sb.append("AZ_" + getCodiceEanNoZero()); sb.append(""); } return sb.toString(); } public Marca getMarca() { this.marca = (Marca)getSecondaryObject(this.marca, Marca.class, new Long(getId_marca())); return this.marca; } public long getMesigar() { return this.mesigar; } public String getNascondi() { return getNascondi(getFlgNascondi()); } public String getNome() { return (this.nome == null) ? "" : this.nome.trim(); } public String getCCNome(String lang) { StringBuilder sb = new StringBuilder(); sb.append(getMarca().getDescrizione()); sb.append(" "); if (!getDescrizioneBreve(lang).isEmpty() && getDescrizioneBreve(lang).length() < getNome(lang).length()) { sb.append(getDescrizioneBreve(lang).replace("/", "/ ")); } else { sb.append(getNome(lang).replace("/", "/ ")); } if (getId_articoloVariante() > 0L) { sb.append(" "); sb.append(getArticoloVariante().getNomeV(lang)); } if (!getCodiceProduttore().isEmpty()) { sb.append(" "); sb.append(getCodiceProduttore()); } return eliminaDoppioniInStringa(sb.toString()); } public String getCCNomeUrl(String lang) { return convertStringToLink(getNome(lang)); } public long getOrdine() { return this.ordine; } public String getPathAllegato() { return getDocBase() + getDocBase(); } public String getPathAllegatoOld() { return (this.pathAllegatoOld == null) ? "" : this.pathAllegatoOld; } public String getPathTmp() { return getDocBase() + getDocBase(); } public double getPercSconto() { return getListinoArticoloBase().getPercEffettiva(); } public double getImportListinoPercSconto() { return this.percSconto; } public double getPesoKg() { return this.pesoKg; } public long getPrenotatiArt() { return this.prenotatiArt; } public double getCostoAcquistoUltimoConIva(Clifor l_clifor) { if (getId_articolo() != 0L && l_clifor.getId_clifor() != 0L) { Vectumerator vec = new ArticoloFornitore(getApFull()).findById_articoloFornitore(getId_articolo(), l_clifor.getId_clifor(), 1, 1); if (vec.hasMoreElements()) { ArticoloFornitore af = (ArticoloFornitore)vec.nextElement(); return af.getCostoTotaleIvato(); } return getCostoAcquistoUltimoConIva(); } return getCostoAcquistoUltimoConIva(); } public double getCostoAcquisto() { if (getCostoNetto() != 0.0D) return getCostoNetto(); return getCostoAcquistoUltimo(); } public double getPrezzoPubblico() { return getPrezzoPubblico(null); } public double getCostoNettoIva() { return DBAdapter.conIva(getCostoNetto(), (double)getIva().getAliquota()); } public double getPrezzoVendor() { return this.prezzoVendor; } public double getPrice() { return getPrezzoPubblico(null); } public double getPriceWVat() { return getPrezzoPubblicoIva(null); } public double getQuantitaData(Date data) { if (!isQuantitaDataCalcolate()) { this.quantitaData = getQuantita(data); setQuantitaDataCalcolate(true); } return this.quantitaData; } public Articolo getRandomArticolo() { String s_Sql_Find = "select A.* from ARTICOLO AS A"; String wc = ""; wc = buildWc(wc, "A.flgOfferta =1"); wc = buildWc(wc, "(A.dataScadenzaOfferta>? or A.dataScadenzaOfferta is null )"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find); Calendar cal = Calendar.getInstance(); Date today = new Date(cal.getTimeInMillis()); stmt.setDate(1, today); Vectumerator vec = findRows(stmt, 0, 0); if (!vec.hasMoreElements()) vec = findAll(); int totRecords = vec.getTotNumberOfRecords(); if (totRecords > 0) { int idx = (int)(Math.random() * (double)totRecords); return (Articolo)vec.elementAt(idx); } return new Articolo(getApFull()); } catch (Exception e) { handleDebug(e); return new Articolo(getApFull()); } } public double getRicaricoBase() { return this.ricaricoBase; } public double getRicaricoPAMax() { return getRicaricoCalc(getCostoAcquistoUltimo()); } public double getRicaricoPAMin() { return getRicaricoCalc(getCostoAcquistoUltimo()); } public String getStato() { return getStato(getFlgStato()); } public String getStockOfferte() { return getStockOfferte(getFlgStockOfferte()); } public double getStreetPrice() { return this.streetPrice; } public Vectumerator getTaglie() { return new Taglia(getApFull()).findById_articolo(getId_articolo(), 0, 0); } public double getPrezzoVenditaConfezioneCalcolatoSuCosto() { if (getId_articolo() == 0L || getPercRicarico() <= 0.0D || getTotCostoConfezione() <= 0.0D) return 0.0D; DoubleOperator dop = new DoubleOperator(getPercRicarico()); dop.setScale(4, 5); dop.add(100); dop.multiply(getTotCostoConfezione()); dop.divide(100.0F); return dop.getResult(); } public double getPrezzoVenditaCalcolatoSuCostoNetto() { if (getId_articolo() == 0L || getPercRicarico() <= 0.0D || getCostoNetto() <= 0.0D) return 0.0D; DoubleOperator dop = new DoubleOperator(getPercRicarico()); dop.setScale(4, 5); dop.add(100); dop.multiply(getCostoNetto()); dop.divide(100.0F); return dop.getResult(); } public Tipo getTipo() { this.tipo = (Tipo)getSecondaryObject(this.tipo, Tipo.class, getId_tipo()); return this.tipo; } public TipoTaglia getTipoTaglia() { this.tipoTaglia = (TipoTaglia)getSecondaryObject(this.tipoTaglia, TipoTaglia.class, getId_tipoTaglia()); return this.tipoTaglia; } public String getUdm() { return getUdm(getFlgUdm()); } public String getUdmQuantita() { return getUdm() + " " + getUdm(); } public long getVolumeCm3() { return this.volumeCm3; } public boolean hasAllegati() { return getAllegati(0L).hasMoreElements(); } public ResParm impostaVisibilita(ArticoloCR CR) { String s_Sql_Find = "UPDATE ARTICOLO as A SET flgNascondi=" + CR.getFlgNascondiNew(); WcString wc = new WcString(); if (CR.getId_articolo() != 0L) wc.addWc("A.id_articolo=" + CR.getId_articolo()); if (CR.getId_tipo() != 0L) wc.addWc("A.id_tipo=" + CR.getId_tipo()); if (CR.getId_marca() != 0L) wc.addWc("A.id_marca=" + CR.getId_marca()); if (CR.getFlgNascondi() >= 0L) if (CR.getFlgNascondi() == 0L) { wc.addWc("(A.flgNascondi=0 or A.flgNascondi is null)"); } else { wc.addWc("A.flgNascondi=" + CR.getFlgNascondi()); } return update(s_Sql_Find + s_Sql_Find); } protected void initFields() { super.initFields(); setFlgNextPrev(false); setId_articoloVarianteBaseNext(0L); setId_articoloVarianteBasePrev(0L); setId_articoloVariante(0L); setFlgStampaEtichette(-1L); setFlgStampaAccessori(-1L); setFlgEscludiWebArt(-1L); setFlgUsaVariantiArt(-1L); setFlgStampaAccessori(-1L); setQuantitaCalcolate(false); setQuantitaEffettiva(0.0D); setQuantitaImpegnata(0.0D); setQuantitaInArrivo(0.0D); setCaratteristicheHT(null); setQuantitaW(0.0D); setListinoArticoloBase(null); setPrezzoArticolo(null); setPrezzoArticoloIva(null); setQuantitaData(0.0D); setQuantitaDB(0.0D); setDescrizioneCaratteristiche(null); setTotCostoConfezione(-1.0D); setListinoArticoloBase(null); setSitemapPriority(80L); setQtaEbay(2L); } public boolean isFlgNextPrev() { return this.flgNextPrev; } public boolean isImgExist(int imgNumber) { String targetDir = getDocBase() + getDocBase(); return isFileExist(targetDir + targetDir); } public boolean isOfferta() { if (getFlgStockOfferte() != 1L) return false; if (getDataScadenzaOfferta() == null) return true; if (getDateDiff(getDataScadenzaOfferta(), getToday()) > 0L) return false; return true; } public boolean isRM() { return false; } public boolean isSale() { return !(getPercSconto() == 0.0D); } protected void prepareSave(PreparedStatement ps) throws SQLException { if (getVolumeM3() > 0.0D) setVolumeCm3(0L); String temp = getCodiciAlternativi(); if (!temp.isEmpty()) { if (!temp.startsWith(",")) temp = "," + temp; if (!temp.endsWith(",")) temp = temp + ","; } setCodiciAlternativi(temp.replace(", ", ",")); temp = getCategoriaImport(); if (!temp.isEmpty()) { if (!temp.startsWith(",")) temp = "," + temp; if (!temp.endsWith(",")) temp = temp + ","; } setCategoriaImport(temp.replace(", ", ",")); if (getCategoriaImport().length() > 1000) setCategoriaImport(getCategoriaImport().substring(0, 999)); temp = getTagArticolo(); if (!temp.isEmpty()) { if (!temp.startsWith(",")) temp = "," + temp; if (!temp.endsWith(",")) temp = temp + ","; } setTagArticolo(temp.replace(", ", ",")); if (getFlgNoListinoArt() == -1L) { setFlgNoListino(getTipo().getFlgNoListinoEffettivo()); } else { setFlgNoListino(getFlgNoListinoArt()); } if (getFlgUsaVariantiArt() == -1L) { setFlgUsaVarianti(getTipo().getFlgUsaVarianti()); } else { setFlgUsaVarianti(getFlgUsaVariantiArt()); } if (getFlgKitArt() == -1L) { setFlgKit(getTipo().getFlgKit()); } else { setFlgKit(getFlgKitArt()); } if (getFlgEscludiWebArt() == -1L) { setFlgEscludiWeb(getTipo().getFlgEscludiWeb()); } else { setFlgEscludiWeb(getFlgEscludiWebArt()); } setFlgTipoMagazzino(getTipo().getFlgTipoMagazzino()); if (!usaMagazzino()) setFlgDispo(1L); if (getFlgArticoloComponente() == 1L) { setFlgUsaVarianti(0L); setFlgUsaVariantiArt(0L); } if (getFlgGoogleDB() == 1L && getFlgGoogle() == 0L) setGoogleFeedFileName(null); if (getFlgUsato() == 0L) if (getId_statoUsato() > 3L) setId_statoUsato(1L); super.prepareSave(ps); } public void setArticoloVarianteBase(ArticoloVariante articoloVarianteBase) { this.articoloVarianteBase = articoloVarianteBase; } public void setCodice(String codice) { this.codice = codice; } public void setCodiceProduttore(String codiceProduttore) { this.codiceProduttore = codiceProduttore; } public void setDataAggiornamento(Date dataAggiornamento) { this.dataAggiornamento = dataAggiornamento; } public void setDataFineVld(Date newDataFineVld) { this.dataFineVld = newDataFineVld; } public String getDescrizioneFornitori() { if (getId_articolo() == 0L) return ""; StringBuilder sb = new StringBuilder(); Vectumerator vec = new ArticoloFornitore(getApFull()).findById_articolo(getId_articolo(), 0, 0); while (vec.hasMoreElements()) { ArticoloFornitore af = (ArticoloFornitore)vec.nextElement(); if (sb.length() > 0) sb.append(";"); sb.append(af.getFornitore().getCognomeNome()); } return sb.toString(); } public void setDataScadenzaOfferta(Date dataScadenzaOfferta) { this.dataScadenzaOfferta = dataScadenzaOfferta; } public void setDescrizioneCommerciale_it(String descrizioneCommerciale_it) { this.descrizioneCommerciale_it = descrizioneCommerciale_it; } public void setFlgAggiornaDati(long flgAggiornaDati) { this.flgAggiornaDati = flgAggiornaDati; } public void setFlgFuoriListino(long flgFuoriListino) { this.flgFuoriListino = flgFuoriListino; } public void setFlgNascondi(long l) { this.flgNascondi = l; } public void setFlgNextPrev(boolean flgNextPrev) { this.flgNextPrev = flgNextPrev; } public void setFlgStato(long flgStato) { this.flgStato = flgStato; } public void setFlgStockOfferte(long newFlgStockOfferte) { this.flgStockOfferte = newFlgStockOfferte; } public void setFlgUdm(long flgUdm) { this.flgUdm = flgUdm; } public void setId_articolo(long newId_articolo) { this.id_articolo = newId_articolo; } public void setId_articoloNext(long id_articoloNext) { this.id_articoloNext = id_articoloNext; } public void setId_articoloPrev(long id_articoloPrev) { this.id_articoloPrev = id_articoloPrev; } public void setId_articoloVarianteBaseNext(long id_articoloNext) { this.id_articoloVarianteBaseNext = id_articoloNext; } public void setId_articoloVarianteBasePrev(long id_articoloPrev) { this.id_articoloVarianteBasePrev = id_articoloPrev; } public void setId_iva(long newId_iva) { this.id_iva = newId_iva; setIva(null); } public void setId_marca(long newId_marca) { this.id_marca = newId_marca; setMarca(null); } public void setId_tipo(long id_tipo) { this.id_tipo = id_tipo; setTipo(null); } public void setId_tipoTaglia(long newId_tipoTaglia) { this.id_tipoTaglia = newId_tipoTaglia; setTipoTaglia(null); } public void setIva(Iva newIva) { this.iva = newIva; } public void setMarca(Marca newMarca) { this.marca = newMarca; } public void setMesigar(long mesigar) { this.mesigar = mesigar; } public void setNome(String nome) { this.nome = nome; } public void setOrdine(long ordine) { this.ordine = ordine; } public void setPercSconto(double percSconto) { this.percSconto = percSconto; } public void setPesoKg(double pesoKg) { this.pesoKg = pesoKg; } public void setPrenotatiArt(long newGiacenza) { this.prenotatiArt = newGiacenza; } public void setPrezzoVendor(double prezzoVendor) { this.prezzoVendor = prezzoVendor; } public void setQuantita(double l_quantita) { this.quantita = l_quantita; } public void setRicaricoBase(double l) { this.ricaricoBase = l; } public void setStreetPrice(double streetPrice) { this.streetPrice = streetPrice; } public void setTipo(Tipo tipo) { this.tipo = tipo; } public void setTipoTaglia(TipoTaglia newTipoTaglia) { this.tipoTaglia = newTipoTaglia; } public void setVolumeCm3(long volumeCm3) { this.volumeCm3 = volumeCm3; } protected boolean useNullFor0() { return false; } public Vectumerator findById_tabellaTaglia(long l_id, int pageNumber, int pageRows) { String s_Sql_Find = "select A.* from ARTICOLO_TABELLA_TAGLIA AS A, ARTICOLO AS B"; String s_Sql_Order = " order by B.nome"; WcString wc = new WcString(); wc.addWc("A.id_articolo=B.id_articolo"); wc.addWc("A.id_tabellaTaglia=" + l_id); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); return findRows(stmt, pageNumber, pageRows); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public void findByCodice(String l_codice) { String s_Sql_Find = "select A.* from ARTICOLO AS A"; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc("A.codice='" + prepareInputMySqlString(l_codice, false) + "'"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public void findByEbayItemId(String l_ebayItemId) { String s_Sql_Find = "select A.* from ARTICOLO AS A"; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc("A.ebayItemId='" + l_ebayItemId + "'"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public void findByCodiceFornitoreSerie(String l_codiceFornitore, String serie) { String s_Sql_Find = "select A.* from ARTICOLO AS A"; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc(" A.codiciAlternativi LIKE '%," + l_codiceFornitore + ",%'"); if (!serie.isEmpty()) wc.addWc(" A.codice LIKE '" + serie + "%'"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public void findByAsinAmz(String l_asinAmz) { String s_Sql_Find = "select A.* from ARTICOLO AS A"; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc(" A.asinAmz like '%" + l_asinAmz + "'"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public void findByCodiceEanSerie(String l_codiceEan, String serie) { String s_Sql_Find = "select A.* from ARTICOLO AS A"; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc(" A.codiceEan like '%" + l_codiceEan + "'"); if (serie != null && !serie.isEmpty()) wc.addWc(" A.codice LIKE '" + serie + "%'"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public long getId_tabellaTaglia() { return this.id_tabellaTaglia; } public TabellaTaglia getTabellaTaglia() { this.tabellaTaglia = (TabellaTaglia)getSecondaryObject(this.tabellaTaglia, TabellaTaglia.class, getId_tabellaTaglia()); return this.tabellaTaglia; } public void setId_tabellaTaglia(long newId_tabellaTaglia) { this.id_tabellaTaglia = newId_tabellaTaglia; setTabellaTaglia(null); } public void setTabellaTaglia(TabellaTaglia newTabellaTaglia) { this.tabellaTaglia = newTabellaTaglia; } public Vectumerator findRandomArticoli(long l_id_vetrina, int numRecord, boolean disponibili) { String s_Sql_Find = "select A.* from ARTICOLO AS A"; s_Sql_Find = "SELECT A.*,B.id_articoloVariante as id_articoloVariante, B.flgNascondi AS flgNascondi_variante, C.flgNascondi AS flgNascondi_tipo, B.id_vetrina as v2 FROM TIPO AS C INNER JOIN (ARTICOLO AS A LEFT JOIN ARTICOLO_VARIANTE AS B ON A.id_articolo = B.id_articolo) ON C.id_tipo = A.id_tipo"; WcString wc = new WcString(); wc.addWc("(A.flgEscludiWeb=0 or A.flgEscludiWeb is null)"); wc.addWc("(A.flgNascondi=0 or A.flgNascondi is null)"); wc.addWc("(B.flgNascondi=0 or B.flgNascondi is null)"); wc.addWc("(C.flgNascondi=0 or C.flgNascondi is null)"); if (disponibili) wc.addWc("A.quantita>0"); if (l_id_vetrina > 0L) wc.addWc("(A.id_vetrina=" + l_id_vetrina + " or B.id_vetrina=" + l_id_vetrina + ")"); long qta = getParm("QTA_MINIMA_VISIBILE").getNumeroLong(); if (qta > 0L) wc.addWc("B.quantitaAV > " + qta); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find); Vectumerator vec = findRows(stmt, 0, 0); if (!vec.hasMoreElements()) return AB_EMPTY_VECTUMERATOR; int totRecords = vec.getTotNumberOfRecords(); if (totRecords <= numRecord) { Vectumerator vectumerator = new Vectumerator(); while (vec.hasMoreElements()) { Articolo row = (Articolo)vec.nextElement(); if (row.getId_articoloVariante() == 0L) { vectumerator.add(row); continue; } ArticoloVariante av = new ArticoloVariante(getApFull()); av.findByPrimaryKey(row.getId_articoloVariante()); vectumerator.add(av); } return vectumerator; } Vectumerator vec2 = new Vectumerator(); Hashtable idxH = new Hashtable(); for (int i = 0; i < numRecord; i++) { int idx; do { idx = (int)(Math.random() * (double)totRecords); } while (idxH.containsKey(new Integer(idx))); idxH.put(new Integer(idx), ""); Articolo row = (Articolo)vec.get(idx); if (row.getId_articoloVariante() == 0L) { vec2.add(row); } else { ArticoloVariante av = new ArticoloVariante(getApFull()); av.findByPrimaryKey(row.getId_articoloVariante()); vec2.add(av); } } return vec2; } catch (Exception e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public long getId_articoloVariante() { return this.id_articoloVariante; } public void setId_articoloVariante(long id_articoloVariante) { this.id_articoloVariante = id_articoloVariante; setArticoloVariante(null); } public ResParm aggiornaQuantita(long l_flgUdm, double l_qta) { setFlgUdm(l_flgUdm); setQuantita(l_qta); handleQuantitaDebugBeforeSave("aggiornaQuantita"); return super.save(); } public ResParm azzeraQuantita() { return azzeraQuantita(getFlgModImportazione()); } public ResParm azzeraQuantita(long l_flgModImportazione) { ResParm rp; if (getParm("USA_MAGAZZINO").isTrue()) { if (getId_articolo() > 0L) { String s_sql_sqring; if (getId_fornitoreCostoNuovo() == 0L) { s_sql_sqring = "UPDATE ARTICOLO_FORNITORE SET dispSede=0, dispCash=0 where id_articolo=" + getId_articolo(); } else { s_sql_sqring = "UPDATE ARTICOLO_FORNITORE SET dispSede=0, dispCash=0 where id_articolo=" + getId_articolo() + " and id_clifor=" + getId_fornitoreCostoNuovo(); } rp = update(s_sql_sqring); if (rp.getStatus()) if (getId_fornitoreCostoNuovo() > 0L) { rp = aggiornaPrezziEDispoByFornitori(0.0D, false); } else { setQuantita(0.0D); handleQuantitaDebugBeforeSave("aggiornaQuantita"); rp = super.save(); } } else { rp = new ResParm(false, "Articolo non selezionato"); } } else { rp = new ResParm(false, "Attenzione! Gestione magazzino tramite movimenti!"); } return rp; } public long getFlgAggGiacenza() { return this.flgAggGiacenza; } public void setFlgAggGiacenza(long flgAggGiacenza) { this.flgAggGiacenza = flgAggGiacenza; } public String getCodiciAlternativi() { return (this.codiciAlternativi == null) ? "" : this.codiciAlternativi.trim(); } public void setCodiciAlternativi(String codiciAlternativi) { this.codiciAlternativi = codiciAlternativi; } public String getDescrizione() { if (getId_articoloVariante() == 0L) return getDescrizione("it"); return getArticoloVariante().getDescrizione("it"); } public double getAvail() { if (getQtaMaxAcquistoWww() < 0L) return 0.0D; if (getQtaMaxAcquistoWww() == 0L) return getQuantitaEffettiva(); return Math.min(getQuantitaEffettiva(), (double)getQtaMaxAcquistoWww()); } public ByteArrayOutputStream creaLabelArticoloA4Pdf(ArticoloCR CR) { long pHMarg = getParm("LABEL_ART_A4_MARGINE").getNumeroLong(); long l_indent = 4L; ByteArrayOutputStream ba = new ByteArrayOutputStream(); try { this.document = new Document(PageSize.A4, 0.0F, 0.0F, 0.0F, 0.0F); this.writer = PdfWriter.getInstance(this.document, ba); this.document.open(); long labelNumber = 0L; String dim = getParm("LABEL_ART_A4_COL_ROW").getTesto(); int nCol = Integer.parseInt(dim.substring(0, dim.indexOf(','))); int nRow = Integer.parseInt(dim.substring(dim.indexOf(',') + 1)); float[] widths = { 0.25F, 0.25F, 0.25F, 0.25F }; this.pdfPcorpo = new PdfPTable(widths); this.pdfPcorpo.setWidthPercentage(100.0F); if (CR.getBlankLabels() > 0L) { PdfPCell cell = new PdfPCell(); cell.setFixedHeight((PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow); cell.setIndent((float)l_indent); cell.setBorder(0); for (int i = 0; (long)i < CR.getBlankLabels(); i++) { labelNumber++; this.pdfPcorpo.addCell(cell); } } if (CR.getId_articolo() != 0L) { findByPrimaryKey(CR.getId_articolo()); labelNumber = (long)addLabelUnArticoloA4Pdf("", nRow, CR.getNumLabels(), null, CR.getId_articoloVariante()); } else { Vectumerator vec = findByCR(CR, 0, 0); while (vec.hasMoreElements()) { Articolo rowBean = (Articolo)vec.nextElement(); labelNumber += (long)rowBean.addLabelUnArticoloA4Pdf("", nRow, CR.getNumLabels(), null, CR.getId_articoloVariante()); } } if (labelNumber == 0L) { Phrase ph = new Phrase("Attenzione! Non ci sono etichette da stampare!"); PdfPCell cell = new PdfPCell(ph); cell.setFixedHeight((PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow); cell.setIndent((float)l_indent); cell.setBorder(0); cell.setColspan(nCol); this.pdfPcorpo.addCell(cell); } else { long numberBlankCell = (long)nCol - labelNumber % (long)nCol; PdfPCell cell = new PdfPCell(); cell.setFixedHeight((PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow); cell.setIndent((float)l_indent); cell.setBorder(0); if (numberBlankCell != (long)nCol) for (int i = 0; (long)i < numberBlankCell; i++) this.pdfPcorpo.addCell(cell); } this.document.add((Element)this.pdfPcorpo); this.document.close(); this.document = null; } catch (Exception e) { e.printStackTrace(); } return ba; } public ResParm save() { updateHashCodeCurrent(); ResParm rp = super.save(); if (rp.getStatus()) { setDescrizioneSearch(getBuildedDescSearch()); updateErroriSeo(); String temp = getTipo().getIndici() + getTipo().getIndici(); if (temp.length() > 254) { setIdTipoSearch(temp.substring(0, 254)); } else { setIdTipoSearch(temp); } setTipoOrdineSearch(getTipo().getOrdine()); setTipoDescrizioneSearch(getTipo().getDescrizione()); if (getCodice().isEmpty()) setCodice(zeroLeft(getId_articolo(), 10)); setDescTxtLang("descrizione", "it", getNome()); if (!getSimboliLavaggio().hasAlmenoUnSimbolo()) { SimboliLavaggio sl = getSimboliLavaggioDefault(); if (sl != null) { setLavaggio((long)sl.getLavaggio().getCodiceSimbolo()); setCandeggio((long)sl.getCandeggio().getCodiceSimbolo()); setStiratura((long)sl.getStiratura().getCodiceSimbolo()); setPulituraSecco((long)sl.getPulituraSecco().getCodiceSimbolo()); setAsciugatura((long)sl.getAsciugatura().getCodiceSimbolo()); } } if (getId_fornitoreCostoNuovo() == 0L) setDataScadenzaOffertaFornitore(null); if (getTipo().getFlgControlloCostiAggFor() == 0L) { setFlgControlloCostoAggArt(1L); } else { ArticoloFornitore af = new ArticoloFornitore(getApFull()); setFlgControlloCostoAggArt(af.checkControlloAggiuntivoByArticolo(getId_articolo()) ? 1L : 0L); } return super.save(); } return rp; } private String getBuildedDescSearch() { StringBuilder sb = new StringBuilder(); if (!getKeywords().isEmpty()) sb.append(getKeywords()); StringBuilder l_readyForweb = new StringBuilder(); String lingue = getParm("LANG_AVAILABLE").getTesto(); if (lingue.isEmpty()) lingue = "it"; StringTokenizer st = new StringTokenizer(lingue, ","); while (st.hasMoreTokens()) { String l_currentLang = st.nextToken().trim(); if (isReadyForWeb(l_currentLang)) { l_readyForweb.append(","); l_readyForweb.append(l_currentLang); } sb.append(getTipo().getDescrizioneCompletaSpaces(l_currentLang)); sb.append(" "); sb.append(getNome(l_currentLang)); sb.append(" "); sb.append(getDescrizioneBreve(l_currentLang)); sb.append(" "); } l_readyForweb.append(","); setReadyForWeb(l_readyForweb.toString()); sb.append(" "); sb.append(getMarca().getDescrizione()); sb.append(" "); sb.append(getNome()); sb.append(" "); if (!getCodiceEan().isEmpty()) { sb.append(getCodiceEan()); sb.append(" "); } if (!getCodiceProduttore().isEmpty()) { sb.append(getCodiceProduttore()); sb.append(" "); } Vectumerator vecCa = getCaratteristicheArticolo(); while (vecCa.hasMoreElements()) { CaratteristicaArticolo rowCa = (CaratteristicaArticolo)vecCa.nextElement(); sb.append(rowCa.getVal()); sb.append(" "); } String descSearch = eliminaDoppioniInStringa( sb.toString().toLowerCase().replace('/', ' ').replace('\\', ' ').replace("(", "").replace(")", ""), 2, true); if (descSearch.length() > 1000) return descSearch.substring(0, 990); return descSearch; } public void updateErroriSeo() { StringBuilder sb = new StringBuilder(); String br = "
"; if (getParm("SEO_VERSION").getNumeroLong() == 0L) { if ((long)getCCSeoTitle("it").length() > 60L) { sb.append("Titolo pagina troppo lungo(>60): " + getCCSeoTitle("it").length()); sb.append("
"); } if ((long)getCCTagH1("it").length() > 70L) { sb.append("Tag H1 troppo lungo(>70): " + getCCTagH1("it").length()); sb.append("
"); } if ((long)getCCTagH2Web("it").length() > 70L) { sb.append("Tag H2 troppo lungo(>70): " + getCCTagH2Web("it").length()); sb.append("
"); } String link = getCCLinkDettaglio(new ArticoloCR()); if ((long)link.length() > 80L) { sb.append("Link Url troppo lungo (>80): " + link.length()); sb.append("
"); } if ((long)getCCMetaDescriptionWeb("it").length() > 150L) { sb.append("Meta Description troppo lunga(>150): " + getCCMetaDescriptionWeb("it").length()); sb.append("
"); } } else if (getParm("SEO_VERSION").getNumeroLong() == 1L) { if ((long)getTFSeoTitle("it").length() > 60L) { sb.append("Titolo pagina troppo lungo(>60): " + getTFSeoTitle("it").length()); sb.append("
"); } if ((long)getCCTagH1("it").length() > 70L) { sb.append("Tag H1 troppo lungo(>70): " + getCCTagH1("it").length()); sb.append("
"); } if ((long)getCCTagH2Web("it").length() > 70L) { sb.append("Tag H2 troppo lungo(>70): " + getCCTagH2Web("it").length()); sb.append("
"); } String link = getCCLinkDettaglio(new ArticoloCR()); if ((long)link.length() > 80L) { sb.append("Link Url troppo lungo (>80): " + link.length()); sb.append("
"); } if ((long)getTFMetaDescriptionWeb("it").length() > 150L) { sb.append("Meta Description troppo lunga(>150): " + getTFMetaDescriptionWeb("it").length()); sb.append("
"); } } setErroriSeo(sb.toString()); } public ResParm aggiornaCodice(String l_codice) { setCodice(l_codice); return super.save(); } public String getSeriale() { return (this.seriale == null) ? "" : this.seriale.trim(); } public void setSeriale(String seriale) { this.seriale = seriale; } public long getFlgUsaVarianti() { return this.flgUsaVarianti; } public void setFlgUsaVarianti(long flgUsaVarianti) { this.flgUsaVarianti = flgUsaVarianti; } public Vectumerator findArticoliTessuto() { ArticoloArticoloTessuto atf = new ArticoloArticoloTessuto(getApFull()); return atf.findByArticolo(getId_articolo()); } public ArticoloVariante getArticoloVariante() { this.articoloVariante = (ArticoloVariante)getSecondaryObject(this.articoloVariante, ArticoloVariante.class, getId_articoloVariante()); return this.articoloVariante; } public void setArticoloVariante(ArticoloVariante newArticoloVariante) { this.articoloVariante = newArticoloVariante; } public Vectumerator findByCRAvx(ArticoloCR CR, int pageNumber, int pageRows) { if (CR.getFlgTipoRicerca() == 1L) return findByCRSerMovimento(CR, pageNumber, pageRows); String s_Sql_Find1 = "select C.id_articoloTaglia, B.id_articoloVariante as id_articoloVariante, A.* from ARTICOLO AS A JOIN ARTICOLO_VARIANTE AS B ON A.id_articolo=B.id_articolo LEFT JOIN ARTICOLO_TAGLIA AS C ON A.id_articolo=C.id_articolo AND B.id_articoloVariante=C.id_articoloVariante"; String s_Sql_Find2 = "select C.id_articoloTaglia, 0 as id_articoloVariante, A.* from ARTICOLO AS A LEFT JOIN ARTICOLO_TAGLIA AS C ON A.id_articolo=C.id_articolo and (C.id_articoloVariante is null or C.id_articoloVariante=0) "; String s_Sql_Order = " order by A.nome, A.descrizione_it"; WcString wc = new WcString(); StringBuffer wcArt = new StringBuffer("("); StringBuffer wcArtVar = new StringBuffer("("); if (!CR.getSearchTxt().trim().isEmpty()) { String star = ""; String temp = CR.getSearchTxt().trim(); temp = prepareInputMySqlString(temp, true); temp = temp.replace("*", "%"); StringTokenizer st = new StringTokenizer(temp.trim(), " "); while (st.hasMoreTokens()) { String token = star + star; wcArt.append("(A.codice like '" + token + "%' or A.nome like '" + token + "%' or A.codiciAlternativi like '%," + token + ",%')"); wcArtVar.append("(A.codice like '" + token + "%' or A.nome like '" + token + "%' or B.codiceVariante like '" + token + "%' or B.codiciAlternativiV like '%," + token + ",%' or B.nomeV like '" + token + "%')"); if (st.hasMoreTokens()) { wcArt.append(" and "); wcArtVar.append(" and "); star = "%"; } } wcArt.append(")"); wcArtVar.append(")"); } if (wcArt.length() > 2) { wc.addWc("(" + wcArt.toString() + " and (A.flgUsaVarianti=0 or A.flgUsaVarianti is null) and A.flgNascondi>-1 and A.dataFineVld is null) OR (" + wcArtVar.toString() + " and B.id_articoloVariante Is Not Null AND A.flgUsaVarianti=1 and A.flgNascondi>-1 and A.dataFineVld is null)"); } else { wc.addWc("A.flgUsaVarianti=0 OR (B.id_articoloVariante Is Not Null AND A.flgUsaVarianti=1 and A.flgNascondi>-1 and A.dataFineVld is null)"); } String wcSql1 = wc.toString(); wc.addWc("A.flgUsaVarianti=0"); String wcSql2 = wc.toString(); try { PreparedStatement stmt = getConn() .prepareStatement(s_Sql_Find1 + s_Sql_Find1 + wcSql1 + " union " + s_Sql_Order + s_Sql_Find2 + wcSql2); return findRows(stmt, pageNumber, pageRows); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } protected void fillFields(ResultSet rst) { super.fillFields(rst); setQuantitaDB(this.quantita); setCostoNettoDb(getCostoNetto()); setFlgGoogleDB(getFlgGoogle()); try { if (isColumnInResultSet(rst, "id_articoloVariante")) setId_articoloVariante(rst.getLong("id_articoloVariante")); if (isColumnInResultSet(rst, "id_articoloTaglia")) setId_articoloTaglia(rst.getLong("id_articoloTaglia")); if (isColumnInResultSet(rst, "seriale")) setSeriale(rst.getString("seriale")); } catch (Exception e) { e.printStackTrace(); } } public long getFlgStampaEtichette() { return this.flgStampaEtichette; } public void setFlgStampaEtichette(long flgStampaEtichette) { this.flgStampaEtichette = flgStampaEtichette; } public String getStampaEtichette() { if (this.flgStampaEtichette == 0L) return "No"; if (this.flgStampaEtichette == 1L) return "Si"; if (this.flgStampaEtichette == -1L) return getTipo().getStampaEtichette(); return "??"; } public long getFlgStampaEtichetteT() { if (getFlgStampaEtichette() == -1L) return getTipo().getFlgStampaEtichette(); return getFlgStampaEtichette(); } public ResParm copyAccessoriDaArticolo(long l_id_articolo) { ResParm rp = new ResParm(); Articolo bean = new Articolo(getApFull()); bean.findByPrimaryKey(l_id_articolo); if (bean.getDBState() == 1) { Vectumerator vec = bean.getAccessori(); while (vec.hasMoreElements()) { Accessorio row = (Accessorio)vec.nextElement(); row.setDBState(0); row.setId_accessorio(0L); if (row.getId_articolo() == bean.getId_articolo()) { row.setId_articolo(getId_articolo()); } else { row.setId_articoloAssociato(getId_articolo()); } rp = addAccessorio(row); if (!rp.getStatus()) return rp; } rp.setStatus(true); rp.setMsg("Copia Accessori da " + bean.getDescrizioneCompleta() + " avvenuta con successo."); } else { rp.setStatus(false); rp.setMsg("Errore! Articolo sorgente inesistente. "); } return rp; } public ByteArrayOutputStream creaLabelArticoloAccA4Pdf(ArticoloCR CR) { long pHMarg = getParm("LABEL_ART_A4_MARGINE").getNumeroLong(); ByteArrayOutputStream ba = new ByteArrayOutputStream(); try { this.document = new Document(PageSize.A4, 0.0F, 0.0F, 0.0F, 0.0F); this.writer = PdfWriter.getInstance(this.document, ba); this.document.open(); long labelNumber = 0L; String dim = getParm("LABEL_ART_A4_COL_ROW").getTesto(); int nCol = Integer.parseInt(dim.substring(0, dim.indexOf(','))); int nRow = Integer.parseInt(dim.substring(dim.indexOf(',') + 1)); float[] widths = { 0.25F, 0.25F, 0.25F, 0.25F }; this.pdfPcorpo = new PdfPTable(widths); this.pdfPcorpo.setWidthPercentage(100.0F); if (CR.getBlankLabels() > 0L) { PdfPCell cell = new PdfPCell(); cell.setFixedHeight((PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow); cell.setBorder(0); for (int i = 0; (long)i < CR.getBlankLabels(); i++) { labelNumber++; this.pdfPcorpo.addCell(cell); } } if (CR.getId_articolo() != 0L) { findByPrimaryKey(CR.getId_articolo()); labelNumber = (long)addLabelUnArticoloAccA4Pdf(nRow, CR.getNumLabels(), labelNumber, null); } else { Vectumerator vec = findByCR(CR, 0, 0); while (vec.hasMoreElements()) { Articolo rowBean = (Articolo)vec.nextElement(); labelNumber += (long)rowBean.addLabelUnArticoloAccA4Pdf(nRow, CR.getNumLabels(), labelNumber, null); } } if (labelNumber == 0L) { Phrase ph = new Phrase("Attenzione! Non ci sono etichette da stampare!"); PdfPCell cell = new PdfPCell(ph); cell.setFixedHeight((PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow); cell.setBorder(0); cell.setColspan(nCol); this.pdfPcorpo.addCell(cell); } else { long numberBlankCell = (long)nCol - labelNumber % (long)nCol; PdfPCell cell = new PdfPCell(); cell.setFixedHeight((PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow); cell.setBorder(0); if (numberBlankCell != (long)nCol) for (int i = 0; (long)i < numberBlankCell; i++) this.pdfPcorpo.addCell(cell); } this.document.add((Element)this.pdfPcorpo); this.document.close(); this.document = null; } catch (Exception e) { e.printStackTrace(); } return ba; } public int addLabelUnArticoloAccA4Pdf(int nRow, long numberOflabel, long labelNumber, String l_descrizione) { float pHMarg = 0.0F; long paddingTop = 0L; if (getFlgStampaAccessoriT() == 1L) { int numbOflabelArt = 0; try { Vectumerator vec = getAccessori(); if (vec.hasMoreElements() || !getAltreCompatibilita().isEmpty()) { if (l_descrizione == null || l_descrizione.isEmpty()) l_descrizione = getDescrizioneCompleta(); PdfPCell cell = new PdfPCell(); cell.setBorder(0); cell.setPaddingLeft(8.0F); cell.setPaddingRight(8.0F); cell.setPaddingBottom(5.0F); cell.addElement(new Chunk(l_descrizione + ": ", PdfFontFactory.PDF_fPiccolissimo5B)); String l_descrizioneAccessorio = getAltreCompatibilita() + " "; while (vec.hasMoreElements()) { Accessorio row = (Accessorio)vec.nextElement(); l_descrizioneAccessorio = l_descrizioneAccessorio + l_descrizioneAccessorio; if (vec.hasMoreElements()) l_descrizioneAccessorio = l_descrizioneAccessorio + " - "; } cell.addElement(new Chunk(l_descrizioneAccessorio.trim(), PdfFontFactory.PDF_fPiccolissimo5)); cell.setVerticalAlignment(4); cell.setFixedHeight((PageSize.A4.getHeight() - pHMarg) / (float)nRow); for (int i = 0; (long)i < numberOflabel; i++) { paddingTop = 2L * labelNumber / 4L % (long)nRow; cell.setPaddingTop((float)paddingTop); numbOflabelArt++; labelNumber++; this.pdfPcorpo.addCell(cell); } } } catch (Exception e) { e.printStackTrace(); } return numbOflabelArt; } return 0; } public boolean hasAccessori() { if (!getAltreCompatibilita().isEmpty()) return true; return getAccessori().hasMoreElements(); } public boolean hasComponentiArticoli() { return getArticoliComponenti().hasMoreElements(); } public boolean isPrezzoChangedToday() { if (getDBState() == 1) { if (getDataCambiamentoPrezzo() == null) return false; if (getDateDiff(getDataCambiamentoPrezzo(), getToday()) == 0L) return true; return false; } return false; } public boolean isCostoChangedToday() { if (getDBState() == 1) { if (getDataUltimoCosto() == null) return false; if (getDateDiff(getDataUltimoCosto(), getToday()) == 0L) return true; return false; } return false; } public Date getDataCambiamentoPrezzo() { return getListinoArticoloBase().getDataCambiamentoPrezzoLA(); } public void setDataCambiamentoPrezzo(Date dataCambiamentoPrezzo) { this.dataCambiamentoPrezzo = dataCambiamentoPrezzo; } public void aggiornaPrezzoPubblicoERivalutazione(double nuovoPrezzoPubblico, double nuovoPrezzoRiv) { setDataCambiamentoPrezzo(getToday()); ListinoArticolo listinoArticoloBase = getListinoArticoloBase(); listinoArticoloBase.setPrezzoLA(DBAdapter.scorporaIva(nuovoPrezzoPubblico, (double)getIva().getAliquota())); listinoArticoloBase.save(); if (getCostoAcquistoORivalutato() != nuovoPrezzoRiv) { Rivalutazione riv = new Rivalutazione(getApFull()); riv.setId_articolo(getId_articolo()); riv.setDataRivalutazione(getToday()); riv.setImponibileRivalutazione(nuovoPrezzoRiv); addRivalutazione(riv); setCostoRivalutazione(nuovoPrezzoRiv); } super.save(); } public void aggiornaPrezzoPubblico(double nuovoPrezzoPubblico, double nuovoCostoNetto) { setCostoPrecedente(getCostoNetto()); setImponibilePrecedente(getPrezzoBase()); setCostoNetto(nuovoCostoNetto); setDataUltimoCosto(getToday()); setDataCambiamentoPrezzo(getToday()); ListinoArticolo listinoArticoloBase = getListinoArticoloBase(); listinoArticoloBase.setPrezzoLA(DBAdapter.scorporaIva(nuovoPrezzoPubblico, (double)getIva().getAliquota())); listinoArticoloBase.save(); super.save(); } public void aggiornaPrezzoPubblicoImponibile(double nuovoPrezzoPubblicoImponibile) { setImponibilePrecedente(getPrezzoBase()); setDataCambiamentoPrezzo(getToday()); ListinoArticolo listinoArticoloBase = getListinoArticoloBase(); listinoArticoloBase.setPrezzoLA(nuovoPrezzoPubblicoImponibile); listinoArticoloBase.save(); super.save(); } public long getFlgUsaVariantiArt() { return this.flgUsaVariantiArt; } public void setFlgUsaVariantiArt(long flgUsaVariantiArt) { this.flgUsaVariantiArt = flgUsaVariantiArt; } public double getCostoAcquistoUltimoConIva() { if (getId_articolo() != 0L) { Vectumerator vec = new ArticoloFornitore(getApFull()).findById_articoloFornitore(getId_articolo(), 0L, 1, 1); if (vec.hasMoreElements()) { ArticoloFornitore af = (ArticoloFornitore)vec.nextElement(); return af.getCostoTotaleIvato(); } return 0.0D; } return 0.0D; } public String getAltreCompatibilita() { if (this.altreCompatibilita != null && this.altreCompatibilita.equals("


")) this.altreCompatibilita = ""; return (this.altreCompatibilita == null) ? "" : this.altreCompatibilita.trim(); } public void setAltreCompatibilita(String altreCompatibilita) { this.altreCompatibilita = altreCompatibilita; } public double getCostoAcquistoUltimo() { if (getId_articolo() != 0L) { Vectumerator vec = new ArticoloFornitore(getApFull()).findById_articoloFornitore(getId_articolo(), 0L, 1, 1); if (vec.hasMoreElements()) { ArticoloFornitore af = (ArticoloFornitore)vec.nextElement(); return af.getCostoTotale(); } return 0.0D; } return 0.0D; } public double getCostoAcquistoUltimo(Clifor l_clifor) { if (getId_articolo() != 0L && l_clifor.getId_clifor() != 0L) { ArticoloFornitore af = new ArticoloFornitore(getApFull()); af.findByFornitoreArticolo(l_clifor.getId_clifor(), getId_articolo(), 1L); if (af.getDBState() == 1) return af.getCostoTotale(); return 0.0D; } return 0.0D; } public double getRicaricoPAUltimo() { return getRicaricoCalc(getCostoAcquistoUltimo()); } public double getRicaricoEffettivoDaCostoConfezione() { return getRicaricoCalc(getTotCostoConfezione()); } private double getRicaricoCalc(double l_costo) { if (l_costo != 0.0D) { DoubleOperator temp = new DoubleOperator(getPrezzoPubblico()); temp.setScale(4, 1); temp.divide(l_costo); temp.subtract(1); temp.multiply(100); temp.setScale(4, 1); return temp.getResult(); } return 0.0D; } public double getRicaricoBaseNew() { return this.ricaricoBaseNew; } public void setRicaricoBaseNew(double ricaricoBaseNew) { this.ricaricoBaseNew = ricaricoBaseNew; } public ResParm aggiornaRicaricoSeZero() { ResParm rp = new ResParm(true); if (getRicaricoBase() == 0.0D) { setRicaricoBase(getRicaricoPAUltimo()); rp = super.save(); } return rp; } public long getFlgSerialiMassivi() { return this.flgSerialiMassivi; } public void setFlgSerialiMassivi(long flgSerialiMassivi) { this.flgSerialiMassivi = flgSerialiMassivi; } public String getCaratteristiche() { return (this.caratteristiche == null) ? "" : this.caratteristiche.trim(); } public void setCaratteristiche(String compatibilita) { this.caratteristiche = compatibilita; } public ResParm aggiornaCompatibilita() { Vectumerator vec = getAccessori(); StringBuffer l_compatibilita = new StringBuffer(); while (vec.hasMoreElements()) { Accessorio row = (Accessorio)vec.nextElement(); l_compatibilita.append(row.getArticoloAssociato(getId_articolo()).getNome()); if (vec.hasMoreElements()) l_compatibilita.append(","); } if (l_compatibilita.length() == 0) { setCompatibilita(""); } else if (l_compatibilita.length() > 254) { setCompatibilita(l_compatibilita.toString().substring(0, 254)); } else { setCompatibilita(l_compatibilita.toString()); } return super.save(); } public String getDescrizioneCompatibilita() { if (getCompatibilita().isEmpty()) return getAltreCompatibilita(); return getCompatibilita() + "," + getCompatibilita(); } public void creaFileCvs(ArticoloCR CR) { try { Vectumerator list = findByCR(CR, 0, 0); CR.setFileName(getPathTmp() + "exportArticoli_" + getPathTmp() + ".csv"); String theCvsFile = getDocBase() + getDocBase(); String SEP = ";"; new File(theCvsFile).delete(); FileWr outCvsFile = new FileWr(theCvsFile, false); String s1 = "Criteri di ricerca: " + CR.getDescrizioneCR() + "\nCodice;Descrizione;Tipo;Costo acq. imp;Costo acq. ivato;Prezzo Vendita con iva;Ric.;Scorta Minima;Quantita'"; if (CR.getFlgTipoReport() >= 1L) s1 = s1 + ";Q.ta' variante"; if (CR.getFlgTipoReport() == 2L) s1 = s1 + ";Q.ta' seriale"; outCvsFile.writeLine(s1); while (list.hasMoreElements()) { Articolo row = (Articolo)list.nextElement(); s1 = " \"" + row.getCodice() + "\"" + SEP + row.getDescrizioneCompleta() + SEP + row.getTipo().getDescrizioneCompleta() + SEP + getNf().format(row.getCostoAcquistoORivalutato()) + SEP + getNf().format(row.getCostoAcquistoORivalutatoConIva()) + SEP + getNf().format(row.getPrezzoPubblicoIva()) + SEP + getNf().format(row.getRicaricoBase()) + SEP + (row.isArticoloDaRiordinare() ? getNf().format(row.getQtaRiordino()) : "") + SEP + getNf().format(row.getQuantitaData(CR.getDataMovimento())); s1 = s1.replace("€", "€"); s1 = s1.replace("»", "-->"); outCvsFile.writeLine(s1); if (CR.getFlgTipoReport() >= 1L) { if (row.getFlgUsaVarianti() == 1L) { Vectumerator listaAv = row.findArticoliVarianti(-1L, -1L); while (listaAv.hasMoreElements()) { ArticoloVariante rowAv = (ArticoloVariante)listaAv.nextElement(); if (rowAv.getQuantitaAv(CR.getDataMovimento()) != 0.0D) { s1 = ";;;;;;variante;" + rowAv.getNomeV() + SEP + SEP + getNf().format(rowAv.getQuantitaAv(CR.getDataMovimento())); outCvsFile.writeLine(s1); } if (CR.getFlgTipoReport() == 2L) { Vectumerator listaD = rowAv.getDisponibilitaMovimentoM(); while (listaD.hasMoreElements()) { Movimento rowD = (Movimento)listaD.nextElement(); if (rowD.getQuantita() != 0.0D) { s1 = ";;;;;;S/N;n. " + rowD.getSeriale() + SEP + SEP + SEP + getNf().format(rowD.getQuantita()); outCvsFile.writeLine(s1); } } } } continue; } if (CR.getFlgTipoReport() == 2L && row.isUsaSeriale()) { Vectumerator listaD = row.getDisponibilitaMovimentoM(); while (listaD.hasMoreElements()) { Movimento rowD = (Movimento)listaD.nextElement(); s1 = ";;;;;;S/N;n. " + rowD.getSeriale() + SEP + SEP + SEP + getNf().format(rowD.getQuantita()); outCvsFile.writeLine(s1); } } } } outCvsFile.closeFile(); } catch (Exception e) { handleDebug(e); } } public double getQtaRiordino() { return this.qtaRiordino; } public void setQtaRiordino(double qtaRiordino) { this.qtaRiordino = qtaRiordino; } public boolean isArticoloDaRiordinare() { if (getQuantitaEffettiva() < getQtaRiordino()) return true; return false; } public long getFlgStampaAccessori() { return this.flgStampaAccessori; } public void setFlgStampaAccessori(long flgStampaAccessori) { this.flgStampaAccessori = flgStampaAccessori; } public long getFlgStampaAccessoriT() { if (getFlgStampaAccessori() == -1L) return getTipo().getFlgStampaAccessori(); return getFlgStampaAccessori(); } public double getPrezzoPubblicoIva(Clifor l_clifor) { return getPrezzoArticoloIva(l_clifor).getPrezzoFinale(); } public double getCostoRivalutazione() { return this.costoRivalutazione; } public void setCostoRivalutazione(double costoRivalutazione) { this.costoRivalutazione = costoRivalutazione; } public double getCostoRivalutazioneConIva() { return this.costoRivalutazioneConIva; } public void setCostoRivalutazioneConIva(double costoRivalutazioneConIva) { this.costoRivalutazioneConIva = costoRivalutazioneConIva; } public double getRicaricoCostoRivalutazione() { return getRicaricoCalc(getCostoRivalutazione()); } public double getCostoRivalutazioneIva() { return DBAdapter.conIva(getCostoRivalutazione(), (double)getIva().getAliquota()); } public long getFlgNegativo() { return this.flgNegativo; } public void setFlgNegativo(long flgNegativo) { this.flgNegativo = flgNegativo; } public ResParm addRivalutazione(Rivalutazione row) { Rivalutazione bean = new Rivalutazione(getApFull()); bean.findByPrimaryKey(row.getId_rivalutazione()); if (bean.getId_rivalutazione() != 0L) { row.setDBState(bean.getDBState()); } else { row.setDBState(0); } ResParm rp = row.save(); return rp; } public ResParm delRivalutazione(Rivalutazione row) { Rivalutazione bean = new Rivalutazione(getApFull()); bean.findByPrimaryKey(row.getId_rivalutazione()); return bean.delete(); } public Vectumerator getRivalutazioni() { return new Rivalutazione(getApFull()).findById_articolo(getId_articolo(), 0, 0); } public ResParm aggiornaCostoRivalutazione(double l_costoRivalutazione) { setCostoRivalutazione(l_costoRivalutazione); return super.save(); } public double getCostoAcquistoORivalutatoConIva() { if (getCostoRivalutazioneIva() != 0.0D) return getCostoRivalutazioneIva(); return getCostoAcquistoConIva(); } public double getRicaricoPAUltimoORivalutatoConIva() { if (getRicaricoCostoRivalutazione() != 0.0D) return getRicaricoCostoRivalutazione(); return getRicaricoPAUltimo(); } public double getCostoAcquistoORivalutato() { if (getCostoRivalutazione() != 0.0D) return getCostoRivalutazione(); return getCostoAcquisto(); } public double getPrezzoRivNuovo() { return this.prezzoRivNuovo; } public void setPrezzoRivNuovo(double prezzoRivNuovo) { this.prezzoRivNuovo = prezzoRivNuovo; } public double getQuantitaEffettiva() { if (getParm("USA_MAGAZZINO").isFalse()) { if (!isQuantitaCalcolate()) calcolaQuantita(); return this.quantitaEffettiva; } return getQuantita(); } public double getQuantitaInArrivo() { if (!isQuantitaCalcolate()) calcolaQuantita(); return this.quantitaInArrivo; } public void setQuantitaEffettiva(double quantitaEffettiva) { this.quantitaEffettiva = quantitaEffettiva; } private synchronized void calcolaQuantita() { if (getParm("USA_MAGAZZINO").isTrue()) { setQuantitaW(getQuantita()); return; } if ((!isQuantitaCalcolate() ? true : false) & ((this.id_articolo != 0L) ? true : false)) { long l_flgDispo; RigaDocumento rd = new RigaDocumento(getApFull()); rd.findMagDisponibilita(getId_articolo(), getId_articoloVariante(), getId_articoloTaglia(), null, 1L, 0L, null); double q = rd.getQuantita(); double nr = rd.getNr(); double kg = rd.getKg(); double mt = rd.getMt(); setQuantitaW(q); setQuantita(q); setQuantitaImpegnata(new RigaDocumento(getApFull()).getQuantitaImpegnataByArticolo(getId_articolo())); double q1 = new RigaDocumento(getApFull()).getQuantitaInArrivoByArticolo(getId_articolo()); setQuantitaInArrivo(q1); if (usaMagazzino()) { DoubleOperator dop = new DoubleOperator(q); dop.add(this.quantitaInArrivo); dop.subtract(this.quantitaImpegnata); setQuantitaEffettiva(dop.getResult()); } this.quantitaMagazzinoMovimentoHtml = getMovimentoHtmlDesc(getTipologiaArticolo(), q, nr, kg, mt, this.quantitaInArrivo, this.quantitaImpegnata, this.quantitaEffettiva, usaMagazzino(), getParm("USA_MAGAZZINO").isTrue(), getNf()); if (!usaMagazzino()) { l_flgDispo = 1L; } else { l_flgDispo = (this.quantitaW > 0.0D) ? 1L : 0L; } String SEP = ","; MagFisico mf = new MagFisico(getApFull()); Vectumerator vec = mf.findByTipo(0L); StringBuilder sb = new StringBuilder(); while (vec.hasMoreElements()) { MagFisico row = (MagFisico)vec.nextElement(); rd.findMagDisponibilitaPuntuale(getId_articolo(), getId_articoloVariante(), 0L, null, row.getId_magFisico(), 0L, 0L); if (rd.getQuantita() > 0.0D) { sb.append(row.getId_magFisico()); sb.append(","); } } if (sb.length() > 0) sb.insert(0, ","); String temp = "update ARTICOLO set quantitaMagazzinoMovimentoHtml='" + this.quantitaMagazzinoMovimentoHtml + "', quantitaW=" + this.quantitaW + ", quantita=" + this.quantitaW + ", quantitaEffettiva=" + this.quantitaEffettiva + ", quantitaImpegnata=" + this.quantitaImpegnata + ", quantitaCalcolate=true, flgDispo=" + l_flgDispo + ", codiciMagazzino='" + sb.toString() + "' where id_articolo=" + getId_articolo(); update(temp); setQuantitaCalcolate(true); } } public boolean isQuantitaCalcolate() { return this.quantitaCalcolate; } public void setQuantitaCalcolate(boolean quantitaCalcolate) { this.quantitaCalcolate = quantitaCalcolate; } public double getQuantitaImpegnata() { if (!isQuantitaCalcolate()) calcolaQuantita(); return this.quantitaImpegnata; } public void setQuantitaImpegnata(double quantitaImpeggnata) { this.quantitaImpegnata = quantitaImpeggnata; } public void setQuantitaInArrivo(double quantitaInArrivo) { this.quantitaInArrivo = quantitaInArrivo; } public static final synchronized ResParm creaOrdine(Articolo l_articolo, long l_id_articoloVariante, long l_id_clifor, double l_qta) { ResParm rp = new ResParm(true); String msg = ""; ApplParmFull ap = l_articolo.getApFull(); if (l_qta <= 0.0D) { rp.setStatus(false); rp.setMsg("Errore! Quantità da riordinare <=0. Riordino non necessario."); return rp; } Documento ordine = new Documento(ap); ordine.findOrdineBozza(l_id_clifor); if (ordine.getDBState() == 0) { msg = " Creato nuovo ordine n. "; ordine.setId_clifor(l_id_clifor); ordine.setDataDocumento(getToday()); ordine.setId_tipoDocumento(8L); ordine.setId_magFisicoPartenza(ordine.getTipoDocumento().getCausaleMagazzino().getId_magFisicoPartenza()); ordine.setId_magFisicoArrivo(ordine.getTipoDocumento().getCausaleMagazzino().getId_magFisicoArrivo()); rp = ordine.save(); } else { msg = " Aggiornato ordine n. "; } if (!rp.getStatus()) { rp.setStatus(false); rp.setMsg("Errore! Impossibile salvare ordine."); return rp; } RigaDocumento row = new RigaDocumento(ap); row.setId_articolo(l_articolo.getId_articolo()); if (l_id_articoloVariante != 0L) { row.setId_articoloVariante(l_id_articoloVariante); row.setDescrizioneRiga(row.getArticoloVariante().getDescrizioneCompleta()); } else { row.setDescrizioneRiga(row.getArticolo().getDescrizioneCompleta()); } row.setQuantita(l_qta); row.setQuantitaUdm(l_qta); rp.append(Documento.addRigaDocumento(ordine, row)); if (rp.getStatus()) { rp.append(l_articolo.aggiornaQtaRiordino(l_articolo.getQtaRiordino())); rp.setMsg(msg + msg); } rp.setReturnObj(ordine); return rp; } public double getPrice(long l_id_users) { if (l_id_users == 0L) return getPrice(); Users user = new Users(getApFull()); user.findByPrimaryKey(l_id_users); if (user.getId_clifor() >= 0L) return getPrezzoPubblico(user.getClifor()); return getPrice(); } public double getQtaRiordinoNuovo() { return this.qtaRiordinoNuovo; } public void setQtaRiordinoNuovo(double qtaRiordinoNuovo) { this.qtaRiordinoNuovo = qtaRiordinoNuovo; } public ResParm aggiornaQtaRiordino(double l_qtaRiordino) { ResParm rp = new ResParm(true); if (getId_articolo() != 0L) { setQtaRiordino(l_qtaRiordino); rp = super.save(); } return rp; } public double getQtaDaRiordinare() { DoubleOperator qrow = new DoubleOperator(getQtaRiordino()); qrow.subtract(getQuantitaEffettiva()); if (qrow.getResult() <= 0.0D) return 0.0D; return qrow.getResult(); } private Hashtable getCaratteristicheHT() { if (this.caratteristicheHT == null) this.caratteristicheHT = new Hashtable(); return this.caratteristicheHT; } public void setCaratteristicheHT(Hashtable caratteristicaHT) { this.caratteristicheHT = caratteristicaHT; } public ResParm aggiornaCaratteristiche() { Vectumerator vec = getCaratteristicheArticolo(); StringBuilder l_caratteristiche = new StringBuilder(); StringBuilder l_caratteristicheID = new StringBuilder(); while (vec.hasMoreElements()) { CaratteristicaArticolo row = (CaratteristicaArticolo)vec.nextElement(); l_caratteristiche.append(row.getVal()); if (row.getId_lista() > 0L) l_caratteristicheID.append(row.getId_lista()); if (vec.hasMoreElements()) { l_caratteristiche.append(","); if (row.getId_lista() > 0L) l_caratteristicheID.append(","); } } if (l_caratteristiche.length() == 0) { setCaratteristiche(""); } else { setCaratteristiche(l_caratteristiche.toString()); } if (l_caratteristicheID.length() == 0) { setCaratteristicheListeId(""); } else { setCaratteristicheListeId("," + l_caratteristicheID.toString() + ","); } return super.save(); } public String getCompatibilita() { return (this.compatibilita == null) ? "" : this.compatibilita.trim(); } public void setCompatibilita(String compatibilita) { this.compatibilita = compatibilita; } public long getId_caratteristica() { return this.id_caratteristica; } public void setId_caratteristica(long id_caratteristica) { this.id_caratteristica = id_caratteristica; } public double getPrezzoPubblicoIva() { return getPrezzoPubblicoIva(null); } public double getCostoAcquistoConIva(Clifor l_clifor) { double costoAcquistoCLifor = getCostoAcquistoUltimoConIva(l_clifor); if (costoAcquistoCLifor != 0.0D) return costoAcquistoCLifor; if (getCostoNetto() != 0.0D) return getCostoNettoIva(); return getCostoAcquistoUltimoConIva(); } protected void findByCRCreateStmtDate(ArticoloCR CR, PreparedStatement stmt) { try { int dataCount = 1; if (CR.getFlgStockOfferte() == 99L) { stmt.setDate(dataCount, DBAdapter.getToday()); dataCount++; } if (CR.getFlgOfferta() >= 0L) { stmt.setDate(dataCount, DBAdapter.getToday()); dataCount++; if (CR.getFlgOfferta() == 1L || CR.getFlgOfferta() == 0L) { stmt.setDate(dataCount, DBAdapter.getToday()); dataCount++; } if (CR.getFlgOfferta() == 3L) { stmt.setDate(dataCount, DBAdapter.getToday()); dataCount++; stmt.setDate(dataCount, DBAdapter.getToday()); dataCount++; stmt.setDate(dataCount, DBAdapter.getToday()); dataCount++; } } if (CR.getDataDocumentoUsatoA() != null) { stmt.setDate(dataCount, CR.getDataDocumentoUsatoA()); dataCount++; stmt.setDate(dataCount, CR.getDataDocumentoUsatoA()); dataCount++; } if (CR.getDataDocumentoDa() != null) { stmt.setDate(dataCount, CR.getDataDocumentoDa()); dataCount++; } if (CR.getDataDocumentoA() != null) { stmt.setDate(dataCount, CR.getDataDocumentoA()); dataCount++; } if (CR.getDataCreazioneDa() != null) { stmt.setDate(dataCount, CR.getDataCreazioneDa()); dataCount++; } if (CR.getDataCreazioneA() != null) { stmt.setDate(dataCount, CR.getDataCreazioneA()); dataCount++; } if (CR.getDataUpdateDa() != null) { stmt.setDate(dataCount, CR.getDataUpdateDa()); dataCount++; } if (CR.getFlgAmzFeaturedPriceData() == 1L) { stmt.setDate(dataCount, getToday()); dataCount++; } } catch (SQLException e) { handleDebug(e); } } protected int findByCRTotRecord(ArticoloCR CR) { StringBuffer s_Sql_Find = new StringBuffer("select count( A.id_articolo) as tot from ARTICOLO AS A "); WcString wc = new WcString(); findByCRCreateWC(CR, s_Sql_Find, wc); try { PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find)); findByCRCreateStmtDate(CR, stmt); return (int)getTots(stmt); } catch (Exception e) { handleDebug(e); return 0; } } public boolean isDeleteLogic() { return false; } public long getFlgRC() { return this.flgRC; } public void setFlgRC(long flgRC) { this.flgRC = flgRC; } public long getFlgNoListino() { return this.flgNoListino; } public void setFlgNoListino(long flgNoListino) { this.flgNoListino = flgNoListino; } public double getPrezzoPubblico(Clifor l_clifor) { return getPrezzoArticolo(l_clifor).getPrezzoFinale(); } public ByteArrayOutputStream creaLabelArticoloAccZebraPdf(ArticoloCR CR) { ByteArrayOutputStream ba = new ByteArrayOutputStream(); try { String dim = getParm("LABEL_ART_SIZE").getTesto(); long xx = Long.parseLong(dim.substring(0, dim.indexOf(','))); long yy = Long.parseLong(dim.substring(dim.indexOf(',') + 1)); Rectangle label = new Rectangle(getPdfPointSize(yy), getPdfPointSize(xx)); this.document = new Document(label.rotate(), 2.0F, 2.0F, 2.0F, 2.0F); this.writer = PdfWriter.getInstance(this.document, ba); this.document.open(); int labelNumber = 0; if (CR.getId_articolo() != 0L) { findByPrimaryKey(CR.getId_articolo()); labelNumber = addLabelUnArticoloAccZebraPdf(CR.getNumLabels(), (long)labelNumber, null); } else { Vectumerator vec = findByCR(CR, 0, 0); while (vec.hasMoreElements()) { Articolo rowBean = (Articolo)vec.nextElement(); labelNumber += rowBean.addLabelUnArticoloAccZebraPdf(CR.getNumLabels(), (long)labelNumber, null); } } this.document.close(); this.document = null; } catch (Exception e) { e.printStackTrace(); } return ba; } public int addLabelUnArticoloAccZebraPdf(long numberOflabel, long labelNumber, String l_descrizione) { if (getFlgStampaAccessoriT() == 1L) { int fontSize = getParm("LABEL_ART_ACC_FONT_SIZE").getNumeroInt(); Font pdfTagliando = new Font(2, (float)fontSize, 1); int numbOflabelArt = 0; try { float[] widths = { 1.0F }; this.pdfPcorpo = new PdfPTable(widths); this.pdfPcorpo.setWidthPercentage(100.0F); Vectumerator vec = getAccessori(); if (vec.hasMoreElements() || !getAltreCompatibilita().isEmpty()) { if (l_descrizione == null || l_descrizione.isEmpty()) l_descrizione = getDescrizioneCompleta(); PdfPCell cell = new PdfPCell(); cell.setBorder(0); cell.setVerticalAlignment(4); cell.addElement(new Chunk(l_descrizione + ": ", pdfTagliando)); String l_descrizioneAccessorio = getAltreCompatibilita() + " "; while (vec.hasMoreElements()) { Accessorio row = (Accessorio)vec.nextElement(); l_descrizioneAccessorio = l_descrizioneAccessorio + l_descrizioneAccessorio; if (vec.hasMoreElements()) l_descrizioneAccessorio = l_descrizioneAccessorio + " - "; } cell.addElement(new Chunk(l_descrizioneAccessorio.trim(), pdfTagliando)); this.pdfPcorpo.addCell(cell); for (int i = 0; (long)i < numberOflabel; i++) { numbOflabelArt++; labelNumber++; this.document.add((Element)this.pdfPcorpo); if ((long)i < numberOflabel) this.document.newPage(); } } } catch (Exception e) { e.printStackTrace(); } return numbOflabelArt; } return 0; } public int addLabelUnArticoloPackingListA4Pdf(String titolo, int nRow, long numberOflabel, String l_descrizione) { long pHMarg = 2L; long l_indent = 4L; if (getFlgStampaEtichetteT() == 1L) { int totNumbOflabel = 0; try { int altezzaCod = 50; int larghezzaCod = 120; PdfContentByte cb = this.writer.getDirectContent(); Barcode128 codeBar = new Barcode128(); codeBar.setCodeType(9); if (getFlgUsaVarianti() == 0L || (getFlgUsaVarianti() == -1L && getTipo().getFlgUsaVarianti() == 0L)) { if (l_descrizione == null || l_descrizione.isEmpty()) l_descrizione = getDescrizioneCompleta().replace("€", "€"); for (int i = 0; (long)i < numberOflabel; i++) { totNumbOflabel++; PdfPCell cell = new PdfPCell(); cell.setBorder(0); codeBar.setCode(getCodice()); Image imgBarcode = codeBar.createImageWithBarcode(cb, null, null); imgBarcode.scaleToFit((float)larghezzaCod, (float)altezzaCod); cell.addElement(new Chunk(imgBarcode, 20.0F, (float)(-altezzaCod + 10))); cell.addElement(new Chunk("\n\n\n\n " + l_descrizione, PdfFontFactory.PDF_fPiccolissimo6)); cell.setVerticalAlignment(4); cell.setFixedHeight((PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow); cell.setIndent((float)l_indent); this.pdfPcorpo.addCell(cell); } } else { Vectumerator varianti = findArticoliVarianti(-1L, -1L); while (varianti.hasMoreElements()) { ArticoloVariante rowAv = (ArticoloVariante)varianti.nextElement(); l_descrizione = rowAv.getDescrizioneCompleta(); for (int i = 0; (long)i < numberOflabel; i++) { totNumbOflabel++; PdfPCell cell = new PdfPCell(); cell.setBorder(0); codeBar.setCode(rowAv.getCodiceVariante()); Image imgBarcode = codeBar.createImageWithBarcode(cb, null, null); imgBarcode.scaleToFit((float)larghezzaCod, (float)altezzaCod); cell.addElement(new Chunk(imgBarcode, 20.0F, (float)(-altezzaCod + 10))); cell.addElement(new Chunk("\n\n\n\n " + l_descrizione, PdfFontFactory.PDF_fPiccolissimo)); cell.setVerticalAlignment(4); cell.setIndent((float)l_indent); this.pdfPcorpo.addCell(cell); } } } } catch (Exception e) { e.printStackTrace(); } return totNumbOflabel; } return 0; } public ByteArrayOutputStream creaLabelArticoloZebraPdf(ArticoloCR CR) { ByteArrayOutputStream ba = new ByteArrayOutputStream(); try { String dim = getParm("LABEL_ART_SIZE").getTesto(); long xx = Long.parseLong(dim.substring(0, dim.indexOf(','))); long yy = Long.parseLong(dim.substring(dim.indexOf(',') + 1)); Rectangle label = new Rectangle(getPdfPointSize(yy), getPdfPointSize(xx)); this.document = new Document(label.rotate(), 2.0F, 2.0F, 2.0F, 2.0F); this.writer = PdfWriter.getInstance(this.document, ba); this.document.open(); int labelNumber = 0; if (CR.getId_articolo() != 0L) { findByPrimaryKey(CR.getId_articolo()); labelNumber = addLabelUnArticoloZebraPdf(CR.getNumLabels(), null); } else { Vectumerator vec = findByCR(CR, 0, 0); while (vec.hasMoreElements()) { Articolo rowBean = (Articolo)vec.nextElement(); labelNumber += rowBean.addLabelUnArticoloZebraPdf(CR.getNumLabels(), null); } } this.document.close(); this.document = null; } catch (Exception e) { e.printStackTrace(); } return ba; } public int addLabelUnArticoloZebraPdf(long numberOflabel, String l_descrizione) { if (getFlgStampaEtichetteT() == 1L) { int totNumbOflabel = 0; int fontSize = getParm("LABEL_ART_FONT_SIZE").getNumeroInt(); Font pdfTagliando = new Font(2, (float)fontSize, 1); try { float[] widths = { 1.0F }; int altezzaCod = 50; int larghezzaCod = 120; PdfContentByte cb = this.writer.getDirectContent(); Barcode128 codeBar = new Barcode128(); codeBar.setCodeType(9); if (getFlgUsaVarianti() == 0L || (getFlgUsaVarianti() == -1L && getTipo().getFlgUsaVarianti() == 0L)) { if (l_descrizione == null || l_descrizione.isEmpty()) l_descrizione = getDescrizioneCompleta().replace("€", "€"); PdfPCell cell = new PdfPCell(); cell.setBorder(0); codeBar.setCode(getCodice()); Image imgBarcode = codeBar.createImageWithBarcode(cb, null, null); imgBarcode.scaleToFit((float)larghezzaCod, (float)altezzaCod); cell.addElement(new Chunk(imgBarcode, 10.0F, (float)(-altezzaCod + 10))); cell.addElement(new Chunk("\n\n\n\n\n\n " + l_descrizione, pdfTagliando)); cell.setVerticalAlignment(4); this.pdfPcorpo = new PdfPTable(widths); this.pdfPcorpo.setWidthPercentage(100.0F); this.pdfPcorpo.addCell(cell); for (int i = 0; (long)i < numberOflabel; i++) { totNumbOflabel++; this.document.add((Element)this.pdfPcorpo); this.document.newPage(); } } else { Vectumerator varianti = findArticoliVarianti(-1L, -1L); while (varianti.hasMoreElements()) { ArticoloVariante rowAv = (ArticoloVariante)varianti.nextElement(); l_descrizione = rowAv.getDescrizioneCompleta(); PdfPCell cell = new PdfPCell(); cell.setBorder(0); codeBar.setCode(rowAv.getCodiceVariante()); Image imgBarcode = codeBar.createImageWithBarcode(cb, null, null); imgBarcode.scaleToFit((float)larghezzaCod, (float)altezzaCod); cell.addElement(new Chunk(imgBarcode, 20.0F, (float)(-altezzaCod + 10))); cell.addElement(new Chunk("\n\n\n\n " + l_descrizione, pdfTagliando)); cell.setVerticalAlignment(4); this.pdfPcorpo = new PdfPTable(widths); this.pdfPcorpo.setWidthPercentage(100.0F); this.pdfPcorpo.addCell(cell); for (int i = 0; (long)i < numberOflabel; i++) { totNumbOflabel++; this.document.add((Element)this.pdfPcorpo); this.document.newPage(); } } } } catch (Exception e) { e.printStackTrace(); } return totNumbOflabel; } return 0; } public long getFlgEscludiWeb() { return this.flgEscludiWeb; } public void setFlgEscludiWeb(long flgEscludiWeb) { this.flgEscludiWeb = flgEscludiWeb; } public boolean isWeb() { if (getTipo().isWeb()) { if (getFlgEscludiWeb() == 0L) return true; return false; } return false; } public String getDescrizioneUrl() { String temp = convertStringToLink(getDescrizione()); return temp; } protected int getStringValueCase(String l_colomnName) { return super.getStringValueCase(l_colomnName); } public String getCartItemDescriptionUrl() { return getDescrizioneUrl(); } public Vectumerator getAccessori(long l_id_tipoAccessorio, long l_id_tipoAcc, long l_flgEscludiWeb) { return new Accessorio(getApFull()).findById_articolo(getId_articolo(), l_id_tipoAccessorio, l_id_tipoAcc, l_flgEscludiWeb, 0, 0); } public Vectumerator getKitAssociati() { return new Kit(getApFull()).findByArticoloPrimario(getId_articolo(), 0, 0); } public Vectumerator getKitVariantiAssociati() { return new ArticoloVariante(getApFull()).findByArticoloKit(getId_articolo()); } public Vectumerator getArticoliComponenti() { return new ArticoloArticoloComponente(getApFull()).findByArticolo(getId_articolo()); } public long getId_tipoAccessorio() { return this.id_tipoAccessorio; } public TipoAccessorio getTipoAccessorio() { this.tipoAccessorio = (TipoAccessorio)getSecondaryObject(this.tipoAccessorio, TipoAccessorio.class, getId_tipoAccessorio()); return this.tipoAccessorio; } public void setId_tipoAccessorio(long newId_tipoAccessorio) { this.id_tipoAccessorio = newId_tipoAccessorio; setTipoAccessorio(null); } public void setTipoAccessorio(TipoAccessorio newTipoAccessorio) { this.tipoAccessorio = newTipoAccessorio; } public long getId_tipoPadre() { return 0L; } public String getDescrizioneVetrina() { return getDescrizioneVetrina("it"); } public String getDescrizioneVetrina(String lang) { if (lang.isEmpty()) lang = "it"; return getDescTxtLang("descrizioneVetrina", lang); } public long getId() { return getId_articolo(); } public int getDispoLevel() { double qt = getAvail(); double dispoLevelScarsa = getParm("CC_QTA_LOW").getNumero(); if (qt <= 0.0D) return 0; if (qt > 0.0D && qt < dispoLevelScarsa) return 1; if (qt >= dispoLevelScarsa) return 2; return 0; } public static final String getDispoLevelDesc(int l_dispoLevel) { switch (l_dispoLevel) { case 0: return "NON DISPONIBILE"; case 1: return "Disponibilità Bassa "; case 2: return "Disponibile"; } return ""; } public String getDispoLevelDesc() { return getDispoLevelDesc(getDispoLevel()); } public boolean isFlgVetrina() { if (getId_articolo() > 0L) { if (getTipo().getFlgUsaVarianti() == 0L) return (getId_vetrina() > 0L); return new ArticoloVariante(getApFull()).isFlgVetrinaByArticolo(getId_articolo()); } return false; } public ResParm impostaFlgEscludiWebByggTipo() { ResParm rp = new ResParm(true); return rp; } public boolean useDescLangTables() { return true; } public boolean usaMagazzino() { if (getTipo().getFlgTipoMagazzino() == 9L || getTipo().getFlgTipoMagazzino() == 0L) return false; return true; } public ResParm updateModimportazione(long l_flgModImportazione, String l_codiceSerie) { return update("UPDATE ARTICOLO SET flgModImportazione = " + l_flgModImportazione + " WHERE codice LIKE '" + l_codiceSerie + "%'"); } public ResParm updateModimportazioneByFornitore(long l_flgModImportazione, long l_id_fornitore) { if (l_flgModImportazione == 0L) return update("UPDATE ARTICOLO AS A inner join ARTICOLO_FORNITORE as B on A.id_articolo=B.id_articolo SET A.flgModImportazione =" + l_flgModImportazione + ", countImportNonTrovato=countImportNonTrovato+1 WHERE B.id_clifor =" + l_id_fornitore); return update("UPDATE ARTICOLO AS A inner join ARTICOLO_FORNITORE as B on A.id_articolo=B.id_articolo SET A.flgModImportazione =" + l_flgModImportazione + " WHERE B.id_clifor =" + l_id_fornitore); } public String getDescrizioneCommercialeScript(String lang) { return DBAdapter.prepareScriptString(getDescrizioneCommerciale(lang), true, false); } public String getDescrizioneTecnicaScript(String lang) { return DBAdapter.prepareScriptString(getDescrizioneTecnica(lang), true, false); } public String getDescrizioneVetrinaScript(String lang) { return DBAdapter.prepareScriptString(getDescrizioneVetrina(lang), true, false); } public long getFlgEscludiWebArt() { return this.flgEscludiWebArt; } public void setFlgEscludiWebArt(long flgEscludiWebArt) { this.flgEscludiWebArt = flgEscludiWebArt; } public String getCartItemTag() { return ""; } protected void findByCRCreateWC(ArticoloCR CR, StringBuffer s_Sql_Find, WcString wc) { if (CR.getFlgShowDeleteLogic() == 0L) { wc.addWc("A.dataFineVld is null"); } else { wc.addWc("A.dataFineVld is not null"); } if ((!CR.getSearchTxt().isEmpty() && !CR.getSearchTxt().equals("*")) || !CR.getCodice().isEmpty() || CR.getId_vetrina() > 0L || CR.getFlgNascondi() == 0L || !CR.getNomeV().isEmpty() || !CR.getCodiceSerieV().isEmpty() || CR.getFlgQta() == 1L || ( !CR.getSearchTxtWeb().isEmpty() && !CR.getSearchTxtWeb().equals("*")) || ( CR.getFlgNascondi() >= 0L && CR.getFlgUsaDisponibilita() == 1L)) s_Sql_Find.append("LEFT JOIN ARTICOLO_VARIANTE AS B ON A.id_articolo=B.id_articolo"); if (CR.getDataDocumentoDa() != null || CR.getDataDocumentoA() != null || CR.getId_clifor() > 0L) { s_Sql_Find.append(" inner join RIGA_DOCUMENTO AS RDOC ON RDOC.id_articolo=A.id_articolo"); s_Sql_Find.append(" inner join DOCUMENTO AS DOC ON DOC.id_documento=RDOC.id_documento"); } if (CR.getId_fornitore() > 0L) s_Sql_Find.append(" inner join ARTICOLO_FORNITORE AS AF ON AF.id_articolo=A.id_articolo"); if (CR.getId_fornitoreUsato() > 0L) s_Sql_Find.append(" inner join ARTICOLO_USATO AS AU ON AU.id_articolo=A.id_articolo"); if (CR.getFlgAmzFeaturedPriceData() >= 0L || CR.getFlgPrezzoCompetitivo() >= 0L) s_Sql_Find.append(" left join AMZ_FEATURED_PRICE AS AFP ON AFP.id_articolo=A.id_articolo"); if (!CR.getSearchTxtWeb().isEmpty() || CR.getFlgIcecatAuto() >= 0L || CR.getFlgOrderBy() == 1L || ( !CR.getSearchTxt().isEmpty() && !CR.getSearchTxt().equals("*"))) s_Sql_Find.append(" left join MARCA AS M on A.id_marca=M.id_marca"); if (CR.getFlgOrderBy() >= 2L || CR.getFlgEscludiWeb() >= 0L || CR.getId_tipo() != 0L || CR.getFlgNascondi() >= 0L || CR.getId_tipoSel() != 0L || !CR.getFlgReport().isEmpty()) s_Sql_Find.append(" inner join TIPO AS C ON C.id_tipo=A.id_tipo"); if (CR.getDataDocumentoUsatoA() != null) s_Sql_Find.append(" inner join ( select X.* from ARTICOLO_USATO AS X where X.id_articoloUsato = (SELECT MAX(X2.id_articoloUsato ) FROM ARTICOLO_USATO AS X2 WHERE X2.`id_articolo` = X.id_articolo and X2.dataDocumento <=? )) as CX on A.id_articolo=CX.id_articolo"); if (!CR.getSearchTxtWeb().isEmpty() && !CR.getSearchTxtWeb().equals("*")) { String star = ""; String temp = CR.getSearchTxtWeb().toLowerCase(); temp = prepareInputMySqlString(temp, true); temp = temp.replace("*", "%"); StringTokenizer st = new StringTokenizer(temp.trim(), " "); StringBuffer txt = new StringBuffer("("); while (st.hasMoreTokens()) { String token = star + star; txt.append("(A.descrizioneSearch like '%" + token + "%' or A.codice like '%" + token + "%' or B.descrizioneSearchAv like '%" + token + "%' or A.codicePromozioneA like '%" + token + "%' or A.asinAmz like '%%' or B.codicePromozioneAV like '%" + token + "%' or A.ebayItemId like '%," + token + "%' or A.codiciAlternativi like '%," + token + ",%' or A.tagArticolo like '%," + token + ",%' or B.ebayItemIdAv like '%," + token + "%' or M.descrizione like '%" + token + "%')"); if (st.hasMoreTokens()) { txt.append(" and "); star = "%"; } } txt.append(")"); wc.addWc(txt.toString()); } if (CR.getId_articolo() > 0L) wc.addWc("A.id_articolo=" + CR.getId_articolo()); if (!CR.getSearchTxt().isEmpty() && !CR.getSearchTxt().equals("*")) { String star = ""; String temp = CR.getSearchTxt(); temp = prepareInputMySqlString(temp, true); temp = temp.replace("*", "%"); StringTokenizer st = new StringTokenizer(temp.trim(), " "); StringBuffer txt = new StringBuffer("("); while (st.hasMoreTokens()) { String token = star + star; txt.append("(A.descrizioneSearch like '%" + token + "%' or A.codice like '%" + token + "%' or B.descrizioneSearchAv like '%" + token + "%' or A.codiceEan like '%" + token + "%' or A.codicePromozioneA like '%" + token + "%' or B.codicePromozioneAV like '%" + token + "%' or A.ebayItemId like '%," + token + "%' or A.codiciAlternativi like '%," + temp + ",%' or A.tagArticolo like '%," + token + ",%' or B.ebayItemIdAv like '%," + token + "%' or M.descrizione like '%" + token + "%')"); if (st.hasMoreTokens()) txt.append(" and "); } txt.append(")"); wc.addWc(txt.toString()); } if (!CR.getCategoriaImport().isEmpty()) { String star = ""; String temp = CR.getCategoriaImport().toLowerCase(); temp = prepareInputMySqlString(temp, true); StringTokenizer st = new StringTokenizer(temp.trim(), " "); StringBuffer txt = new StringBuffer(); while (st.hasMoreTokens()) { String token = star + star; txt.append("A.categoriaImport like '%" + token + "%'"); if (st.hasMoreTokens()) txt.append(" and "); } wc.addWc(txt.toString()); } if (!CR.getCompatibilita().trim().isEmpty()) { String star = "%"; String temp = CR.getCompatibilita().trim(); temp = prepareInputMySqlString(temp, true); temp = temp.replace("*", "%"); StringTokenizer st = new StringTokenizer(temp.trim(), " "); StringBuffer txt = new StringBuffer("("); while (st.hasMoreTokens()) { String token = star + star; txt.append("(A.altreCompatibilita like '" + token + "%' or A.compatibilita like '" + token + "%' )"); if (st.hasMoreTokens()) { txt.append(" and "); star = "%"; } } txt.append(")"); wc.addWc(txt.toString()); } if (CR.getFlgControlloCostoAggArt() == 0L) { wc.addWc("(A.flgControlloCostoAggArt = 0 OR A.flgControlloCostoAggArt IS NULL)"); } else if (CR.getFlgControlloCostoAggArt() > 0L) { wc.addWc("A.flgControlloCostoAggArt = " + CR.getFlgControlloCostoAggArt()); } if (CR.getFlgPriceTypeAmz() == 0L) { wc.addWc("(A.flgPriceTypeAmz = 0 OR A.flgPriceTypeAmz IS NULL)"); } else if (CR.getFlgPriceTypeAmz() > 0L) { wc.addWc("A.flgPriceTypeAmz = " + CR.getFlgPriceTypeAmz()); } if (CR.getFlgAsinAmzNull() == 0L) { wc.addWc("A.asinAmz is not null"); wc.addWc("A.asinAmz !=''"); } else if (CR.getFlgAsinAmzNull() > 0L) { wc.addWc("(A.asinAmz is null or A.asinAmz='')"); } if (CR.getFlgPrezzoCompetitivo() == 0L) { wc.addWc("AFP.flgPrezzoCompetitivoAmz=1"); } else if (CR.getFlgPrezzoCompetitivo() == 1L) { wc.addWc("AFP.flgPrezzoCompetitivo=1"); } else if (CR.getFlgPrezzoCompetitivo() == 2L) { wc.addWc("AFP.id_amzFeaturedPrice is not null"); wc.addWc("(AFP.flgPrezzoCompetitivo is null or AFP.flgPrezzoCompetitivo=0) "); wc.addWc("(AFP.flgPrezzoCompetitivoAmz is null or AFP.flgPrezzoCompetitivoAmz=0) "); } else if (CR.getFlgPrezzoCompetitivo() == 3L) { wc.addWc("AFP.id_amzFeaturedPrice is null"); } if (CR.getFlgModImportazione() == 0L) { wc.addWc("(A.flgModImportazione = 0 OR A.flgModImportazione IS NULL)"); } else if (CR.getFlgModImportazione() > 0L) { wc.addWc("A.flgModImportazione = " + CR.getFlgModImportazione()); } if (CR.getFlgTipoSchedaArticoloWww() == 0L) { wc.addWc("(A.flgTipoSchedaArticoloWww = 0 OR A.flgTipoSchedaArticoloWww IS NULL)"); } else if (CR.getFlgTipoSchedaArticoloWww() > 0L) { wc.addWc("A.flgTipoSchedaArticoloWww = " + CR.getFlgTipoSchedaArticoloWww()); } if (!CR.getNMatricola().isEmpty()) wc.addWc("A.nMatricola like '%" + CR.getNMatricola() + "%'"); if (CR.getCountImportNonTrovatoDa() > 0L) wc.addWc("A.countImportNonTrovato>=" + CR.getCountImportNonTrovatoDa()); if (CR.getCountGgNoImportDa() > 0L) wc.addWc("DATEDIFF(CURDATE(), dataUltimoImport)>=" + CR.getCountGgNoImportDa()); if (CR.getCountGgNoImportA() > 0L) wc.addWc("DATEDIFF(CURDATE(), dataUltimoImport)<=" + CR.getCountGgNoImportA()); if (CR.getCountImportNonTrovatoA() > 0L) wc.addWc("A.countImportNonTrovato<=" + CR.getCountImportNonTrovatoA()); if (CR.getCountImpressionDa() > 0L) wc.addWc("A.impression>=" + CR.getCountImpressionDa()); if (CR.getCountImpressionA() > 0L) wc.addWc("A.impression<=" + CR.getCountImpressionA()); if (!CR.getGoogleFeedFileName().isEmpty()) wc.addWc("(A.googleFeedFileName is null or A.googleFeedFileName='' or A.googleFeedFileName like '%" + CR.getGoogleFeedFileName() + "%')"); if (CR.getFlgOrderBy() == 8L || CR.getFlgOrderBy() == 9L) wc.addWc("A.tmstLastImpression is not null"); if (!CR.getCodiceEan().isEmpty()) wc.addWc("A.codiceEan like '%" + CR.getCodiceEan() + "%'"); if (!CR.getScaffale().isEmpty()) if (CR.getScaffale().indexOf("*") >= 0) { String temp = CR.getScaffale().replace("*", "%"); wc.addWc("A.scaffale like'" + temp + "'"); } else { wc.addWc("A.scaffale ='" + CR.getScaffale() + "'"); } if (CR.getId_clifor() > 0L) wc.addWc("DOC.id_clifor=" + CR.getId_clifor()); if (CR.getId_fornitore() > 0L) wc.addWc("AF.id_clifor=" + CR.getId_fornitore()); if (CR.getId_fornitoreCostoNuovo() > 0L) wc.addWc("A.id_fornitoreCostoNuovo=" + CR.getId_fornitoreCostoNuovo()); if (CR.getId_fornitoreUsato() > 0L) wc.addWc("AU.id_fornitore=" + CR.getId_fornitoreUsato()); if (CR.getPrezzoDa() > 0.0D) wc.addWc("A.prezzoPubblicoIvaOrd>=" + CR.getPrezzoDa()); if (CR.getPrezzoA() > 0.0D) wc.addWc("A.prezzoPubblicoIvaOrd<=" + CR.getPrezzoA()); if (CR.getFlgPercRicaricoEffettivoLike() == 1L) { wc.addWc("A.percRicaricoEffettivo >=" + CR.getPercRicaricoEffettivo()); } else if (CR.getFlgPercRicaricoEffettivoLike() == 2L) { wc.addWc("A.percRicaricoEffettivo <=" + CR.getPercRicaricoEffettivo()); } else if (CR.getFlgPercRicaricoEffettivoLike() == 3L) { wc.addWc("A.percRicaricoEffettivo =" + CR.getPercRicaricoEffettivo()); } if (!CR.getLangReadyForWeb().isEmpty()) if (CR.getFlgReadyForWeb() == 1L) { wc.addWc("A.readyForWeb like '%," + CR.getLangReadyForWeb() + ",%'"); } else if (CR.getFlgReadyForWeb() == 2L) { wc.addWc("A.readyForWeb like '%," + CR.getLangReadyForWeb() + ",%'"); wc.addWc("A.erroriSeo is not null and LENGTH(A.erroriSeo) > 1"); } else if (CR.getFlgReadyForWeb() == 0L) { wc.addWc("(A.readyForWeb is null or A.readyForWeb not like '%," + CR.getLangReadyForWeb() + ",%')"); } if (CR.getFlgIcecatAuto() == 0L) { wc.addWc("(M.flgIcecatAuto =0 or M.flgIcecatAuto is null)"); } else if (CR.getFlgIcecatAuto() > 0L) { wc.addWc("M.flgIcecatAuto=" + CR.getFlgIcecatAuto()); } if (CR.getDataMovimento() == null && CR.getDataDocumentoUsatoA() == null) if (CR.getFlgQta() == 1L) if (CR.getQtaDa() == 0L) { wc.addWc("(A.quantita<=" + CR.getQtaA() + " or B.quantitaAv<=" + CR.getQtaA() + ")"); } else { wc.addWc("(A.quantita>=" + CR.getQtaDa() + " or B.quantitaAv>=" + CR.getQtaDa() + ")"); wc.addWc("(A.quantita<=" + CR.getQtaA() + " or B.quantitaAv<=" + CR.getQtaA() + ")"); } if (!CR.getCurrentCodice().isEmpty()) if (CR.getFlgOrderType().toLowerCase().equals("desc")) { wc.addWc("A.codice <'" + CR.getCurrentCodice() + "'"); } else { wc.addWc("A.codice >'" + CR.getCurrentCodice() + "'"); } if (CR.getFlgDisponibile() == 1L) wc.addWc("A.quantita>=1"); if (!CR.getCodice().isEmpty()) { String temp = prepareInputMySqlString(CR.getCodice(), true); if (temp.length() < 10) { String temp10 = zeroLeft(temp, 10); wc.addWc("(A.codice like'" + temp + "%'or A.codice ='" + temp10 + "' or B.codiceVariante like '" + temp + "%' or B.codiceVariante='" + temp10 + "')"); } else { wc.addWc("(A.codice like'" + temp + "%' or B.codiceVariante like '" + temp + "%')"); } } if (CR.getId_statoUsato() != 0L) wc.addWc("A.id_statoUsato=" + CR.getId_statoUsato()); if (CR.getId_marca() != 0L) wc.addWc("A.id_marca=" + CR.getId_marca()); if (!CR.getId_marche().isEmpty()) { StringTokenizer st = new StringTokenizer(CR.getId_marche(), ","); StringBuilder wcmarche = new StringBuilder("("); while (st.hasMoreTokens()) { long token = Long.parseLong(st.nextToken()); wcmarche.append("A.id_marca= " + token); if (st.hasMoreTokens()) wcmarche.append(" or "); } wcmarche.append(")"); wc.addWc(wcmarche.toString()); } if (CR.getId_tipoAccessorio() > 0L) wc.addWc("A.id_tipoAccessorio=" + CR.getId_tipoAccessorio()); if (CR.getId_magFisico() > 0L) wc.addWc("A.codiciMagazzino like'%," + CR.getId_magFisico() + ",%'"); if (CR.getId_vetrina() > 0L) wc.addWc("(A.id_vetrina=" + CR.getId_vetrina() + " or B.id_vetrina=" + CR.getId_vetrina() + ")"); if (CR.getFlgNoleggio() == 20L) { wc.addWc("A.flgNoleggio>=1"); } else if (CR.getFlgNoleggio() > 0L) { wc.addWc("A.flgNoleggio=" + CR.getFlgNoleggio()); } if (CR.getFlgRiordino() == 1L) wc.addWc("((A.quantitaEffettiva = null and A.qtaRiordino>0)or A.quantitaEffettiva 0L) { wc.addWc("A.flgKit=" + CR.getFlgKit()); } if (CR.getFlgEscludiWeb() == 0L) { wc.addWc("(A.flgEscludiWeb=0 or A.flgEscludiWeb is null)"); } else if (CR.getFlgEscludiWeb() > 0L) { wc.addWc("A.flgEscludiWeb=" + CR.getFlgEscludiWeb()); } if (CR.getFlgWebNoVendita() == 0L) { wc.addWc("(A.flgWebNoVendita=0 or A.flgWebNoVendita is null)"); } else if (CR.getFlgWebNoVendita() > 0L) { wc.addWc("A.flgWebNoVendita=" + CR.getFlgWebNoVendita()); } if (CR.getFlgArticoloComponente() == 0L) { wc.addWc("(A.flgArticoloComponente=0 or A.flgArticoloComponente is null)"); } else if (CR.getFlgArticoloComponente() > 0L) { wc.addWc("A.flgArticoloComponente=" + CR.getFlgArticoloComponente()); } if (CR.getFlgNascondi() == 0L) { wc.addWc("(A.flgNascondi=0 or A.flgNascondi is null)"); wc.addWc("(B.flgNascondi=0 or B.flgNascondi is null)"); wc.addWc("(C.flgNascondi=0 or C.flgNascondi is null)"); if (CR.getFlgUsaDisponibilita() == 1L) wc.addWc("(B.flgNascondi=0 or B.flgNascondi is null)"); } else if (CR.getFlgNascondi() > 0L) { wc.addWc("A.flgNascondi=" + CR.getFlgNascondi()); wc.addWc("C.flgNascondi=" + CR.getFlgNascondi()); if (CR.getFlgUsaDisponibilita() == 1L) wc.addWc("B.flgNascondi=" + CR.getFlgNascondi()); } if (CR.getId_tipoSel() != 0L) wc.addWc("(A.id_tipo=" + CR.getId_tipoSel() + " or C.indici like'%:" + CR.getId_tipoSel() + ":%')"); if (CR.getFlgRateale0() == 0L) { wc.addWc("(A.flgRateale0 is null or A.flgRateale0=0)"); } else if (CR.getFlgRateale0() > 0L) { wc.addWc("A.flgRateale0= " + CR.getFlgRateale0()); } if (CR.getFlgGoogle() == 0L) { wc.addWc("(A.flgGoogle is null or A.flgGoogle=0)"); } else if (CR.getFlgGoogle() == 1L || CR.getFlgGoogle() == 2L) { wc.addWc("A.flgGoogle= " + CR.getFlgGoogle()); } else if (CR.getFlgGoogle() == 3L) { wc.addWc("(A.flgGoogle=1 or A.flgGoogle=2)"); } if (CR.getFlgTrovaprezzi() == 0L) { wc.addWc("(A.flgTrovaprezzi is null or A.flgTrovaprezzi=0)"); } else if (CR.getFlgTrovaprezzi() > 0L) { wc.addWc("A.flgTrovaprezzi= " + CR.getFlgTrovaprezzi()); } if (CR.getFlgIdealo() == 0L) { wc.addWc("(A.flgIdealo is null or A.flgIdealo=0)"); } else if (CR.getFlgIdealo() > 0L) { wc.addWc("A.flgIdealo= " + CR.getFlgIdealo()); } if (CR.getFlgSubito() == 0L) { wc.addWc("(A.flgSubito is null or A.flgSubito=0)"); } else if (CR.getFlgSubito() > 0L) { wc.addWc("A.flgSubito= " + CR.getFlgSubito()); } if (CR.getFlgEbay() == 0L) { wc.addWc("(A.flgEbay is null or A.flgEbay=0)"); } else if (CR.getFlgEbay() > 0L) { wc.addWc("A.flgEbay= " + CR.getFlgEbay()); } if (CR.getFlgAmazon() == 0L) { wc.addWc("(A.flgAmazon is null or A.flgAmazon=0)"); } else if (CR.getFlgAmazon() > 0L) { wc.addWc("A.flgAmazon= " + CR.getFlgAmazon()); } if (CR.getFlgAmzWarn() == 0L) { wc.addWc("(A.flgAmzWarn is null or A.flgAmzWarn=0)"); } else if (CR.getFlgAmzWarn() > 0L) { wc.addWc("A.flgAmzWarn= " + CR.getFlgAmzWarn()); } if (CR.getFlgEbayPubblicato() == 0L) { wc.addWc("(A.ebayOfferId is null or A.ebayOfferId='')"); } else if (CR.getFlgEbayPubblicato() > 0L) { wc.addWc("LENGTH(A.ebayOfferId)>0"); if (CR.getFlgEbayPubblicato() == 9L) wc.addWc("((qtaEbay=0 && qtaSuEbay!=quantita) or (qtaEbay>0 && qtaSuEbay!=LEAST(quantita,qtaEbay)))"); } if (CR.getFlgInEsaurimento() == 0L) { wc.addWc("(A.flgInEsaurimento is null or A.flgInEsaurimento=0)"); } else if (CR.getFlgInEsaurimento() > 0L) { wc.addWc("A.flgInEsaurimento= " + CR.getFlgInEsaurimento()); } if (CR.getFlgContoVendita() == 0L) { wc.addWc("(A.flgContoVendita is null or A.flgContoVendita=0)"); } else if (CR.getFlgContoVendita() > 0L) { wc.addWc("A.flgContoVendita= " + CR.getFlgContoVendita()); } if (CR.getFlgUsato() >= 0L) if (CR.getFlgUsato() == 0L) { wc.addWc("(A.flgUsato= 0 or A.flgUsato is null)"); } else if (CR.getFlgUsato() == 99L) { wc.addWc("A.flgUsato>=1"); } else { wc.addWc("A.flgUsato=" + CR.getFlgUsato()); } if (CR.getCarId_lista() != 0L) { Lista lista = new Lista(getApFull()); lista.findByPrimaryKey(CR.getCarId_lista()); wc.addWc("A.caratteristiche like '%," + lista.getValore() + ",%'"); } if (CR.getCarId_lista1() != 0L) { Lista lista = new Lista(getApFull()); lista.findByPrimaryKey(CR.getCarId_lista1()); wc.addWc("A.caratteristiche like '%," + lista.getValore() + ",%'"); } if (CR.getId_lista1() > 0L) { s_Sql_Find.append(" , CARATTERISTICA_ARTICOLO AS CA1"); wc.addWc("A.id_articolo=CA1.id_articolo"); } if (CR.getId_lista2() > 0L) { s_Sql_Find.append(" , CARATTERISTICA_ARTICOLO AS CA2"); wc.addWc("A.id_articolo=CA2.id_articolo"); } if (CR.getId_lista3() > 0L) { s_Sql_Find.append(" , CARATTERISTICA_ARTICOLO AS CA3"); wc.addWc("A.id_articolo=CA3.id_articolo"); } if (CR.getId_lista4() > 0L) { s_Sql_Find.append(" , CARATTERISTICA_ARTICOLO AS CA4"); wc.addWc("A.id_articolo=CA4.id_articolo"); } if (CR.getValSN1() == 1L) { s_Sql_Find.append(" , CARATTERISTICA_ARTICOLO AS CAV1"); wc.addWc("A.id_articolo=CAV1.id_articolo"); } if (CR.getValSN2() == 1L) { s_Sql_Find.append(" , CARATTERISTICA_ARTICOLO AS CAV2"); wc.addWc("A.id_articolo=CAV2.id_articolo"); } if (CR.getValSN3() == 1L) { s_Sql_Find.append(" , CARATTERISTICA_ARTICOLO AS CAV3"); wc.addWc("A.id_articolo=CAV3.id_articolo"); } if (CR.getId_lista1() != 0L) wc.addWc("CA1.id_lista=" + CR.getId_lista1()); if (CR.getId_lista2() != 0L) wc.addWc("CA2.id_lista=" + CR.getId_lista2()); if (CR.getId_lista3() != 0L) wc.addWc("CA3.id_lista=" + CR.getId_lista3()); if (CR.getId_lista4() != 0L) wc.addWc("CA4.id_lista=" + CR.getId_lista4()); if (CR.getValSN1() == 1L) { wc.addWc("CAV1.valSN=1"); wc.addWc("CAV1.id_caratteristica=" + CR.getId_caratteristicaValSN1()); } if (CR.getId_iva() != 0L) wc.addWc("A.id_iva=" + CR.getId_iva()); if (!CR.getNomeV().isEmpty()) wc.addWc("B.nomeV='" + CR.getNomeV() + "'"); if (!CR.getCodiceSerieV().isEmpty()) wc.addWc("B.codiceSerieV='" + CR.getCodiceSerieV() + "'"); if (!CR.getDescrizioneArticolo().isEmpty()) wc.addWc("A.nome LIKE '%" + CR.getDescrizioneArticolo() + "%'"); if (!CR.getNome().isEmpty()) wc.addWc("A.nome LIKE '%" + CR.getNome() + "%'"); if (CR.getDataDocumentoUsatoA() != null) wc.addWc("(CX.flgTipoDocumento=1 or CX.flgTipoDocumento=3 ) "); if (CR.getFlgOrderBy() == 10L) wc.addWc("(A.hashCodeCurrent is null or A.hashCodeCurrent<>A.hashCodeIndexNow) "); if (CR.getFlgStockOfferte() > 0L) if (CR.getFlgStockOfferte() == 99L) { wc.addWc("(A.flgStockOfferte=1 and (A.dataScadenzaOfferta is null or A.dataScadenzaOfferta>=?))"); } else { wc.addWc("A.flgStockOfferte=" + CR.getFlgStockOfferte()); } if (CR.getFlgOfferta() == 1L) { wc.addWc("(A.dataScadenzaOfferta>=? or A.dataScadenzaOffertaFornitore>=?)"); } else if (CR.getFlgOfferta() == 0L) { wc.addWc("(A.dataScadenzaOfferta=?)"); } else if (CR.getFlgOfferta() == 11L) { wc.addWc("(A.dataScadenzaOfferta>=? )"); } else if (CR.getFlgOfferta() == 22L) { wc.addWc("(A.dataScadenzaOffertaFornitore is not null and A.dataScadenzaOffertaFornitore=?"); if (CR.getDataDocumentoA() != null) wc.addWc("DOC.dataDocumento<=? "); if (CR.getDataCreazioneDa() != null) wc.addWc("A.createTmst>=?"); if (CR.getDataCreazioneA() != null) wc.addWc("A.createTmst<=?"); if (CR.getDataUpdateDa() != null) wc.addWc("A.lastUpdTmst>=? "); if (CR.getFlgAmzFeaturedPriceData() == 1L) wc.addWc("(AFP.dataPriceAmz is null or AFP.dataPriceAmz "); sb.append(getNf().format(getQuantita())); sb.append(""); } else { sb.append(getNf().format(getQuantita())); } sb.append(" + "); sb.append(" "); sb.append(getNf().format(getQuantitaInArrivo())); sb.append(""); sb.append(" - "); sb.append(" "); sb.append(getNf().format(getQuantitaImpegnata())); sb.append(""); sb.append(" = "); sb.append(" "); sb.append(getNf().format(getQuantitaEffettiva())); sb.append(""); return sb.toString(); } public double getImportListinoPrezzoOfferta() { return this.prezzoOfferta; } public void setPrezzoOfferta(double prezzoOfferta) { this.prezzoOfferta = prezzoOfferta; } public long getTipoArticoloVetrina() { return 0L; } public String getCaratteristicheListeId() { return (this.caratteristicheListeId == null) ? "" : this.caratteristicheListeId.trim(); } public void setCaratteristicheListeId(String caratteristicheListeId) { this.caratteristicheListeId = caratteristicheListeId; } public void setLavaggio(long newLavaggio) { this.lavaggio = newLavaggio; setSimboliLavaggio(null); } public void setCandeggio(long newCandeggio) { this.candeggio = newCandeggio; setSimboliLavaggio(null); } public void setStiratura(long newStiratura) { this.stiratura = newStiratura; setSimboliLavaggio(null); } public void setPulituraSecco(long newPulituraSecco) { this.pulituraSecco = newPulituraSecco; setSimboliLavaggio(null); } public void setAsciugatura(long newAsciugatura) { this.asciugatura = newAsciugatura; setSimboliLavaggio(null); } public void setMassaLineare(long newMassaLineare) { this.massaLineare = newMassaLineare; } public void setAltezzaMinima(long newAltezzaMinima) { this.altezzaMinima = newAltezzaMinima; } public long getLavaggio() { return this.lavaggio; } public long getCandeggio() { return this.candeggio; } public long getStiratura() { return this.stiratura; } public long getPulituraSecco() { return this.pulituraSecco; } public long getAsciugatura() { return this.asciugatura; } public long getMassaLineare() { return this.massaLineare; } public long getAltezzaMinima() { return this.altezzaMinima; } public SimboliLavaggio getSimboliLavaggio() { if (this.simboliLavaggio == null) { this.simboliLavaggio = new SimboliLavaggio(); this.simboliLavaggio.setAsciugatura(getAsciugatura()); this.simboliLavaggio.setCandeggio(getCandeggio()); this.simboliLavaggio.setLavaggio(getLavaggio()); this.simboliLavaggio.setPulituraSecco(getPulituraSecco()); this.simboliLavaggio.setStiratura(getStiratura()); } return (this.simboliLavaggio == null) ? new SimboliLavaggio() : this.simboliLavaggio; } public ResParm addArticoloComponente(ArticoloComponente row) { ResParm rp = new ResParm(true); ArticoloComponente bean = new ArticoloComponente(getApFull()); bean.findByArticoloComponente(row.getId_articolo(), row.getId_componente()); if (bean.getDBState() == 1) { bean.setPerc(row.getPerc()); rp = bean.save(); } else { row.setDBState(0); rp = row.save(); } return rp; } public ResParm delArticoloComponente(ArticoloComponente row) { ArticoloComponente bean = new ArticoloComponente(getApFull()); bean.findByPrimaryKey(row.getId_articoloComponente()); return bean.delete(); } public double getPercTotaleComponenti() { String s_Sql_Find = "select SUM(A.perc) AS _sum from ARTICOLO_COMPONENTE AS A"; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc("id_articolo = " + getId_articolo()); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); return getSum(stmt); } catch (SQLException e) { handleDebug(e); return 0.0D; } } public ResParm addListinoArticolo(ListinoArticolo row) { ResParm rp = new ResParm(true); ListinoArticolo bean = new ListinoArticolo(getApFull()); bean.findByArticoloListino(row.getId_articolo(), row.getId_listino()); if (bean.getDBState() == 1) { bean.setPrezzoLA(row.getPrezzoLA()); bean.setPercLA(row.getPercLA()); bean.setPercLA1(row.getPercLA1()); bean.setPercLA2(row.getPercLA2()); bean.setPercLA3(row.getPercLA3()); rp = bean.save(); } else { row.setDBState(0); rp = row.save(); } return rp; } public ResParm delListinoArticolo(ListinoArticolo row) { ListinoArticolo bean = new ListinoArticolo(getApFull()); bean.findByPrimaryKey(row.getId_listinoArticolo()); return bean.delete(); } public void setId_articoloTaglia(long id_articoloTaglia) { this.id_articoloTaglia = id_articoloTaglia; setArticoloTaglia(null); } public Vectumerator findByCRAv(ArticoloCR CR, int pageNumber, int pageRows) { if (CR.getFlgTipoRicerca() == 1L) return findByCRSerMagazzino(CR, pageNumber, pageRows); String s_Sql_Find1 = "select C.id_articoloTaglia, B.id_articoloVariante as id_articoloVariante, A.* from ARTICOLO AS A JOIN ARTICOLO_VARIANTE AS B ON A.id_articolo=B.id_articolo LEFT JOIN ARTICOLO_TAGLIA AS C ON A.id_articolo=C.id_articolo AND B.id_articoloVariante=C.id_articoloVariante"; String s_Sql_Find2 = "select C.id_articoloTaglia, 0 as id_articoloVariante, A.* from ARTICOLO AS A LEFT JOIN ARTICOLO_TAGLIA AS C ON A.id_articolo=C.id_articolo and (C.id_articoloVariante is null or C.id_articoloVariante=0) "; String s_Sql_Order = " order by A.nome"; WcString wc = new WcString(); StringBuffer wcArt = new StringBuffer(""); StringBuffer wcArtVar = new StringBuffer(""); if (!CR.getSearchTxt().trim().isEmpty()) { String star = ""; String temp = CR.getSearchTxt().trim(); temp = prepareInputMySqlString(temp, true); temp = temp.replace("*", "%"); StringTokenizer st = new StringTokenizer(temp.trim(), " "); while (st.hasMoreTokens()) { String token = star + star; wcArt.append("(A.codice like '%" + token + "%' or A.descrizioneSearch like '%" + token + "%' or A.codiciAlternativi like '%," + token + "%')"); wcArtVar.append("(A.codice like '%" + token + "%' or A.nome like '%" + token + "%' or B.codiceVariante like '%" + token + "%' or B.codiciAlternativiV like '%," + token + ",%' or B.nomeV like '%" + token + "%')"); if (st.hasMoreTokens()) { wcArt.append(" and "); wcArtVar.append(" and "); star = "%"; } } } if (wcArtVar.length() > 0) { wcArtVar.append(" and "); wcArt.append(" and "); } wcArtVar.insert(0, " where "); wcArtVar.append(" B.id_articoloVariante Is Not Null AND A.flgUsaVarianti=1 and (A.flgNascondi=0 or A.flgNascondi is null) and (A.flgArticoloComponente is null or A.flgArticoloComponente=0) and A.dataFineVld is null"); wcArt.insert(0, " where "); wcArt.append(" (A.flgUsaVarianti=0 or A.flgUsaVarianti is null) and (A.flgArticoloComponente is null or A.flgArticoloComponente=0) and (A.flgNascondi=0 or A.flgNascondi is null) and A.dataFineVld is null"); if (CR.getFlgEscludiWeb() == 0L) { wcArt.append(" and (A.flgEscludiWeb=0 or A.flgEscludiWeb is null)"); } else if (CR.getFlgEscludiWeb() > 0L) { wcArt.append(" and A.flgEscludiWeb=" + CR.getFlgEscludiWeb()); } try { PreparedStatement stmt = getConn().prepareStatement("(" + s_Sql_Find1 + wcArtVar.toString() + s_Sql_Order + ") union (" + s_Sql_Find2 + wcArt.toString() + s_Sql_Order + ")"); return findRows(stmt, pageNumber, pageRows); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public void arrotondaPrezzoPubblicoConIva() { if (getDBState() == 1 && getId_iva() == 6L) System.out.println("SE ARRIVA QUI SIAMO NEI GUAI"); } public long getFlgNoListinoArt() { return this.flgNoListinoArt; } public void setFlgNoListinoArt(long flgNoListinoArt) { this.flgNoListinoArt = flgNoListinoArt; } private double getPercScontoListino(Clifor l_clifor) { if (getFlgNoListino() == 1L) return 0.0D; Listino listino = l_clifor.getListino(); if (listino.getId_listino() > 0L) return listino.getPercSconto(this); return 0.0D; } public long getId_fornitoreAbituale() { ArticoloFornitore af = new ArticoloFornitore(getApFull()); af.findByArticoloFornitoreAbituale(getId_articolo()); return af.getId_clifor(); } public Clifor getFornitoreAbituale() { ArticoloFornitore af = new ArticoloFornitore(getApFull()); af.findByArticoloFornitoreAbituale(getId_articolo()); return af.getFornitore(); } public double getQtaDaRiordinare(long l_id_rigaDocumento) { if (l_id_rigaDocumento > 0L) { RigaDocumento rd = new RigaDocumento(getApFull()); rd.findByPrimaryKey(l_id_rigaDocumento); double[] res = rd.getQtaOrdinataPrelevataByRigaPrenotazione(); double qtOrd = res[0]; DoubleOperator dop = new DoubleOperator(rd.getQuantita()); dop.subtract(qtOrd); return Math.max(0.0D, dop.getResult()); } return getQtaDaRiordinare(); } public String getQuantitaMagazzinoMovimentoHtml() { if (getParm("USA_MAGAZZINO").isTrue()) return getNf().format(getQuantita()); if (!isQuantitaCalcolate() && this.id_articolo != 0L) calcolaQuantita(); return (this.quantitaMagazzinoMovimentoHtml == null) ? "" : this.quantitaMagazzinoMovimentoHtml; } public TipologiaArticolo getTipologiaArticolo() { return getTipo().getTipologiaArticolo(); } public ResParm superSave() { return super.save(); } public long getFlgTipoMagazzino() { return this.flgTipoMagazzino; } public void setFlgTipoMagazzino(long flgTipoMagazzino) { this.flgTipoMagazzino = flgTipoMagazzino; } public double getQuantitaW() { if (!isQuantitaCalcolate() && this.id_articolo != 0L) calcolaQuantita(); return this.quantitaW; } public void setQuantitaW(double quantitaW) { this.quantitaW = quantitaW; } public long getFlgDispo() { return this.flgDispo; } public void setFlgDispo(long flgDispo) { this.flgDispo = flgDispo; } public Vectumerator findByCRSerMagazzino(ArticoloCR CR, int pageNumber, int pageRows) { handleDebug("findbycrsermagazzino chiamata!!", 1); try { Vectumerator vec = new Vectumerator(); String sql = "SELECT M.id_articolo as id_artmov, A.id_articolo,A.codice,A.codiceEan, 0 as id_articoloTaglia, M.id_articoloVariante,M.id_clifor, M.seriale, SUM(segnoMov*kg) as kg, SUM(segnoMov*mt) as mt, SUM(segnoMov*nr) as nr, A.nome,A.id_marca,A.id_tipo,A.percSconto,A.id_iva,A.prezzoOfferta,A.prezzoPubblico,A.flgSerialiMassivi FROM RIGA_DOCUMENTO AS M INNER JOIN ARTICOLO AS A ON A.id_articolo=M.id_articolo "; String s_Sql_GrouBy = " group by M.id_articolo, M.id_clifor, M.seriale "; String s_Sql_Having = " HAVING ( nr>0 and A.id_articolo>0 and M.seriale is not null ) "; WcString wc = new WcString(); if (!CR.getSearchTxt().trim().isEmpty()) { String star = ""; String temp = CR.getSearchTxt().trim(); StringTokenizer st = new StringTokenizer(temp.trim(), " "); StringBuffer txt = new StringBuffer("("); while (st.hasMoreTokens()) { String token = star + star; token = prepareInputMySqlString(token, false); token = token.replace("*", "%"); txt.append("(A.codice like '%" + token + "%' or A.nome like '%" + token + "%' or M.seriale = '" + token + "%' or A.codiceEan like '%" + token + "%' or A.codiciAlternativi like '%," + token + ",%' )"); if (st.hasMoreTokens()) { txt.append(" and "); star = "%"; } } txt.append(")"); wc.addWc(txt.toString()); } if (isDeleteLogic()) if (CR.getFlgShowDeleteLogic() == 0L) { wc.addWc("A.dataFineVld is null"); } else { wc.addWc("A.dataFineVld is not null"); } if (CR.getId_clifor() != 0L && CR.getId_magFisico() > 0L && CR.getMagFisico().getFlgTipo() != 1L) { wc.addWc("(M.id_clifor=" + CR.getId_clifor() + ")"); } else { wc.addWc("(M.id_clifor=0 or M.id_clifor is null )"); } wc.addWc(" M.id_magFisico=" + CR.getId_magFisico()); String s_Sql_Find1 = "select 0 as id_artmov, A.id_articolo,A.codice,A.codiceEan, C.id_articoloTaglia, B.id_articoloVariante,0 as id_clifor,null as seriale,0 as kg, 0 as mt, 0 as nr, A.nome,A.id_marca,A.id_tipo,A.percSconto,A.id_iva,A.prezzoOfferta,A.prezzoPubblico,A.flgSerialiMassivi from ARTICOLO AS A inner join TIPO as T on A.id_tipo=T.id_tipo left JOIN ARTICOLO_VARIANTE AS B ON A.id_articolo = B.id_articolo LEFT JOIN ARTICOLO_TAGLIA as C on A.id_articolo=C.id_articolo and B.id_articoloVariante=C.id_articoloVariante"; String s_Sql_Order = " "; WcString wc1 = new WcString(); wc1.addWc("T.flgTipoMagazzino!=2"); if (!CR.getSearchTxt().trim().isEmpty()) { String star = ""; String temp = CR.getSearchTxt().trim(); StringTokenizer st = new StringTokenizer(temp.trim(), " "); StringBuffer txt = new StringBuffer("("); while (st.hasMoreTokens()) { String token = star + star; token = prepareInputMySqlString(token, false); token = token.replace("*", "%"); txt.append("(A.codice like '%" + token + "%' or A.nome like '%" + token + "%' or C.codiceAT = '" + token + "' or A.codiceEan like '%" + token + "%'or A.codiciAlternativi like '%," + token + ",%' or B.codiceVariante like '%" + token + "%' or B.nomeV like '%" + token + "%')"); if (st.hasMoreTokens()) { txt.append(" and "); star = "%"; } } txt.append(")"); wc1.addWc(txt.toString()); } if (isDeleteLogic()) if (CR.getFlgShowDeleteLogic() == 0L) { wc1.addWc("A.dataFineVld is null"); } else { wc1.addWc("A.dataFineVld is not null"); } PreparedStatement stmt = getConn().prepareStatement("(" + sql + wc.toString() + s_Sql_GrouBy + s_Sql_Having + ") union (" + s_Sql_Find1 + wc1.toString() + s_Sql_Order + ")"); return findRows(stmt, pageNumber, 50); } catch (SQLException e) { handleDebug(e); e.printStackTrace(); return AB_EMPTY_VECTUMERATOR; } } public double getImportAbbuonoPrezzoPubblico() { return this.abbuonoPrezzoPubblico; } public double getAbbuonoPrezzoPubblico() { return getListinoArticoloBase().getAbbuonoPrezzoPubblicoLA(); } public double getImportListinoAbbuonoPrezzoPubblico() { return this.abbuonoPrezzoPubblico; } public void setAbbuonoPrezzoPubblico(double abbuonoPrezzoPubblico) { this.abbuonoPrezzoPubblico = abbuonoPrezzoPubblico; } public ResParm ebayDeleteInventoryItem() { boolean debug = false; ResParm rp = new ResParm(); if (getId_articolo() == 0L) { rp.setStatus(false); rp.setMsg("Errore! Articolo nullo o non valido!"); } else { Attivita attivita = Attivita.getDefaultInstance(getApFull()); if (attivita.isEbayPubblicabile()) { EbayAbliaApi ebay = new EbayAbliaApi(getApFull()); if (ebay.isOAuthTokenValid()) { EbayResult res = new EbayResult(); res.setOk(true); if (!getEbayOfferId().isEmpty()) { if (debug) System.out.println("Articolo.ebayDeleteInventoryItem ebayDeleteOffer..."); res = ebay.ebayDeleteOffer(this); if (debug) System.out.println("Articolo.ebayDeleteInventoryItem ebayDeleteOffer..." + res.getMsg()); } if (res.isOk()) { if (debug) System.out.println("Articolo.ebayDeleteInventoryItem ebayDeleteInventoryItem..."); res = ebay.ebayDeleteInventoryItem(this); if (debug) System.out.println("Articolo.ebayDeleteInventoryItem ebayDeleteInventoryItem..." + res.getMsg()); } if (res.isOk()) { rp.setStatus(true); rp.setMsg("Articolo inserito o aggiornato correttamente"); } else { rp.setStatus(false); rp.setMsg("Errore! " + res.getMsg()); } } else { rp.setStatus(false); rp.setMsg("Errore! User token non valido! Richiedere nuovo token oAuth!"); } } else { rp.setStatus(false); rp.setMsg("Errore! Mancano i profiles id su attivita!"); } } return rp; } public ResParm ebayRemoveOffer() { ResParm rp = new ResParm(); if (getId_articolo() == 0L) { rp.setStatus(false); rp.setMsg("Errore! Articolo nullo o non valido!"); } else { Attivita attivita = Attivita.getDefaultInstance(getApFull()); EbayAbliaApi ebay = new EbayAbliaApi(getApFull()); if (ebay.isOAuthTokenValid()) { EbayResult res = new EbayResult(); res.setOk(true); if (getEbayOfferId().isEmpty()) { rp.setStatus(false); rp.setMsg("Errore! articolo senza id offerta"); } else { res = ebay.ebayDeleteOffer(this); } if (res.isOk()) { rp.setStatus(true); rp.setMsg("Offerta " + getEbayOfferId() + " rimossa correttamente!"); setEbayOfferId(null); superSave(); } else { rp.setStatus(false); rp.setMsg("Errore! " + res.getMsg()); } } else { rp.setStatus(false); rp.setMsg("Errore! User token non valido! Richiedere nuovo token oAuth!"); } } return rp; } public void setQuantitaMagazzinoMovimentoHtml(String quantitaMagazzinoMovimentoHtml) { this.quantitaMagazzinoMovimentoHtml = quantitaMagazzinoMovimentoHtml; } public String getImgFileName(int imgNumber, int scaledWidth) { String targetDir = getDocBase() + getDocBase(); String newImageName = "" + scaledWidth + "/" + scaledWidth; String srcFileName = targetDir + targetDir; String targetFileName = targetDir + targetDir; ResParm rp = ScaleImage.scaleImageToFile(srcFileName, targetFileName, getPathTmpFull(), scaledWidth, 75); if (rp.getStatus()) return newImageName; return getImgFileName(imgNumber, getImgTmst()); } public Vectumerator findByCRSerMovimentoTUTTIICAMPI(ArticoloCR CR, int pageNumber, int pageRows) { try { Vectumerator vec = new Vectumerator(); String sql = "SELECT M.id_articolo as id_artmov, A.id_articolo, 0 as id_articoloTaglia, M.id_articoloVariante,M.id_clifor, M.seriale, SUM(kg) as kg, SUM(mt) as mt, SUM(nr) as nr, A.* FROM MOVIMENTO AS M INNER JOIN ARTICOLO AS A ON A.id_articolo=M.id_articolo "; String s_Sql_GrouBy = " group by M.id_articolo, M.id_clifor, M.seriale "; String s_Sql_Having = " HAVING ( nr>0 and A.id_articolo>0 and M.seriale is not null) "; WcString wc = new WcString(); if (!CR.getSearchTxt().trim().isEmpty()) { String star = ""; String temp = CR.getSearchTxt().trim(); StringTokenizer st = new StringTokenizer(temp.trim(), " "); StringBuffer txt = new StringBuffer("("); while (st.hasMoreTokens()) { String token = star + star; token = prepareInputMySqlString(token, false); token = token.replace("*", "%"); txt.append("(A.codice like '%" + token + "%' or A.nome like '%" + token + "%' or M.seriale = '" + token + "'or A.codiciAlternativi like '%," + token + ",%' )"); if (st.hasMoreTokens()) { txt.append(" and "); star = "%"; } } txt.append(")"); wc.addWc(txt.toString()); } if (isDeleteLogic()) if (CR.getFlgShowDeleteLogic() == 0L) { wc.addWc("A.dataFineVld is null"); } else { wc.addWc("A.dataFineVld is not null"); } if (CR.getId_clifor() != 0L && CR.getMagFisico().getFlgTipo() != 1L) { wc.addWc("(M.id_clifor=" + CR.getId_clifor() + ")"); } else { wc.addWc("(M.id_clifor=0 or M.id_clifor is null )"); } wc.addWc(" M.id_magFisico=" + CR.getId_magFisico()); String s_Sql_Find1 = "select 0 as id_artmov, A.id_articolo, C.id_articoloTaglia, B.id_articoloVariante,0 as id_clifor,null as seriale,0 as kg, 0 as mt, 0 as nr, A.* from ARTICOLO AS A inner join TIPO as T on A.id_tipo=T.id_tipo left JOIN ARTICOLO_VARIANTE AS B ON A.id_articolo = B.id_articolo LEFT JOIN ARTICOLO_TAGLIA as C on A.id_articolo=C.id_articolo and B.id_articoloVariante=C.id_articoloVariante"; String s_Sql_Order = " "; WcString wc1 = new WcString(); wc1.addWc("T.flgTipoMagazzino!=2"); if (!CR.getSearchTxt().trim().isEmpty()) { String star = ""; String temp = CR.getSearchTxt().trim(); StringTokenizer st = new StringTokenizer(temp.trim(), " "); StringBuffer txt = new StringBuffer("("); while (st.hasMoreTokens()) { String token = star + star; token = prepareInputMySqlString(token, false); token = token.replace("*", "%"); txt.append("(A.codice like '%" + token + "%' or A.nome like '%" + token + "%' or C.codiceAT = '" + token + "'or A.codiciAlternativi like '%," + token + ",%' or B.nomeV like '%" + token + "%')"); if (st.hasMoreTokens()) { txt.append(" and "); star = "%"; } } txt.append(")"); wc1.addWc(txt.toString()); } if (isDeleteLogic()) if (CR.getFlgShowDeleteLogic() == 0L) { wc1.addWc("A.dataFineVld is null"); } else { wc1.addWc("A.dataFineVld is not null"); } wc1.addWc(" (A.flgDispo > 0 OR B.flgDispo > 0 OR C.flgDispo > 0) "); PreparedStatement stmt = getConn().prepareStatement("(" + sql + wc.toString() + s_Sql_GrouBy + s_Sql_Having + ") union (" + s_Sql_Find1 + wc1.toString() + s_Sql_Order + ")"); return findRows(stmt, pageNumber, 50); } catch (SQLException e) { handleDebug(e); e.printStackTrace(); return AB_EMPTY_VECTUMERATOR; } } public void resetCalcoloQuantita() { if (getId_articolo() > 0L) { update("update ARTICOLO set quantitaCalcolate=false where id_articolo=" + getId_articolo()); setQuantitaCalcolate(false); } } public ResParm resetFornitore(long l_id_fornitore) { ResParm rp = new ResParm(true); return rp; } public long getFlgWebNoVendita() { return this.flgWebNoVendita; } public void setFlgWebNoVendita(long flgWebNoVendita) { this.flgWebNoVendita = flgWebNoVendita; } public double getPriceWVat(long l_id_users) { if (l_id_users == 0L) return getPriceWVat(); Users user = new Users(getApFull()); user.findByPrimaryKey(l_id_users); if (user.getId_clifor() >= 0L) return getPrezzoPubblicoIva(user.getClifor()); return getPriceWVat(); } public double getPriceWVat(Users l_user) { return getPriceWVat(l_user.getId_users()); } public Listino getListinoBase() { if (this.listinoBase == null && getApFull() != null) this.listinoBase = Listino.dammiListinoBase(getApFull()); return this.listinoBase; } public void setListinoBase(Listino listinoBase) { this.listinoBase = listinoBase; } public void setListinoArticoloBase(ListinoArticolo listinoArticoloBase) { this.listinoArticoloBase = listinoArticoloBase; } public Date getImportListinoDataCambiamentoPrezzo() { return this.dataCambiamentoPrezzo; } public double getPrezzoBase() { return getListinoArticoloBase().getPrezzoLA(); } public double getPrezzoBaseIva() { return DBAdapter.conIva(getListinoArticoloBase().getPrezzoLA(), (double)getIva().getAliquota()); } public double getPrezzoBaseIva(Users user) { if (user.getId_clifor() == 0L) return DBAdapter.conIva(getListinoArticoloBase().getPrezzoLA(), (double)getIva().getAliquota()); if (user.getClifor().isPrezzoWebEsente()) return DBAdapter.conIva(getListinoArticoloBase().getPrezzoLA(), getIvaAliquota(user.getClifor())); return DBAdapter.conIva(getListinoArticoloBase().getPrezzoLA(), (double)getIva().getAliquota()); } public boolean isOffertaValida() { if (getListinoArticoloBase().isOffertaValida()) return true; return isOffertaFornitoreValida(); } public boolean isOffertaFornitoreValida() { if (getListinoArticoloBase().isOffertaValida()) return false; if (getId_fornitoreCostoNuovo() > 0L && getDataScadenzaOffertaFornitore() != null && DBAdapter.getDateDiff(getToday(), getDataScadenzaOffertaFornitore()) >= 0L) return true; return false; } public String getDescrizioneOffertaAdmin() { if (isOffertaFornitoreValida()) return "Offerta FORNITORE " + getFornitoreCostoNuovo().getCognomeNome() + " valida fino al " + getDataFormat().format(getDataScadenzaOffertaFornitore()); if (isOffertaValida()) return "Offerta valida fino al " + getDataFormat().format(getDataScadenzaOfferta()) + " (" + getNf().format(getPrezzoBaseIva()) + ")"; return ""; } public double getPrezzoOfferta() { return getListinoArticoloBase().getPrezzoOffertaLA(); } public double getPercScontoOfferta() { return getListinoArticoloBase().getPercScontoOffertaLA(); } public double getPrezzoOffertaIva() { return DBAdapter.conIva(getListinoArticoloBase().getPrezzoOffertaLA(), (double)getIva().getAliquota()); } public ListinoArticolo getListinoArticoloBase() { if ((this.listinoArticoloBase == null || this.listinoArticoloBase.getId_listinoArticolo() == 0L) && getApFull() != null && getId_articolo() != 0L) { this.listinoArticoloBase = new ListinoArticolo(getApFull()); this.listinoArticoloBase.findByArticoloListino(getId_articolo(), getListinoBase().getId_listino()); } return (this.listinoArticoloBase == null) ? new ListinoArticolo(getApFull()) : this.listinoArticoloBase; } public PrezzoArticolo getPrezzoArticolo(Clifor clifor) { if (this.prezzoArticolo != null && clifor != null && this.prezzoArticolo.getId_clifor() != clifor.getId_clifor()) { this.prezzoArticolo = null; this.prezzoArticoloIva = null; } if (this.prezzoArticolo == null && getId_articolo() > 0L && getId_articoloVariante() > 0L) { if (clifor != null && clifor.getListino().getId_listino() > 0L) { this.prezzoArticolo = clifor.getListino().getPrezzo(getArticoloVariante()); this.prezzoArticolo.setId_clifor(clifor.getId_clifor()); } else { this.prezzoArticolo = getListinoBase().getPrezzo(getArticoloVariante()); } } else if (this.prezzoArticolo == null && getId_articolo() > 0L) { if (clifor != null && clifor.getListino().getId_listino() > 0L) { this.prezzoArticolo = clifor.getListino().getPrezzo(this); this.prezzoArticolo.setId_clifor(clifor.getId_clifor()); } else { this.prezzoArticolo = getListinoBase().getPrezzo(this); } } return (this.prezzoArticolo == null) ? new PrezzoArticolo() : this.prezzoArticolo; } public double getPrezzoMinimoPaypal() { double tariffaFissa = 0.35D; double percPaypal = 0.034D; if (getTipo().getEbayFissa() > 0.0D) tariffaFissa = getTipo().getEbayFissa(); if (getTipo().getEbayCommissione() > 0.0D) percPaypal = getTipo().getEbayCommissione() / 100.0D; DoubleOperator dop = new DoubleOperator(getCostoNetto()); dop.setScale(4, 5); dop.add(tariffaFissa); DoubleOperator perc = new DoubleOperator(1.0F); perc.subtract(percPaypal); dop.divide(perc); return dop.getResult(); } public double getPrezzoMinimoPaypalIva() { return conIva(getPrezzoMinimoPaypal(), (double)getIva().getAliquota()); } public double getPrezzoMinimoPaypalEbay() { double tariffaFissa = 0.35D; double percPaypal = 0.034D; double percEbay = 0.043D; DoubleOperator dop = new DoubleOperator(getCostoNetto()); dop.add(tariffaFissa); DoubleOperator perc = new DoubleOperator(1.0F); perc.subtract(percPaypal); perc.subtract(percEbay); dop.divide(perc); return dop.getResult(); } public double getPrezzoMinimoAmazonIva() { return conIva(getPrezzoMinimoAmazon(), (double)getIva().getAliquota()); } public PrezzoArticolo getPrezzoArticoloEbay() { if (getId_listinoEbay() == 0L) return getListinoBase().getPrezzoBaseLA(this); return getListinoEbay().getPrezzo(this); } public PrezzoArticolo getPrezzoArticoloEbayIva() { if (getId_listinoEbay() == 0L) return getListinoBase().getPrezzoBaseIvaLA(this); return getListinoEbay().getPrezzoIva(this); } public void setPrezzoArticolo(PrezzoArticolo prezzoArticoloBase) { this.prezzoArticolo = prezzoArticoloBase; this.prezzoArticoloIva = null; } public PrezzoArticolo getPrezzoArticoloIvaOrig(Clifor clifor) { if (this.prezzoArticoloIva != null && clifor != null && this.prezzoArticoloIva.getId_clifor() != clifor.getId_clifor()) { this.prezzoArticolo = null; this.prezzoArticoloIva = null; } if (this.prezzoArticoloIva == null && getId_articolo() > 0L) if (clifor != null && clifor.getListino().getId_listino() > 0L) { this.prezzoArticoloIva = clifor.getListino().getPrezzoIva(this); this.prezzoArticoloIva.setId_clifor(clifor.getId_clifor()); } else { this.prezzoArticoloIva = getListinoBase().getPrezzoIva(this); } return (this.prezzoArticoloIva == null) ? new PrezzoArticolo() : this.prezzoArticoloIva; } public void setPrezzoArticoloIva(PrezzoArticolo prezzoArticoloBaseIva) { this.prezzoArticoloIva = prezzoArticoloBaseIva; } public double getQuantita(Date data) { if (!usaMagazzino()) return 0.0D; if (getParm("USA_MAGAZZINO").isFalse()) { RigaDocumento rd = new RigaDocumento(getApFull()); rd.findMagDisponibilita(getId_articolo(), 0L, 0L, null, 1L, 0L, data); return rd.getQuantita(); } return this.quantita; } public double getQuantitaM(Date data) { if (!usaMagazzino()) return 0.0D; if (getParm("USA_MAGAZZINO").isFalse()) { Movimento mov = new Movimento(getApFull()); mov.findDisponibilita(getId_articolo(), 0L, 0L, null, 1L, 0L, data); return mov.getQuantita(); } return this.quantita; } public Vectumerator findUltimiModificatiRandom(long numArt, long numFetch) { StringBuilder s_Sql_Find = new StringBuilder("select A.* from ARTICOLO AS A inner join TIPO AS C ON C.id_tipo=A.id_tipo "); String s_Sql_Order = " order by A.lastUpdTmst desc,A.ordine desc, A.nome limit " + numFetch; WcString wc = new WcString(); wc.addWc("A.flgNascondi=0"); wc.addWc("C.flgNascondi=0"); wc.addWc("A.flgEscludiWeb=0"); wc.addWc("A.quantita>0"); try { PreparedStatement stmt = getConn().prepareStatement("select R.* FROM (" + String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order + ") as R ORDER BY rand() limit " + numArt); Vectumerator vec = findRows(stmt); return vec; } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public double getQuantita() { return getQuantita(null); } public boolean isQuantitaDataCalcolate() { return this.quantitaDataCalcolate; } public void setQuantitaDataCalcolate(boolean quantitaDataCalcolate) { this.quantitaDataCalcolate = quantitaDataCalcolate; } public void setQuantitaData(double quantitaData) { this.quantitaData = quantitaData; } public long getFlgArticoloComponente() { return this.flgArticoloComponente; } public void setFlgArticoloComponente(long flgComponente) { this.flgArticoloComponente = flgComponente; } public Vectumerator findArticoliVarianti(long flgDisponibili, long flgNascondi) { return new ArticoloVariante(getApFull()).findById_articolo(getId_articolo(), 0, 0, flgDisponibili, flgNascondi); } public String getImgFileName(int imgNumber) { return getImgFileName(imgNumber, getImgTmst()); } public String getDescrizioneNomeUrl() { if (!getNomeSeo().isEmpty()) return getNomeSeo().trim(); String temp = DBAdapter.eliminaDoppioniTokenInStringa(getMarca().getDescrizione() + " " + getMarca().getDescrizione(), " "); return temp.trim(); } public String getDescrizioneNomeCodiceUrl() { String temp = convertStringToLink((getNome() + " " + getNome()).trim()); return temp; } public Vectumerator findByCRSerMovimentoOLDCONTABELLAMOVIMENTO(ArticoloCR CR, int pageNumber, int pageRows) { try { Vectumerator vec = new Vectumerator(); String sql = "SELECT M.id_articolo as id_artmov, A.id_articolo, 0 as id_articoloTaglia, M.id_articoloVariante,M.id_clifor, M.seriale, SUM(kg) as kg, SUM(mt) as mt, SUM(nr) as nr, A.nome,A.id_marca,A.id_tipo,A.percSconto,A.id_iva,A.prezzoOfferta,A.prezzoPubblico,A.flgSerialiMassivi FROM MOVIMENTO AS M INNER JOIN ARTICOLO AS A ON A.id_articolo=M.id_articolo "; String s_Sql_GrouBy = " group by M.id_articolo, M.id_clifor, M.seriale "; String s_Sql_Having = " HAVING ( nr>0 and A.id_articolo>0 and M.seriale is not null) "; WcString wc = new WcString(); if (!CR.getSearchTxt().trim().isEmpty()) { String star = ""; String temp = CR.getSearchTxt().trim(); StringTokenizer st = new StringTokenizer(temp.trim(), " "); StringBuffer txt = new StringBuffer("("); while (st.hasMoreTokens()) { String token = star + star; token = prepareInputMySqlString(token, false); token = token.replace("*", "%"); txt.append("(A.codice like '%" + token + "%' or A.nome like '%" + token + "%' or M.seriale = '" + token + "'or A.codiciAlternativi like '%," + token + ",%' )"); if (st.hasMoreTokens()) { txt.append(" and "); star = "%"; } } txt.append(")"); wc.addWc(txt.toString()); } if (isDeleteLogic()) if (CR.getFlgShowDeleteLogic() == 0L) { wc.addWc("A.dataFineVld is null"); } else { wc.addWc("A.dataFineVld is not null"); } if (CR.getId_clifor() != 0L && CR.getMagFisico().getFlgTipo() != 1L) { wc.addWc("(M.id_clifor=" + CR.getId_clifor() + ")"); } else { wc.addWc("(M.id_clifor=0 or M.id_clifor is null )"); } wc.addWc(" M.id_magFisico=" + CR.getId_magFisico()); String s_Sql_Find1 = "select 0 as id_artmov, A.id_articolo, C.id_articoloTaglia, B.id_articoloVariante,0 as id_clifor,null as seriale,0 as kg, 0 as mt, 0 as nr, A.nome,A.id_marca,A.id_tipo,A.percSconto,A.id_iva,A.prezzoOfferta,A.prezzoPubblico,A.flgSerialiMassivi from ARTICOLO AS A inner join TIPO as T on A.id_tipo=T.id_tipo left JOIN ARTICOLO_VARIANTE AS B ON A.id_articolo = B.id_articolo LEFT JOIN ARTICOLO_TAGLIA as C on A.id_articolo=C.id_articolo and B.id_articoloVariante=C.id_articoloVariante"; String s_Sql_Order = " "; WcString wc1 = new WcString(); wc1.addWc("T.flgTipoMagazzino!=2"); if (!CR.getSearchTxt().trim().isEmpty()) { String star = ""; String temp = CR.getSearchTxt().trim(); StringTokenizer st = new StringTokenizer(temp.trim(), " "); StringBuffer txt = new StringBuffer("("); while (st.hasMoreTokens()) { String token = star + star; token = prepareInputMySqlString(token, false); token = token.replace("*", "%"); txt.append("(A.codice like '%" + token + "%' or A.nome like '%" + token + "%' or C.codiceAT = '" + token + "'or A.codiciAlternativi like '%," + token + ",%' or B.nomeV like '%" + token + "%')"); if (st.hasMoreTokens()) { txt.append(" and "); star = "%"; } } txt.append(")"); wc1.addWc(txt.toString()); } if (isDeleteLogic()) if (CR.getFlgShowDeleteLogic() == 0L) { wc1.addWc("A.dataFineVld is null"); } else { wc1.addWc("A.dataFineVld is not null"); } wc1.addWc(" (A.flgDispo > 0 OR B.flgDispo > 0 OR C.flgDispo > 0) "); PreparedStatement stmt = getConn().prepareStatement("(" + sql + wc.toString() + s_Sql_GrouBy + s_Sql_Having + ") union (" + s_Sql_Find1 + wc1.toString() + s_Sql_Order + ")"); return findRows(stmt, pageNumber, 50); } catch (SQLException e) { handleDebug(e); e.printStackTrace(); return AB_EMPTY_VECTUMERATOR; } } public Vectumerator findByCR(ArticoloCR CR, int pageNumber, int pageRows) { String s_Sql_Order; if (CR.getFlgTipoRicerca() == 1L) return findByCRSerMagazzino(CR, pageNumber, pageRows); if (CR.getFlgTipoRicerca() == 2L) return findByCRAv(CR, pageNumber, pageRows); if (CR.getFlgTipoRicerca() == 10L) return findWebByArticoloCR(CR, pageNumber, pageRows); if (CR.getFlgTipoRicerca() == 11L) return findWebByArticoloVarianteCR(CR, pageNumber, pageRows); if (CR.getDataMovimento() != null) return findByCRMovimento(CR, pageNumber, pageRows); boolean flgOttimizzo = true; if (pageNumber == 0 && pageRows == 0) flgOttimizzo = false; StringBuffer s_Sql_Find = new StringBuffer("select A.* from ARTICOLO AS A "); if (CR.getFlgOrderBy() == 99L) { s_Sql_Order = " order by rand()"; } else { String orderBy = " order by "; if (CR.getFlgOrdinaWww() == 1L) orderBy = orderBy + "A.ordine desc, "; s_Sql_Order = orderBy + "A.nome"; if (!CR.getFlgReport().isEmpty()) { s_Sql_Order = orderBy + "C.descrizioneCompleta,C.descrizione, A.nome"; } else if (CR.getFlgOrderBy() == 0L) { s_Sql_Order = orderBy + "A.nome " + orderBy; } else if (CR.getFlgOrderBy() == 1L) { s_Sql_Order = orderBy + "M.descrizione " + orderBy + ", A.codice, A.nome " + CR.getFlgOrderType(); } else if (CR.getFlgOrderBy() == 2L) { s_Sql_Order = orderBy + "C.descrizioneR , A.nome "; } else if (CR.getFlgOrderBy() == 3L) { s_Sql_Order = orderBy + "C.descrizioneR desc , A.nome desc"; } else if (CR.getFlgOrderBy() == 4L) { s_Sql_Order = orderBy + "A.prezzoPubblico , C.descrizione , A.nome"; } else if (CR.getFlgOrderBy() == 5L) { s_Sql_Order = orderBy + " A.prezzoPubblico desc , C.descrizione ,A.nome"; } else if (CR.getFlgOrderBy() == 7L) { s_Sql_Order = orderBy + "A.quantita desc, C.descrizioneR , A.nome "; } else if (CR.getFlgOrderBy() == 8L) { s_Sql_Order = orderBy + " A.tmstLastImpression desc, A.impression desc, A.nome asc "; } else if (CR.getFlgOrderBy() == 9L) { s_Sql_Order = orderBy + " A.impression desc, A.nome asc "; } else if (CR.getFlgOrderBy() == 10L) { s_Sql_Order = orderBy + " A.quantita desc "; } } WcString wc = new WcString(); findByCRCreateWC(CR, s_Sql_Find, wc); try { PreparedStatement stmt; if ((pageNumber == 0 && pageRows == 0) || !flgOttimizzo) { stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find) + wc.toString()); } else { if (pageNumber == 0) pageNumber = 1; int start = (pageNumber - 1) * pageRows; int stop = start + pageRows; stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find) + wc.toString() + " limit " + s_Sql_Order + "," + start); } findByCRCreateStmtDate(CR, stmt); if ((pageNumber == 0 && pageRows == 0) || !flgOttimizzo) { Vectumerator vectumerator = findRows(stmt, pageNumber, pageRows); if (!CR.getFlgReport().isEmpty()); return vectumerator; } Vectumerator vec = findRows(stmt, 1, pageRows); vec.setPageNumber(pageNumber); vec.setTotNumberOfRecords(findByCRTotRecord(CR)); return vec; } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public Vectumerator findByCRSerMovimento(ArticoloCR CR, int pageNumber, int pageRows) { try { Vectumerator vec = new Vectumerator(); String sql = "SELECT M.id_articolo as id_artmov, A.id_articolo, 0 as id_articoloTaglia, M.id_articoloVariante,M.id_clifor, M.seriale, SUM(kg) as kg, SUM(mt) as mt, SUM(nr) as nr, A.nome,A.id_marca,A.id_tipo,A.percSconto,A.id_iva,A.prezzoOfferta,A.prezzoPubblico,A.flgSerialiMassivi FROM MOVIMENTO AS M INNER JOIN ARTICOLO AS A ON A.id_articolo=M.id_articolo "; String s_Sql_GrouBy = " group by M.id_articolo, M.id_clifor, M.seriale "; String s_Sql_Having = " HAVING ( nr>0 and A.id_articolo>0 and M.seriale is not null) "; WcString wc = new WcString(); if (!CR.getSearchTxt().trim().isEmpty()) { String star = ""; String temp = CR.getSearchTxt().trim(); StringTokenizer st = new StringTokenizer(temp.trim(), " "); StringBuffer txt = new StringBuffer("("); while (st.hasMoreTokens()) { String token = star + star; token = prepareInputMySqlString(token, false); token = token.replace("*", "%"); txt.append("(A.codice like '%" + token + "%' or A.nome like '%" + token + "%' or M.seriale = '" + token + "'or A.codiciAlternativi like '%," + token + ",%' )"); if (st.hasMoreTokens()) { txt.append(" and "); star = "%"; } } txt.append(")"); wc.addWc(txt.toString()); } if (isDeleteLogic()) if (CR.getFlgShowDeleteLogic() == 0L) { wc.addWc("A.dataFineVld is null"); } else { wc.addWc("A.dataFineVld is not null"); } if (CR.getId_clifor() != 0L && CR.getMagFisico().getFlgTipo() != 1L) { wc.addWc("(M.id_clifor=" + CR.getId_clifor() + ")"); } else { wc.addWc("(M.id_clifor=0 or M.id_clifor is null )"); } wc.addWc(" M.id_magFisico=" + CR.getId_magFisico()); String s_Sql_Find1 = "select 0 as id_artmov, A.id_articolo, C.id_articoloTaglia, B.id_articoloVariante,0 as id_clifor,null as seriale,0 as kg, 0 as mt, 0 as nr, A.nome,A.id_marca,A.id_tipo,A.percSconto,A.id_iva,A.prezzoOfferta,A.prezzoPubblico,A.flgSerialiMassivi from ARTICOLO AS A inner join TIPO as T on A.id_tipo=T.id_tipo left JOIN ARTICOLO_VARIANTE AS B ON A.id_articolo = B.id_articolo LEFT JOIN ARTICOLO_TAGLIA as C on A.id_articolo=C.id_articolo and B.id_articoloVariante=C.id_articoloVariante"; String s_Sql_Order = " "; WcString wc1 = new WcString(); wc1.addWc("T.flgTipoMagazzino!=2"); if (!CR.getSearchTxt().trim().isEmpty()) { String star = ""; String temp = CR.getSearchTxt().trim(); StringTokenizer st = new StringTokenizer(temp.trim(), " "); StringBuffer txt = new StringBuffer("("); while (st.hasMoreTokens()) { String token = star + star; token = prepareInputMySqlString(token, false); token = token.replace("*", "%"); txt.append("(A.codice like '%" + token + "%' or A.nome like '%" + token + "%' or C.codiceAT = '" + token + "'or A.codiciAlternativi like '%," + token + ",%' or B.nomeV like '%" + token + "%')"); if (st.hasMoreTokens()) { txt.append(" and "); star = "%"; } } txt.append(")"); wc1.addWc(txt.toString()); } if (isDeleteLogic()) if (CR.getFlgShowDeleteLogic() == 0L) { wc1.addWc("A.dataFineVld is null"); } else { wc1.addWc("A.dataFineVld is not null"); } wc1.addWc(" (A.flgDispo > 0 OR B.flgDispo > 0 OR C.flgDispo > 0) "); PreparedStatement stmt = getConn().prepareStatement("(" + sql + wc.toString() + s_Sql_GrouBy + s_Sql_Having + ") union (" + s_Sql_Find1 + wc1.toString() + s_Sql_Order + ")"); return findRows(stmt, pageNumber, 50); } catch (SQLException e) { handleDebug(e); e.printStackTrace(); return AB_EMPTY_VECTUMERATOR; } } public Vectumerator findByCRMovimento(ArticoloCR CR, int pageNumber, int pageRows) { boolean flgOttimizzo = false; if (pageNumber == 0 && pageRows == 0) flgOttimizzo = false; StringBuffer s_Sql_Find = new StringBuffer("SELECT A.* , SUM(M.kg) as kg, SUM(M.mt) as mt, SUM(M.nr) as nr FROM MOVIMENTO AS M INNER JOIN ARTICOLO AS A ON A.id_articolo=M.id_articolo "); String s_Sql_GrouBy = " group by M.id_articolo"; WcString s_sql_havinng = new WcString(); String s_Sql_Order = " order by A.nome"; if (!CR.getFlgReport().isEmpty()) { s_Sql_Order = " order by C.descrizioneCompleta,C.descrizione, A.nome"; } else if (CR.getFlgOrderBy() == 0L) { s_Sql_Order = " order by A.nome " + CR.getFlgOrderType(); } else if (CR.getFlgOrderBy() == 1L) { s_Sql_Order = " order by M.descrizione " + CR.getFlgOrderType() + ", A.codice, A.nome " + CR.getFlgOrderType(); } else if (CR.getFlgOrderBy() == 2L) { s_Sql_Order = " order by C.descrizione , A.nome "; } else if (CR.getFlgOrderBy() == 3L) { s_Sql_Order = " order by C.descrizione desc , A.nome desc"; } else if (CR.getFlgOrderBy() == 4L) { s_Sql_Order = " order by A.prezzoPubblico , C.descrizione , A.nome"; } else if (CR.getFlgOrderBy() == 5L) { s_Sql_Order = " order by A.prezzoPubblico desc , C.descrizione ,A.nome"; } WcString wc = new WcString(); findByCRCreateWC(CR, s_Sql_Find, wc); if (CR.getDataMovimento() != null) { s_Sql_Find.append(" inner join RIGA_DOCUMENTO AS RD ON M.id_rigaDocumento=RD.id_rigaDocumento inner join DOCUMENTO as DOC on RD.id_documento=DOC.id_documento"); wc.addWc("DOC.dataDocumento<=?"); } if (CR.getFlgQta() == 1L) if (CR.getQtaDa() == 0L) { s_sql_havinng.addHavingWc("nr<=" + CR.getQtaA()); } else { s_sql_havinng.addHavingWc("nr<=" + CR.getQtaA()); s_sql_havinng.addHavingWc("nr>=" + CR.getQtaDa()); } try { PreparedStatement stmt; if ((pageNumber == 0 && pageRows == 0) || !flgOttimizzo) { stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_GrouBy + s_sql_havinng.toString()); } else { if (pageNumber == 0) pageNumber = 1; int start = (pageNumber - 1) * pageRows; int stop = start + pageRows; stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_GrouBy + s_sql_havinng.toString() + " limit " + s_Sql_Order + "," + start); } findByCRCreateStmtDate(CR, stmt); if ((pageNumber == 0 && pageRows == 0) || !flgOttimizzo) { Vectumerator vectumerator = findRows(stmt, pageNumber, pageRows); if (!CR.getFlgReport().isEmpty()); return vectumerator; } Vectumerator vec = findRows(stmt, 1, pageRows); vec.setPageNumber(pageNumber); vec.setTotNumberOfRecords(findByCRTotRecord(CR)); return vec; } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public double getPrezzoBaseIvaConAbbuono() { return getListinoArticoloBase().getPrezzoIvaAbbuonoLA(); } public int addLabelUnArticoloA4Pdf(String titolo, int nRow, long numberOflabel, String l_descrizione, long l_id_articoloVariante) { long pHMarg = 2L; long l_indent = 4L; long totLen = 40L; String l_descrizioneTipo = ""; float labelHeight = (PageSize.A4.getHeight() - (float)pHMarg) / (float)nRow; if (getFlgStampaEtichetteT() == 1L) { int totNumbOflabel = 0; try { int altezzaCod = 50; int larghezzaCod = 120; PdfContentByte cb = this.writer.getDirectContent(); Barcode128 codeBar = new Barcode128(); codeBar.setCodeType(9); if (getFlgUsaVarianti() == 0L || (getFlgUsaVarianti() == -1L && getTipo().getFlgUsaVarianti() == 0L)) { if (l_descrizione == null || l_descrizione.isEmpty()) l_descrizione = getDescrizioneCompleta().replace("€", "€"); l_descrizioneTipo = getTipo().getDescrizioneCompletaLabel().toLowerCase(); for (int i = 0; (long)i < numberOflabel; i++) { totNumbOflabel++; PdfPCell cell = new PdfPCell(); cell.setBorder(0); codeBar.setCode(getCodice()); Image imgBarcode = codeBar.createImageWithBarcode(cb, null, null); imgBarcode.scaleToFit((float)larghezzaCod, (float)altezzaCod); cell.addElement(new Chunk(imgBarcode, 10.0F, (float)(-altezzaCod + 15))); if ((long)l_descrizione.length() < totLen) { cell.addElement(new Chunk("\n\n\n" + spaceLeft("", (int)(totLen - (long)l_descrizione.length())) + l_descrizione, PdfFontFactory.PDF_fPiccolissimo)); } else { cell.addElement(new Chunk("\n\n\n" + l_descrizione, PdfFontFactory.PDF_fPiccolissimo)); } if ((long)l_descrizioneTipo.length() < totLen) { cell.addElement(new Chunk(spaceLeft("", (int)(totLen - (long)l_descrizioneTipo.length())) + spaceLeft("", (int)(totLen - (long)l_descrizioneTipo.length())), PdfFontFactory.PDF_fPiccolissimo)); } else { cell.addElement(new Chunk(l_descrizioneTipo, PdfFontFactory.PDF_fPiccolissimo)); } cell.setVerticalAlignment(4); cell.setFixedHeight(labelHeight); cell.setIndent((float)l_indent); this.pdfPcorpo.addCell(cell); } } else { Vectumerator varianti = findArticoliVarianti(-1L, -1L); while (varianti.hasMoreElements()) { ArticoloVariante rowAv = (ArticoloVariante)varianti.nextElement(); if (l_id_articoloVariante == 0L || rowAv.getId_articoloVariante() == l_id_articoloVariante) { l_descrizione = rowAv.getDescrizioneCompletaSenzaCodice(); l_descrizioneTipo = rowAv.getArticolo().getTipo().getDescrizioneCompletaLabel().toLowerCase(); for (int i = 0; (long)i < numberOflabel; i++) { totNumbOflabel++; PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(4); cell.setFixedHeight(labelHeight); cell.setBorder(0); codeBar.setCode(rowAv.getCodiceVariante()); Image imgBarcode = codeBar.createImageWithBarcode(cb, null, null); imgBarcode.scaleToFit((float)larghezzaCod, (float)altezzaCod); cell.addElement(new Chunk(imgBarcode, 10.0F, (float)(-altezzaCod + 15))); if ((long)l_descrizione.length() < totLen) { cell.addElement(new Chunk("\n\n\n" + spaceLeft("", (int)(totLen - (long)l_descrizione.length())) + l_descrizione, PdfFontFactory.PDF_fPiccolissimo)); } else { cell.addElement(new Chunk("\n\n\n" + l_descrizione, PdfFontFactory.PDF_fPiccolissimo)); } if ((long)l_descrizioneTipo.length() < totLen) { cell.addElement(new Chunk( spaceLeft("", (int)(totLen - (long)l_descrizioneTipo.length())) + spaceLeft("", (int)(totLen - (long)l_descrizioneTipo.length())), PdfFontFactory.PDF_fPiccolissimo)); } else { cell.addElement(new Chunk(l_descrizioneTipo, PdfFontFactory.PDF_fPiccolissimo)); } cell.setIndent((float)l_indent); this.pdfPcorpo.addCell(cell); } } } } } catch (Exception e) { e.printStackTrace(); } return totNumbOflabel; } return 0; } public String getDescrizioneCompleta(String lang) { if (lang == null || lang.isEmpty()) lang = "it"; StringBuilder sb = new StringBuilder(); if (getParm("DOC_ARTICOLI_CON_CODICE").isTrue()) { if (getId_articoloVariante() == 0L) { sb.append(getCodice() + " " + getCodice()); } else { sb.append(getArticoloVariante().getCodiceVariante() + " " + getArticoloVariante().getCodiceVariante()); } } else { sb.append(getDescrizioneCompletaSenzaCodice(lang)); } if (getParm("DOC_ARTICOLI_CON_TIPO").isTrue() && getTipo() != null) { sb.append(" "); sb.append(getTipo().getDescrizione()); } return sb.toString(); } public long getId_tipo2() { return this.id_tipo2; } public void setId_tipo2(long id_tipo2) { this.id_tipo2 = id_tipo2; setTipo2(null); } public Tipo getTipo2() { this.tipo2 = (Tipo)getSecondaryObject(this.tipo2, Tipo.class, getId_tipo2()); return this.tipo2; } public void setTipo2(Tipo tipo2) { this.tipo2 = tipo2; } public ByteArrayOutputStream creaCatalogoPdf(ArticoloCR CR) { boolean debug = false; String debugInfo = "Articolo.creaCatalogoPdf "; NumberFormat nf3 = NumberFormat.getInstance(); float[] colWidthsRighe4 = { 25.0F, 25.0F, 25.0F, 25.0F }; nf3.setMaximumFractionDigits(3); nf3.setMinimumFractionDigits(3); NumberFormat nf0 = NumberFormat.getInstance(); nf0.setMaximumFractionDigits(0); nf0.setMinimumFractionDigits(0); boolean noImg = false; int scaledImgWidth = (int)CR.getRisoluzioneImmaginiCatalogo(); int scaledImgFit = 82; int imagePosY = -66; String crImgDesc = "\n\n\n\n"; int colspanDesc = 15, colspanImmagini = 25; ByteArrayOutputStream ba = new ByteArrayOutputStream(); String titoloReport = ""; try { String imgTmpPdfTargetDir = getDocBase() + getDocBase() + "_pdf/"; if (!new File(imgTmpPdfTargetDir).exists()) new File(imgTmpPdfTargetDir).mkdirs(); this.document = new Document(PageSize.A4, 20.0F, 20.0F, 10.0F, 10.0F); titoloReport = "Catalogo Prodotti"; SimpleDateFormat tf = new SimpleDateFormat("HH:mm:ss"); Date today = getToday(); titoloReport = titoloReport + ". Stampato il " + titoloReport + " " + getDataFormat().format(today); this.writer = PdfWriter.getInstance(this.document, ba); Phrase pH = new Phrase(titoloReport + " - Pag. n. "); HeaderFooter header = new HeaderFooter(pH, true); header.setAlignment(2); header.setBorder(0); this.document.setHeader(header); this.document.open(); creaIntestazioneReportPdfPTable(titoloReport, CR.getDescrizioneCR()); int colDescArticolo = 30, colDescArticoloConVarianti = 40; CR.setFlgOrderBy(2L); Vectumerator vec = findByCR(CR, 0, 0); long currentTipo = -1L; while (vec.hasMoreElements()) { String imgFileNameScaledPdf; Articolo rowArticolo = (Articolo)vec.nextElement(); if (debug) System.out.println(debugInfo + debugInfo + " " + rowArticolo.getNome()); if (currentTipo != rowArticolo.getId_tipo()) { PdfPCell pdfPCell = new PdfPCell(); pdfPCell.addElement(new Chunk(rowArticolo.getTipo().getDescrizioneRPdf(), PdfFontFactory.PDF_fGrandeB)); pdfPCell.setVerticalAlignment(4); pdfPCell.setHorizontalAlignment(0); pdfPCell.setBackgroundColor(Color.lightGray); pdfPCell.setBorderColor(Color.GRAY); pdfPCell.setColspan(colDescArticoloConVarianti); this.pdfPcorpo.addCell(pdfPCell); currentTipo = rowArticolo.getId_tipo(); } if (rowArticolo.getFlgUsaVarianti() == 1L) { PdfPCell pdfPCell = new PdfPCell(); Paragraph paragraph = new Paragraph(); paragraph.add(new Chunk(rowArticolo.getNome(), PdfFontFactory.PDF_fGrandeB)); paragraph.add(new Chunk(" - ", PdfFontFactory.PDF_fGrandeB)); paragraph.add(new Chunk(rowArticolo.getCodice(), PdfFontFactory.PDF_fGrandeB)); paragraph.add(new Chunk("\n" + rowArticolo.getDescrizione(), PdfFontFactory.PDF_fMedio)); pdfPCell.addElement((Element)paragraph); pdfPCell.setVerticalAlignment(4); pdfPCell.setHorizontalAlignment(0); pdfPCell.setBorderColor(Color.GRAY); pdfPCell.setColspan(colspanDesc); this.pdfPcorpo.addCell(pdfPCell); pdfPCell = new PdfPCell(); ArticoloVarianteCR CRAV = new ArticoloVarianteCR(getApFull()); CRAV.setId_articolo(rowArticolo.getId_articolo()); CRAV.setFlgDisponibile(CR.getFlgDisponibile()); CRAV.setFlgEscludiWeb(CR.getFlgEscludiWeb()); CRAV.setFlgNascondi(CR.getFlgNascondi()); Vectumerator vecV = rowArticolo.findArticoliVarianti(-1L, 0L); PdfPTable pdfPTable = new PdfPTable(4); pdfPTable.setWidthPercentage(100.0F); pdfPTable.setWidths(colWidthsRighe4); int i = 0; while (vecV.hasMoreElements()) { ArticoloVariante rowAV = (ArticoloVariante)vecV.nextElement(); if (debug) System.out.println(debugInfo + debugInfo + " " + rowAV.getNomeV() + " " + rowAV.getCodiceVariante()); if (CR.getFlgQta() == 0L || (CR.getFlgQta() > 0L && rowAV.getQuantitaAv() >= (double)CR.getQtaDa() && rowAV.getQuantitaAv() <= (double)CR.getQtaA())) { String str1 = rowAV.getImgFileName(6); String str2 = getDocBase() + getDocBase() + "_var/" + getPathImg(); try { String str; if (!new File(str2).exists()) { str1 = rowAV.getImgFileName(1); str2 = getDocBase() + getDocBase() + "_var/" + getPathImg(); if (!new File(str2).exists()) { str1 = "images/no-img.jpg"; str2 = getDocBase() + getDocBase(); noImg = true; } else { noImg = false; } } if (noImg) { str = imgTmpPdfTargetDir + imgTmpPdfTargetDir; } else if (scaledImgWidth == 0) { str = str2; } else { str = imgTmpPdfTargetDir + imgTmpPdfTargetDir; if (!new File(str).exists()) ScaleImage.scaleImageToFile(str2, str, getPathTmpFull(), scaledImgWidth, 72); } if (!new File(str).exists()) { System.out.println(debugInfo + " ATTENZIONE! Non sono riuscito a gestire l'immagine " + debugInfo + " " + rowAV.getNomeV() + " " + rowAV.getCodiceVariante() + " oppure " + rowAV.getImgFileName(6)); str1 = "images/no-img.jpg"; str = getDocBase() + getDocBase(); } Image imgVariante = Image.getInstance(str); imgVariante.scaleToFit((float)scaledImgFit, 100.0F); imgVariante.setAlignment(5); PdfPCell pdfPCell1 = new PdfPCell(); pdfPCell1.addElement(new Chunk(imgVariante, 2.0F, (float)imagePosY)); pdfPCell1.addElement(new Chunk(crImgDesc + crImgDesc + " " + rowAV.getNomeV(), PdfFontFactory.PDF_fMedio)); pdfPCell1.setVerticalAlignment(4); pdfPCell1.setHorizontalAlignment(0); pdfPCell1.setBackgroundColor(Color.white); pdfPCell1.setBorderColor(Color.white); pdfPCell1.setColspan(1); i++; pdfPTable.addCell(pdfPCell1); } catch (Exception e) { e.printStackTrace(); str1 = "images/no-img.jpg"; String str = getDocBase() + getDocBase(); Image imgVariante = Image.getInstance(str); imgVariante.scaleToFit((float)scaledImgFit, 100.0F); imgVariante.setAlignment(5); PdfPCell pdfPCell1 = new PdfPCell(); pdfPCell1.addElement(new Chunk(imgVariante, 2.0F, (float)imagePosY)); pdfPCell1.addElement(new Chunk(crImgDesc + crImgDesc + " " + rowAV.getNomeV(), PdfFontFactory.PDF_fMedio)); pdfPCell1.setVerticalAlignment(4); pdfPCell1.setHorizontalAlignment(0); pdfPCell1.setBackgroundColor(Color.white); pdfPCell1.setBorderColor(Color.white); pdfPCell1.setColspan(1); i++; } } } if (i % 4 > 0) { PdfPCell pdfPCell1 = new PdfPCell(); pdfPCell1.setBorderColor(Color.white); for (int j = 0; j < 4 - i % 4; j++) pdfPTable.addCell(pdfPCell1); } pdfPCell.addElement((Element)pdfPTable); pdfPCell.setVerticalAlignment(4); pdfPCell.setHorizontalAlignment(0); pdfPCell.setBorderColor(Color.GRAY); pdfPCell.setColspan(colspanImmagini); this.pdfPcorpo.addCell(pdfPCell); continue; } PdfPCell cell = new PdfPCell(); Paragraph p = new Paragraph(); p.add(new Chunk(rowArticolo.getNome(), PdfFontFactory.PDF_fGrandeB)); p.add(new Chunk(" - ", PdfFontFactory.PDF_fGrandeB)); p.add(new Chunk(rowArticolo.getCodice(), PdfFontFactory.PDF_fGrandeB)); p.add(new Chunk("\n" + rowArticolo.getDescrizione(), PdfFontFactory.PDF_fMedio)); p.add(new Chunk("\nPrezzo: € ", PdfFontFactory.PDF_fMedio)); p.add(new Chunk(getNf().format(rowArticolo.getPrezzoPubblico()), PdfFontFactory.PDF_fMedio)); cell.addElement((Element)p); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setBorderColor(Color.GRAY); cell.setColspan(colspanDesc); this.pdfPcorpo.addCell(cell); cell = new PdfPCell(); PdfPTable corpoImmagini = new PdfPTable(4); corpoImmagini.setWidthPercentage(100.0F); corpoImmagini.setWidths(colWidthsRighe4); int numCell = 0; String imageName = rowArticolo.getImgFileName(6); String imageFileName = getDocBase() + getDocBase() + getPathImg(); if (!new File(imageFileName).exists()) { imageName = rowArticolo.getImgFileName(1); imageFileName = getDocBase() + getDocBase() + getPathImg(); if (!new File(imageFileName).exists()) { imageName = "images/no-img.jpg"; imageFileName = getDocBase() + getDocBase(); noImg = true; } else { noImg = false; } } if (noImg) { imgFileNameScaledPdf = imgTmpPdfTargetDir + imgTmpPdfTargetDir; } else if (scaledImgWidth == 0) { imgFileNameScaledPdf = imageFileName; } else { imgFileNameScaledPdf = imgTmpPdfTargetDir + imgTmpPdfTargetDir; if (!new File(imgFileNameScaledPdf).exists()) ScaleImage.scaleImageToFile(imageFileName, imgFileNameScaledPdf, getPathTmpFull(), scaledImgWidth, 72); } Image imgArticolo = Image.getInstance(imgFileNameScaledPdf); imgArticolo.scaleToFit((float)scaledImgFit, 100.0F); imgArticolo.setAlignment(5); PdfPCell cellImg = new PdfPCell(); cellImg.addElement(new Chunk(imgArticolo, 2.0F, (float)imagePosY)); cellImg.addElement(new Chunk(crImgDesc + crImgDesc + " " + rowArticolo.getNome(), PdfFontFactory.PDF_fMedio)); cellImg.setVerticalAlignment(4); cellImg.setHorizontalAlignment(0); cellImg.setBackgroundColor(Color.white); cellImg.setBorderColor(Color.white); cellImg.setColspan(1); numCell++; corpoImmagini.addCell(cellImg); if (numCell % 4 > 0) { cellImg = new PdfPCell(); cellImg.setBorderColor(Color.white); for (int i = 0; i < 4 - numCell % 4; i++) corpoImmagini.addCell(cellImg); } cell.addElement((Element)corpoImmagini); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setBorderColor(Color.gray); cell.setColspan(colspanImmagini); this.pdfPcorpo.addCell(cell); } this.document.add((Element)this.pdfPcorpo); this.document.close(); this.document = null; } catch (Exception e) { e.printStackTrace(); } return ba; } public double getQuantitaAjst() { if (getId_articoloTaglia() > 0L) return getArticoloTaglia().getQuantitaAt(); if (getId_articoloVariante() > 0L) return getArticoloVariante().getQuantitaAv(); return getQuantita(); } public String getQuantitaMagazzinoMovimentoHtmlAjst() { if (getId_articoloTaglia() > 0L) return getArticoloTaglia().getQuantitaMagazzinoMovimentoHtml(); if (getId_articoloVariante() > 0L) return getArticoloVariante().getQuantitaMagazzinoMovimentoHtml(); return getQuantitaMagazzinoMovimentoHtml(); } public double getVolumeM3() { return this.volumeM3; } public void setVolumeM3(double volumeM3) { this.volumeM3 = volumeM3; } public ResParm addArticoloUsato(ArticoloUsato row) { ResParm rp = new ResParm(true); ArticoloUsato bean = new ArticoloUsato(getApFull()); bean.setId_articolo(getId_articolo()); bean.setFlgTipoDocumento(1L); bean.setId_fornitore(row.getId_fornitore()); bean.setDataDocumento(row.getDataDocumento()); bean.setNumeroDocumento(row.getNumeroDocumento()); rp = bean.save(); if (rp.getStatus()) { bean.getArticolo().setQuantita(1.0D); handleQuantitaDebugBeforeSave("addArticoloUsato"); rp = bean.getArticolo().superSave(); } return rp; } public ResParm retrieveEbayItemId() { ResParm rp = new ResParm(true); if (getId_articolo() == 0L) { rp.setStatus(false); rp.setMsg("Articolo nullo"); } else { EbayAbliaApi eaa = new EbayAbliaApi(this.apFull); if (eaa.isTokenValid()) { EbayResult res = eaa.getSdkEbayItemIdBySku(getCodice()); if (res.isOk()) { setEbayItemId((String)res.getResult()); rp = superSave(); } else { rp.setStatus(false); rp.setMsg("Errore! " + res.getMsg()); } } else { rp.setStatus(false); rp.setMsg("Errore! Token ebay non valido o scaduto!"); } } return rp; } public void handleQuantitaDebugBeforeSave(String methodName) { boolean debug = false; if (getParm("USA_MAGAZZINO").isTrue() && debug) if (getQuantitaDB() != this.quantita) { StringBuilder sb = new StringBuilder(); sb.append(">>>>>>>>>>>>>>>>>>>>>>\n"); sb.append("it.acxent.art.Articolo DEBUG QUANTITA'"); sb.append("."); sb.append(methodName); sb.append("\nQuantita db: "); sb.append(getQuantitaDB()); sb.append("\nQuantita :"); sb.append(getQuantita()); sb.append("\n"); sb.append(this.apFull.getReqUrl()); sb.append("\n"); java.util.Date d = new java.util.Date(System.currentTimeMillis()); sb.append(d.toString()); sb.append("\nip: "); sb.append(this.apFull.getReqIpAddress()); sb.append("\n"); sb.append("\n<<<<<<<<<<<<"); System.out.println(sb.toString()); } } public ResParm delProgettista(ArticoloProgettista row) { ArticoloProgettista bean = new ArticoloProgettista(getApFull()); bean.findByPrimaryKey(row.getId_articoloProgettista()); return bean.delete(); } public ResParm delArticoloUsato(ArticoloUsato row) { ArticoloUsato bean = new ArticoloUsato(getApFull()); bean.findByPrimaryKey(row.getId_articoloUsato()); return bean.delete(); } public String getNome(String lang) { if (lang == null || lang.isEmpty()) lang = "it"; String temp = getDescTxtLang("nomeL", lang); if (temp.isEmpty()) return getNome(); return temp; } public String getDescrizioneCompleta() { if (getParm("DOC_ARTICOLI_CON_CODICE").isTrue()) { if (getId_articoloVariante() == 0L) return getCodice() + " " + getCodice(); return getArticoloVariante().getCodiceVariante() + " " + getArticoloVariante().getCodiceVariante(); } return getDescrizioneCompletaSenzaCodice(); } public String getDescrizioneCompletaSenzaCodice() { return getDescrizioneCompletaSenzaCodice(null); } public String getHtmlTableDispoMagInterni() { MagFisico mf = new MagFisico(getApFull()); RigaDocumento rd = new RigaDocumento(getApFull()); Vectumerator vec = mf.findByTipo(1L); StringBuilder sb = new StringBuilder(); while (vec.hasMoreElements()) { MagFisico row = (MagFisico)vec.nextElement(); sb.append("
"); rd.findMagDisponibilitaPuntuale(getId_articolo(), 0L, 0L, null, row.getId_magFisico(), 0L, 0L); sb.append(getNf().format(rd.getQuantita())); sb.append(""; String TDAP_WARN = ""; String TDAP_bold = ""; String TDAP_CENTER = ""; String TDCH = "
"); sb.append(row.getCodice()); sb.append("
"); sb.append(row.getCodice()); sb.append(""); sb.append("
"); if (row.getFlgAmazon() == 1L) { sb.append("V"); } else { sb.append(" "); } sb.append("
" + row.getLinkAmazon()); sb.append("
"); if (row.getFlgGoogle() == 1L) { sb.append("V"); if (!row.getGoogleFeedFileName().isEmpty()) { sb.append(" "); sb.append(row.getGoogleFeedFileName()); } } else { sb.append(" "); } sb.append(""); sb.append(row.getCodiciAlternativiLink()); sb.append(" "); sb.append(row.getCodiceEan()); sb.append(""); sb.append(row.getTipo().getDescrizioneCompleta() + " - " + row.getTipo().getDescrizioneCompleta()); sb.append("
-----------------------
"); sb.append(row.getDescAmz()); sb.append("
"); sb.append(nf.format(row.getPrezzoPubblicoIva())); sb.append(""); sb.append(row.getAmzPrezziDescInline()); sb.append(""); sb.append(nf.format(row.getStreetPriceIva())); sb.append(""); sb.append(nf.format(row.getRicaricoEffettivoDaCostoNetto())); sb.append(""); sb.append(nf.format(row.getQuantita())); sb.append(""); sb.append(nf.format(row.getQtaSuAmz())); sb.append(""); sb.append(row.getEscludiWeb()); sb.append(""); } else { sb.append(""); } sb.append(notes); sb.append("
"); mm.setString("listaArticoli", sb.toString()); String from = apFull.getParm("FROM").getTesto(); MailProperties mp = new MailProperties(); mp.setProperty("FROM", from); mp.setProperty("TO", from); mp.setProperty("SUBJECT", oggettoMessaggio); System.out.println("sendArticoliCambiatiByEmail: from: " + from + " to " + from + " oggetto: " + oggettoMessaggio); rp = mm.sendMailMessage(mp, true); return rp; } public final ResParm sendEbayUpdateResultByEmail(ApplParmFull apFull, Vectumerator vec, String msg) { ResParm rp = new ResParm(); String TDAP = ""; String TDAP_bold = ""; String TDAP_CENTER = ""; String TDCH = ""; String fileName = apFull.getParm("DOCBASE").getTesto() + "admin/art/_mailMessage/ebayUpdate.html"; MailMessage mm = new MailMessage(apFull, fileName); NumberFormat nf = apFull.getNf(); Articolo articolo = new Articolo(apFull); ArticoloCR CR = new ArticoloCR(); StringBuilder sb = new StringBuilder(); mm.setDate("data", DBAdapter.getToday()); mm.setString("risultato", msg); String oggettoMessaggio = "Ebay Update " + String.valueOf(DBAdapter.getToday()) + " " + String.valueOf(DBAdapter.getNow()); while (vec.hasMoreElements()) { Articolo row = (Articolo)vec.nextElement(); String notes = row.getBeanNotes() + "
" + row.getBeanNotes() + " q." + nf.format(row.getPrezzoArticoloEbayIva().getPrezzoFinale()) + "(" + nf.format(row.getQtaSuEbay()) + ")"; sb.append(""); sb.append(""); sb.append(row.getCodice()); sb.append("
"); sb.append(row.getCodice()); sb.append(""); sb.append(""); sb.append(""); if (row.getFlgSubito() == 1L) { sb.append("V"); } else { sb.append(" "); } sb.append(""); sb.append(""); if (row.getFlgEbay() == 1L) { sb.append("V"); } else { sb.append(" "); } if (!row.getEbayOfferId().isEmpty()) sb.append("
" + row.getEbayOfferId()); sb.append(""); sb.append(""); if (row.getFlgGoogle() == 1L) { sb.append("V"); if (!row.getGoogleFeedFileName().isEmpty()) { sb.append(" "); sb.append(row.getGoogleFeedFileName()); } } else { sb.append(" "); } sb.append(""); sb.append(""); sb.append(row.getCodiciAlternativiLink()); sb.append(" "); sb.append(row.getCodiceEan()); sb.append(""); sb.append(""); sb.append(row.getTipo().getDescrizioneCompleta() + " - " + row.getTipo().getDescrizioneCompleta()); sb.append(""); sb.append(""); sb.append(nf.format(row.getPrezzoPubblicoIva())); sb.append(""); sb.append(""); sb.append(nf.format(row.getPrezzoArticoloEbayIva().getPrezzoFinale())); sb.append(""); sb.append(""); sb.append(nf.format(row.getStreetPriceIva())); sb.append(""); sb.append(""); sb.append(nf.format(row.getRicaricoEffettivoDaCostoNetto())); sb.append(""); sb.append(""); sb.append(nf.format(row.getQuantita())); sb.append(""); sb.append(""); sb.append(nf.format(row.getQtaSuEbay())); sb.append(""); sb.append(""); sb.append(row.getEscludiWeb()); sb.append(""); sb.append(""); sb.append(notes); sb.append(""); sb.append(""); sb.append("\n"); } sb.append(""); mm.setString("listaArticoli", sb.toString()); String from = apFull.getParm("FROM").getTesto(); MailProperties mp = new MailProperties(); mp.setProperty("FROM", from); mp.setProperty("TO", from); mp.setProperty("SUBJECT", oggettoMessaggio); System.out.println("sendArticoliCambiatiByEmail: from: " + from + " to " + from + " oggetto: " + oggettoMessaggio); rp = mm.sendMailMessage(mp, true); return rp; } public static final ResParm updateArticoloNonTrovati(ApplParmFull apFull, String TAG_THREAD_MSG, long l_id_fornitore, HashSet hsMarche, HashSet hsTipi) { boolean debug = false; ResParm rp = new ResParm(); StringBuilder err = new StringBuilder(); int i = 0; int se1 = 10; int se2 = 100; int numRecordDaAggiornare = 0, numRecordAggiornati = 0; StringBuilder codiciAggiornati = new StringBuilder("updateArticoloNonTrovati - Codici Aggiornati (debug)\n"); StatusMsg.updateMsgByTag(apFull, TAG_THREAD_MSG, ": Aggiornamento articoli non trovati ......"); if (l_id_fornitore == 0L || hsTipi.size() == 0) { rp.setStatus(true); rp.setMsg("Attenzione. Mancano dati di fornitore o tipi"); } else { long SOSPENDI_DOPO_N_VOLTE = apFull.getParm("CC_SOSPENDI_DOPO_N_GG_NO_IMPORT").getNumeroLong(); ArticoloCR CR = new ArticoloCR(apFull); Articolo bean = new Articolo(apFull); CR.setFlgModImportazione(0L); CR.setId_fornitore(l_id_fornitore); StringBuilder sbMarche = new StringBuilder(), sbTipi = new StringBuilder(); if (hsMarche.size() > 0) { for (Long temp : hsMarche) { sbMarche.append(String.valueOf(temp)); sbMarche.append(","); } CR.setId_marche(sbMarche.substring(0, sbMarche.length() - 1)); } Vectumerator vec = bean.findByCR(CR, 0, 0); if (vec.getTotNumberOfRecords() > 0) { rp.setStatus(true); while (vec.hasMoreElements()) { Articolo row = (Articolo)vec.nextElement(); if (hsTipi.contains(Long.valueOf(row.getId_tipo()))) { numRecordDaAggiornare++; ArticoloFornitore af = new ArticoloFornitore(apFull); af.findByFornitoreArticolo(l_id_fornitore, row.getId_articolo(), -1L); if (af.getId_articoloFornitore() > 0L) { if (af.getDispoTot() > 0L) { af.setDispCash(0L); af.setDispSede(0L); rp = af.save(); } if (rp.getStatus()) { rp = aggiornaDispoEPrezzoArticoloFornitore(row, 0L, 0L, false); if (!rp.getStatus()) { err.append(row.getCodice()); err.append(" "); err.append(row.getNome()); err.append("; "); err.append(rp.getMsg()); err.append("\n"); } else { numRecordAggiornati++; codiciAggiornati.append(row.getCodice()); codiciAggiornati.append("\n"); } } else { err.append(row.getCodice()); err.append(" "); err.append(row.getNome()); err.append("; "); err.append(rp.getMsg()); err.append("\n"); } } } i++; if (se1 > 0 && i % se1 == 0) System.out.print("."); if (se2 > 0 && i % se2 == 0) System.out.println("" + i + "/" + i); StatusMsg.updateMsgByTag(apFull, TAG_THREAD_MSG, ": Aggiornamento articoli non trovati: " + i + "/" + vec.getTotNumberOfRecords() + " - da aggiornare/aggiornati: " + numRecordDaAggiornare + "/" + numRecordAggiornati); } } } rp.setMsg(" da aggiornare/aggiornati: " + numRecordDaAggiornare + "/" + numRecordAggiornati); if (err.length() > 0) { rp.setStatus(false); rp.appendMsg("\n" + err.toString()); } else { rp.setStatus(true); } if (debug) { rp.appendMsg("\n"); rp.appendMsg(codiciAggiornati.toString()); } else { rp.appendMsg("\n Per motivi di performance il dettaglio codici aggiornati è disabilitato in questa modalità."); } return rp; } public long getQtaMaxAcquistoWww() { return this.qtaMaxAcquistoWww; } public void setQtaMaxAcquistoWww(long qtaMaxAcquistoWww) { this.qtaMaxAcquistoWww = qtaMaxAcquistoWww; } public double getPrezzoMinimoEbay() { double tariffaFissa = 0.5D; double percEbay = 0.065D; if (getTipo().getEbayCommissione() > 0.0D) percEbay = getTipo().getEbayCommissione() / 100.0D; DoubleOperator dop = new DoubleOperator(getCostoNetto()); dop.setScale(4, 5); dop.add(tariffaFissa); DoubleOperator perc = new DoubleOperator(1.0F); perc.subtract(percEbay); dop.divide(perc); return dop.getResult(); } public double getTariffaEbay() { DoubleOperator dop = new DoubleOperator(getPrezzoArticoloEbayIva().getPrezzoFinale()); dop.setScale(4, 5); dop.add(10); dop.multiply(getTipo().getEbayCommissione()); dop.divide(100.0F); TipoPagamento tpEbay = TipoPagamento.getTipoPagamentoEbay(getApFull()); dop.add(tpEbay.getWwwTariffaFissa()); dop.setScale(2, 5); return dop.getResult(); } public double getTariffaPaypal() { double percPaypal = 3.4D; DoubleOperator dop = new DoubleOperator(getPrezzoPubblico(null)); dop.setScale(4, 5); dop.add(getDeliveryCost("I")); dop.multiply(percPaypal); dop.divide(100.0F); dop.add(0.35D); dop.setScale(2, 5); return dop.getResult(); } public double getPrezzoMinimoPaypalEbayIva() { return conIva(getPrezzoMinimoPaypalEbay(), (double)getIva().getAliquota()); } public void findByCodiceProduttore(String l_codiceProduttore) { findByCodiceProduttoreMarca(l_codiceProduttore, 0L); } public long getId_articoloTagliaKit() { return this.id_articoloTagliaKit; } public void setId_articoloTagliaKit(long id_articoloTagliaKit) { this.id_articoloTagliaKit = id_articoloTagliaKit; } public void findByCartitemId(CartItemId cii) { initFields(); if (cii.getId_articoloTaglia() > 0L) { ArticoloTaglia at = new ArticoloTaglia(this.apFull); at.findByPrimaryKey(cii.getId_articoloTaglia()); findByPrimaryKey(at.getId_articolo()); setId_articoloVariante(at.getId_articoloVariante()); setId_articoloTaglia(at.getId_articoloTaglia()); if (cii.getId_articoloTagliaKit() > 0L) { at = new ArticoloTaglia(this.apFull); at.findByPrimaryKey(cii.getId_articoloTagliaKit()); setId_articoloVarianteKit(at.getId_articoloVariante()); setId_articoloTagliaKit(at.getId_articoloTaglia()); } } else if (cii.getId_articoloVariante() > 0L) { ArticoloVariante av = new ArticoloVariante(this.apFull); av.findByPrimaryKey(cii.getId_articoloVariante()); findByPrimaryKey(av.getId_articolo()); setId_articoloVariante(av.getId_articoloVariante()); } else { findByPrimaryKey(cii.getId_articolo()); } } public String getCCLinkDettaglio(ArticoloCR CR) { if (CR != null) { if (CR.getId_articoloTaglia() > 0L || CR.getId_taglia() > 0L) { if (CR.getId_articoloVariante() > 0L) { if (CR.getId_articoloVarianteKit() > 0L) return getCCLinkDettaglioTK(CR); return getCCLinkDettaglioT(CR); } return getCCLinkDettaglioT(CR); } return getCCLinkDettaglioA(CR); } return getCCLinkDettaglio(); } public long getCartItemType() { if (getId_articoloTaglia() > 0L) { if (getId_articoloVariante() > 0L) { if (getId_articoloVarianteKit() > 0L) return 5L; return 3L; } if (getId_articoloTagliaKit() > 0L) return 4L; return 2L; } if (getId_articoloVariante() > 0L) return 1L; return 0L; } public long getId_fornitoreCostoNuovo() { return this.id_fornitoreCostoNuovo; } public void setId_fornitoreCostoNuovo(long id_fornitoreCostoNuovo) { this.id_fornitoreCostoNuovo = id_fornitoreCostoNuovo; setFornitoreCostoNuovo(null); } public Clifor getFornitoreCostoNuovo() { this.fornitoreCostoNuovo = (Clifor)getSecondaryObject(this.fornitoreCostoNuovo, Clifor.class, getId_fornitoreCostoNuovo()); return this.fornitoreCostoNuovo; } public void setFornitoreCostoNuovo(Clifor fornitoreCostoNuovo) { this.fornitoreCostoNuovo = fornitoreCostoNuovo; } public ResParm caricaIcecat() { return caricaIcecat(getCurrentLang(), true, 0); } public ResParm caricaIcecat(String l_lang, boolean sovrascriviImmagini, int ggChiamataIcecat) { ResParm rp = new ResParm(true); if (getId_articolo() == 0L || (getCodiceEan().isEmpty() && getId_marca() == 0L && getCodiceProduttore().isEmpty())) { rp.setStatus(false); rp.setMsg("Errore! Codice Ean/marca/mpn non presente o articolo non salvato"); } else if (ggChiamataIcecat > 0 && getDataChiamataIcecat() != null && getDateDiff(getDataChiamataIcecat(), getToday()) < (long)ggChiamataIcecat) { rp.setStatus(true); rp.setMsg("Chiamata Icecat gia' effettuata il " + getDataFormat().format(getDataChiamataIcecat())); } else { Attivita attivita = Attivita.getDefaultInstance(getApFull()); if (attivita.isIcecat()) { Icecat ic = new Icecat(attivita.getIcecatUsername(), l_lang); if (!getCodiceEan().isEmpty()) { rp = ic.fetchGtin(getCodiceEan()); } else { rp.setStatus(false); } if (!rp.getStatus()) if (getId_marca() > 0L && !getCodiceProduttore().isEmpty()) { rp = ic.fetchProductCode(getMarca().getDescrizione(), getCodiceProduttore()); } else { rp.setStatus(false); rp.setMsg("Errore! mancano ean/marca/codiceproduttore!"); return rp; } if (!rp.getStatus()) { rp.setStatus(false); JSONObject res = null; try { res = new JSONObject(rp.getMsg()); } catch (Exception e) {} if (res != null) { if (res.has("Message")) { rp.setMsg("Errore! " + res.getString("Message")); } else if (res.has("message")) { rp.setMsg("Errore! " + res.getString("message")); } } else { rp.setMsg("Errore! " + rp.getMsg()); } } else { StringBuilder sb = new StringBuilder(); boolean salvaArticolo = false; LinkedHashSet gallery = ic.getDSImageGallery(); if (gallery.size() > 0) if (sovrascriviImmagini && gallery.size() > 0) { String targetDir = getDocBase() + getDocBase(); File targetDirFile = new File(targetDir); if (targetDirFile.exists()) { deleteImmagini(); deleteImmaginiRiduzioni(null); } else { targetDirFile.mkdirs(); } setImgTmst(getTimeNameForFileUpload()); superSave(); int currentImg = 1; for (String urlImg : gallery) { caricaImmaginaDaRemoto(urlImg, (long)currentImg); sb.append("immagine"); sb.append(currentImg); sb.append(", "); currentImg++; } } if (!getDescrizioneBreve(l_lang).isEmpty()); setDescTxtLang("descrizioneBreve", l_lang, ic.getDSTitleLong()); sb.append("DescrizioneBreve, "); salvaArticolo = true; long maxlen = getMaxLenNomeMarketplace(); long maxlenDesc = getMaxLenDescMarketplace(); if (getNomeMarketplace(l_lang).isEmpty()) { if ((long)ic.getDSTitleLong().length() <= maxlen) { setDescTxtLang("nomeMarketplace", l_lang, ic.getDSTitleLong()); } else if ((long)ic.getDSSummaryDescriptionShort().length() <= maxlen) { setDescTxtLang("nomeMarketplace", l_lang, ic.getDSSummaryDescriptionShort()); } else { setDescTxtLang("nomeMarketplace", l_lang, getNome()); } sb.append("nomeMarketplace, "); salvaArticolo = true; } String l_descrizioneLunga = ic.getDSSummaryDescriptionLong(); String l_specifiche = ic.getDSFeaturesTable(translate("N.B.: Questa scheda è da ritenersi puramente informativa e non contiene alcun tipo di garanzia né implicita né esplicita.", l_lang)); String l_reasonBuy = ic.getDSReasonToBuyTable(translate("Punti di Forza", l_lang)); if (!getDescrizioneCommerciale(l_lang).isEmpty()); setDescTxtLang("descrizioneCommerciale", l_lang, l_descrizioneLunga + l_descrizioneLunga); sb.append("descrizioneCommerciale, "); salvaArticolo = true; if (getSpecifiche(l_lang).isEmpty() && !l_specifiche.isEmpty()) { setDescTxtLang("specifiche", l_lang, l_specifiche); sb.append("specifiche, "); salvaArticolo = true; } if (getDescrizioneMarketplace(l_lang).isEmpty()) { String temp = l_descrizioneLunga; if (!l_reasonBuy.isEmpty()) { temp = temp + temp; } else { temp = temp + temp; } if ((long)temp.length() <= maxlenDesc) { setDescTxtLang("descrizioneMarketplace", l_lang, temp); } else { setDescTxtLang("descrizioneMarketplace", l_lang, l_descrizioneLunga); } sb.append("descrizioneMarketplace, "); salvaArticolo = true; } if (salvaArticolo) { setFlgTipoSchedaArticoloWww(1L); setDataChiamataIcecat(getToday()); rp = save(); } if (rp.getStatus()) { StringBuilder sbCarNontrovate = new StringBuilder(); HashMap hmCar = ic.getDSFeaturesHasMap(); if (hmCar.size() > 0) { CaratteristicaArticolo ca = new CaratteristicaArticolo(getApFull()); Vectumerator vecCT = new CTipo(this.apFull).findCaratteristicheByTipo(getId_tipo(), false, 0, 0); while (vecCT.hasMoreElements()) { CTipo cTipo = (CTipo)vecCT.nextElement(); ca.findById_articoloId_caratteristica(getId_articolo(), cTipo.getId_caratteristica()); if (ca.getDBState() == 0) { if (cTipo.getCaratteristica().getIcecatDescs().toLowerCase().equals("mpn")) { if (!getCodiceProduttore().isEmpty()) { ca.setId_articolo(getId_articolo()); ca.setId_caratteristica(cTipo.getId_caratteristica()); ca.setValS(getCodiceProduttore()); ca.save(); } continue; } if (cTipo.getCaratteristica().getIcecatDescs().toLowerCase().equals("marca")) { if (!getCodiceProduttore().isEmpty()) { ca.setId_articolo(getId_articolo()); ca.setId_caratteristica(cTipo.getId_caratteristica()); ca.setValS(getMarca().getDescrizione()); ca.save(); } continue; } if (cTipo.getCaratteristica().getFlgTipoVal() == 6L) { Vectumerator vecLista = new Lista(getApFull()) .findLista(cTipo.getId_caratteristica(), 0, 0); while (vecLista.hasMoreElements()) { Lista lista = (Lista)vecLista.nextElement(); boolean carTrovata = false; StringTokenizer stringTokenizer = new StringTokenizer(lista.getIcecatValues(), ","); while (stringTokenizer.hasMoreTokens()) { String icecatValue = stringTokenizer.nextToken(); if (hmCar.containsValue(icecatValue)) { ca.setId_articolo(getId_articolo()); ca.setId_caratteristica(cTipo.getId_caratteristica()); ca.setId_lista(lista.getId_lista()); ca.save(); carTrovata = true; break; } } if (carTrovata) break; if (!lista.getIcecatValues().isEmpty()) for (Map.Entry me : hmCar.entrySet()) { stringTokenizer = new StringTokenizer(lista.getIcecatValues(), ","); while (stringTokenizer.hasMoreTokens()) { String icecatValue = stringTokenizer.nextToken(); if (me.getValue().contains(icecatValue)) { ca.setId_articolo(getId_articolo()); ca.setId_caratteristica(cTipo.getId_caratteristica()); ca.setId_lista(lista.getId_lista()); ca.save(); carTrovata = true; break; } } if (carTrovata) break; } } sbCarNontrovate.append(cTipo.getCaratteristica().getDescrizione_it()); sbCarNontrovate.append(", "); continue; } StringTokenizer st = new StringTokenizer(cTipo.getCaratteristica().getIcecatDescs(), ","); boolean trovato = false; while (st.hasMoreTokens()) { String token = st.nextToken(); if (hmCar.containsKey(token)) { ca.setId_articolo(getId_articolo()); ca.setId_caratteristica(cTipo.getId_caratteristica()); if (cTipo.getCaratteristica().getFlgTipoVal() == 3L) { ca.setValS(hmCar.get(token)); } else if (cTipo.getCaratteristica() .getFlgTipoVal() == 2L) { ca.setValDouble(Double.parseDouble(hmCar.get(token))); } else if (cTipo.getCaratteristica() .getFlgTipoVal() == 1L) { ca.setValI(Long.parseLong(hmCar.get(token))); } else if (cTipo.getCaratteristica() .getFlgTipoVal() == 4L) { ca.setValSN(hmCar.get(token).toLowerCase().equals("si") ? 1L : 0L); } else if (cTipo.getCaratteristica() .getFlgTipoVal() == 5L) { sbCarNontrovate.append(cTipo.getCaratteristica().getDescrizione_it()); sbCarNontrovate.append(", "); } ca.save(); trovato = true; } } if (!trovato) { sbCarNontrovate.append(cTipo.getCaratteristica().getDescrizione_it()); sbCarNontrovate.append(", "); } } } sb.append("caratteristiche, "); } if (sbCarNontrovate.length() > 0) { rp.setMsg("Attenzione! " + sb.toString() + " - Car. NON trovate: " + sbCarNontrovate.toString()); } else { rp.setMsg(sb.toString()); } } } } } return rp; } public long getId_statoUsato() { return this.id_statoUsato; } public void setId_statoUsato(long id_statoUsato) { this.id_statoUsato = id_statoUsato; setStatoUsato(null); } public StatoUsato getStatoUsato() { this.statoUsato = (StatoUsato)getSecondaryObject(this.statoUsato, StatoUsato.class, new Long(getId_statoUsato())); return this.statoUsato; } public void setStatoUsato(StatoUsato statoUsato) { this.statoUsato = statoUsato; } public boolean isNuovo() { return getStatoUsato().isNuovo(); } public boolean isUsato() { return getStatoUsato().isUsato(); } public void deleteImmaginiRiduzioni(String cartelleRiduzioni) { if (cartelleRiduzioni == null || cartelleRiduzioni.isEmpty()) cartelleRiduzioni = "50,66,100,200,350"; StringTokenizer st = new StringTokenizer(cartelleRiduzioni, ","); while (st.hasMoreTokens()) { String size = st.nextToken(); File dir = new File(getDocBase() + getDocBase() + getPathImg() + "/"); FilenameFilter imgFilter = new FilenameFilter() { public boolean accept(File dir, String name) { if ((name.indexOf("+" + Articolo.this.getId_articolo() + "_") >= 0 || name.indexOf("" + Articolo.this.getId_articolo() + "_") == 0) && name.toLowerCase().endsWith("jpg")) return true; return false; } }; File[] files = dir.listFiles(imgFilter); if (files != null) for (File currentImg : files) currentImg.delete(); } } public long getFlgPreventivoWwwArt() { return this.flgPreventivoWwwArt; } public void setFlgPreventivoWwwArt(long flgPreventivoWwwArt) { this.flgPreventivoWwwArt = flgPreventivoWwwArt; } public long getPercCostoSpedizione() { if (this.percCostoSpedizione <= 0L) if (getTipo().getPercCostoSpedizioneDefault() > 0L) { this.percCostoSpedizione = getTipo().getPercCostoSpedizioneDefault(); } else if (getTipo().getPercCostoSpedizioneDefault() < 0L) { setFlgPreventivoWwwArt(1L); } else { this.percCostoSpedizione = 0L; } return this.percCostoSpedizione; } public void setPercCostoSpedizione(long percCostoSpedizione) { this.percCostoSpedizione = percCostoSpedizione; } public boolean isCostoSpedizionePreventivoArticoloNazione(String l_id_nazione) { if (l_id_nazione.isEmpty()) l_id_nazione = "I"; ArticoloNazione an = new ArticoloNazione(getApFull()); an.findByArticoloNazione(getId_articolo(), l_id_nazione); if (an.getId_articoloNazione() > 0L) { if (an.getFlgPreventivoWwwAN() == 1L) return true; return false; } if (getFlgPreventivoWwwArt() == 1L) return true; Nazione nazione = new Nazione(getApFull()); nazione.findByPrimaryKey(l_id_nazione); if (nazione.getId_nazione().isEmpty()) return false; if (nazione.getFlgPreventivoWww() == 1L) return false; return (nazione.getFlgPreventivoWww() == 1L); } public long getPercentileSpedizione() { return getPercCostoSpedizione(); } public double getDeliveryCost(String l_id_nazione) { if (l_id_nazione.isEmpty()) l_id_nazione = "I"; Nazione nazione = new Nazione(getApFull()); nazione.findByPrimaryKey(l_id_nazione); if (nazione.getId_nazione().isEmpty()) return 0.0D; return getDeliveryCostPercentile(nazione); } public String getDeliveryCostDesc(String l_id_nazione, String lang) { if (l_id_nazione.isEmpty()) l_id_nazione = "I"; if (getFlgPreventivoWwwArt() == 1L) return translate("Su preventivo", lang); Nazione nazione = new Nazione(getApFull()); nazione.findByPrimaryKey(l_id_nazione); if (nazione.getId_nazione().isEmpty()) return translate("Su preventivo", lang); if (nazione.getFlgPreventivoWww() == 1L) return translate("Su preventivo", lang); double l_costoSped = getDeliveryCostPercentileIVA(nazione); double l_costoSpedNetto = getDeliveryCostPercentile(nazione); String res = "€ " + getNf().format(l_costoSped) + " (" + getNf().format(l_costoSpedNetto) + " " + translate("+ iva", lang) + ")"; return res; } private double getDeliveryCostPercentileIVA(Nazione nazione) { return conIva(getDeliveryCostPercentile(nazione), getParm(Cart.P_DELIVERY_IVA_ALIQUOTA).getNumeroDouble()); } private double getDeliveryCostPercentile(Nazione nazione) { if (getFlgPreventivoWwwArt() == 1L) return 0.0D; double l_costoSped = nazione.getCostoSpedizione(); if (getFornitoreCostoNuovo().getCostoSpedizioneAggiuntivo() > 0.0D) { DoubleOperator dop = new DoubleOperator(l_costoSped); dop.add(getFornitoreCostoNuovo().getCostoSpedizioneAggiuntivo()); dop.setScale(2, 5); l_costoSped = dop.getResult(); } if (getPercentileSpedizione() > 100L) { DoubleOperator dop = new DoubleOperator(l_costoSped); dop.multiply(getPercentileSpedizione()); dop.divide(100.0F); dop.setScale(2, 5); l_costoSped = dop.getResult(); } return l_costoSped; } public boolean isScontoTroppoAlto() { Attivita attivita = Attivita.getDefaultInstance(getApFull()); if (attivita.getCheckCartPercScontoMax() <= 0.0D) return false; if (Math.abs(getPercScontoRispettoAlPrezzoBarrato()) > attivita.getCheckCartPercScontoMax()) return true; return false; } public final ResParm startThreadCancellazioneMassiva(ApplParmFull apFull, ArticoloCR CR) { if (!isThreadCancellazione()) { new ThreadCancellazioneMassiva(apFull, CR); return new ResParm(true, "Thread cancellazione massiva avviato"); } return new ResParm(false, "ATTENZIONE!! Thread in esecuzione!!!"); } public ByteArrayOutputStream creaReportPdf(int flgTipo, ArticoloCR CR) { ByteArrayOutputStream ba = new ByteArrayOutputStream(); String titoloReport = ""; try { switch (flgTipo) { case 10: this.document = new Document(PageSize.A4, 20.0F, 20.0F, 10.0F, 10.0F); break; default: this.document = new Document(PageSize.A4, 20.0F, 20.0F, 10.0F, 10.0F); break; } switch (flgTipo) { case 10: titoloReport = "Listino Articoli"; break; case 11: titoloReport = "Report Articoli Usato"; break; default: titoloReport = "Report ???"; break; } SimpleDateFormat tf = new SimpleDateFormat("HH:mm:ss"); Date today = getToday(); titoloReport = titoloReport + ". Stampato il " + titoloReport + " " + getDataFormat().format(today); this.writer = PdfWriter.getInstance(this.document, ba); Phrase pH = new Phrase(titoloReport + " - Pag. n. "); HeaderFooter header = new HeaderFooter(pH, true); header.setAlignment(2); header.setBorder(0); this.document.setHeader(header); this.document.open(); switch (flgTipo) { case 10: creaUnReportListinoNegozio(this, CR); break; case 11: creaUnReportUsato(this, CR); break; } this.document.close(); this.document = null; } catch (Exception e) { e.printStackTrace(); } return ba; } private Document creaUnReportListinoNegozio(Articolo bean, ArticoloCR CR) { NumberFormat nf3 = NumberFormat.getInstance(); nf3.setMaximumFractionDigits(3); nf3.setMinimumFractionDigits(3); NumberFormat nf0 = NumberFormat.getInstance(); nf0.setMaximumFractionDigits(0); nf0.setMinimumFractionDigits(0); int col1 = 4, col2 = 8, col3 = 18, col4 = 4, col5 = 6; int cellLeading = 12; try { Cell rigaVuota = new Cell(new Chunk(" ", PDF_fPiccolissimo)); rigaVuota.setVerticalAlignment(4); rigaVuota.setHorizontalAlignment(0); rigaVuota.setLeading((float)cellLeading); rigaVuota.setBorder(0); rigaVuota.setColspan(40); rigaVuota.setRowspan(1); creaIntestazioneReport(CR.getTipoReport(), ""); Cell cell = new Cell(new Chunk("Codice", PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col1); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Marca", PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col2); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Descrizione", PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col3); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Giacenza", PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col4); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Prezzo con iva", PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); this.pdfcorpo.endHeaders(); CR.setFlgOrderBy(1L); Vectumerator vec = bean.findByCR(CR, 0, 0); while (vec.hasMoreElements()) { Articolo row = (Articolo)vec.nextElement(); cell = new Cell(new Chunk(String.valueOf(row.getId_articolo()), PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col1); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(row.getMarca().getDescrizione(), PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col2); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(row.getDescrizione(), PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col3); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf0().format(row.getQuantita()), PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col4); cell.setRowspan(1); this.pdfcorpo.addCell(cell); if (row.getFlgNoleggio() >= 1L) { cell = new Cell(new Chunk(getNf().format(row.getPrezzoNoleggioIva()), PDF_fMedio)); } else { cell = new Cell(new Chunk(getNf().format(row.getPrezzoPubblico()), PDF_fMedio)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); } this.document.add((Element)this.pdfcorpo); } catch (Exception e) { handleDebug(e); } return this.document; } private Document creaUnReportUsato(Articolo bean, ArticoloCR CR) { NumberFormat nf3 = NumberFormat.getInstance(); nf3.setMaximumFractionDigits(3); nf3.setMinimumFractionDigits(3); NumberFormat nf0 = NumberFormat.getInstance(); nf0.setMaximumFractionDigits(0); nf0.setMinimumFractionDigits(0); int col1 = 4, col2 = 5, col3 = 13, col4 = 12, col5 = 2, col6 = 4; int cellLeading = 12; try { Cell rigaVuota = new Cell(new Chunk(" ", PDF_fPiccolissimo)); rigaVuota.setVerticalAlignment(4); rigaVuota.setHorizontalAlignment(0); rigaVuota.setLeading((float)cellLeading); rigaVuota.setBorder(0); rigaVuota.setColspan(40); rigaVuota.setRowspan(1); creaIntestazioneReport(CR.getTipoReport(), ""); Cell cell = new Cell(new Chunk("ELENCO ARTICOLI A DATA ", PDF_fGrandeB)); if (CR.getDataDocumentoUsatoA() == null) { cell.add(new Chunk("di oggi " + getDataFormat().format(getToday()), PDF_fGrandeB)); } else { cell.add(new Chunk(getDataFormat().format(CR.getDataDocumentoUsatoA()), PDF_fGrandeB)); } cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.WHITE); cell.setColspan(40); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Codice", PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col1); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Marca", PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col2); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Descrizione", PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col3); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Fornitore", PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col4); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("#", PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Costo Acquisto", PDF_fGrandeB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setBackgroundColor(Color.lightGray); cell.setColspan(col6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); this.pdfcorpo.endHeaders(); CR.setFlgOrderBy(1L); CR.setFlgUsato(99L); CR.setFlgQta(1L); CR.setQtaDa(1L); CR.setFlgEscludiWeb(-1L); DoubleOperator totAcquisto = new DoubleOperator(); long totArticoli = 0L, totaleArticoliPresenti = 0L; Vectumerator vec = bean.findByCR(CR, 0, 0); while (vec.hasMoreElements()) { Articolo row = (Articolo)vec.nextElement(); totAcquisto.add(row.getCostoNetto()); totArticoli++; totaleArticoliPresenti = (long)((double)totaleArticoliPresenti + row.getQuantita()); cell = new Cell(new Chunk(String.valueOf(row.getCodice()), PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col1); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(row.getMarca().getDescrizione(), PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col2); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(row.getDescrizione() + " (" + row.getDescrizione() + ")", PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col3); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(row.getFornitoreUsato().getDescrizioneCompleta(), PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(0); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col4); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf0().format(row.getQuantita()), PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(row.getCostoNetto()), PDF_fMedio)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); } cell = new Cell(new Chunk("TOTALI", PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col1 + col2 + col3 + col4); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf0().format(totArticoli), PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf().format(totAcquisto.getResult()), PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("Attualmente in magazzino: ", PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col1 + col2 + col3 + col4); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk(getNf0().format(totaleArticoliPresenti), PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col5); cell.setRowspan(1); this.pdfcorpo.addCell(cell); cell = new Cell(new Chunk("", PDF_fMedioB)); cell.setVerticalAlignment(4); cell.setHorizontalAlignment(2); cell.setLeading((float)cellLeading); cell.setBorder(0); cell.setColspan(col6); cell.setRowspan(1); this.pdfcorpo.addCell(cell); this.document.add((Element)this.pdfcorpo); } catch (Exception e) { handleDebug(e); } return this.document; } public Clifor getFornitoreUsato() { return new ArticoloUsato(getApFull()).getFornitoreByArticolo(getId_articolo()); } public PrezzoArticolo getPrezzoArticoloIva(Clifor clifor) { if (this.prezzoArticoloIva != null && clifor != null && this.prezzoArticoloIva.getId_clifor() != clifor.getId_clifor()) { this.prezzoArticolo = null; this.prezzoArticoloIva = null; } if (this.prezzoArticoloIva == null && getId_articolo() > 0L) if (clifor != null) { if (clifor.isPrezzoWebEsente()) { this.prezzoArticoloIva = getPrezzoArticolo(clifor); } else { Iva ivaDaApplicare = getIvaByClifor(clifor); if (clifor.getListino().getId_listino() > 0L) { this.prezzoArticoloIva = clifor.getListino().getPrezzoIva(this, ivaDaApplicare); this.prezzoArticoloIva.setId_clifor(clifor.getId_clifor()); } else { this.prezzoArticoloIva = getListinoBase().getPrezzoIva(this, ivaDaApplicare); } } } else { this.prezzoArticoloIva = getListinoBase().getPrezzoIva(this); } return (this.prezzoArticoloIva == null) ? new PrezzoArticolo() : this.prezzoArticoloIva; } public boolean isPrezzoWebEsente(Users user) { if (user == null || user.getId_users() == 0L) return false; if (user.getId_clifor() >= 0L) return user.getClifor().isPrezzoWebEsente(); return false; } public static String getTipoReport(long l_flgTipoReport) { if (l_flgTipoReport == 10L) return "Listino Negozio"; if (l_flgTipoReport == 11L) return "USATO"; if (l_flgTipoReport == 1L) return "Articolo+Varianti"; if (l_flgTipoReport == 2L) return "Articolo+Varianti+Seriali"; if (l_flgTipoReport == 0L) return "Comnpatto"; return "??"; } public String getCategoriaImport() { return (this.categoriaImport == null) ? "" : this.categoriaImport.trim(); } public void setCategoriaImport(String categoriaImport) { this.categoriaImport = categoriaImport; } public String getCCLinkAdmin() { StringBuilder sb = new StringBuilder(); sb.append(getParm("P_WWW_ADDRESS").getTesto()); sb.append("Redir.abl?_svlt=/admin/art/Articolo.abl&_parms=@cmd:search@codice:"); sb.append(getCodice()); return sb.toString(); } public String getTFLinkDettaglio(ArticoloCR CR) { String lang = (CR == null || CR.getLang().isEmpty()) ? "it" : CR.getLang(); StringBuilder sb = new StringBuilder(); sb.append(convertStringToLink(getMarca().getDescrizione()).replace('+', '-')); sb.append("-"); sb.append(getDescrizioneNomeCodiceUrl().replace('+', '-').replace(',', '-')); sb.append("+"); if (CR == null) { sb.append("d"); } else { sb.append(translate("d", lang)); } sb.append("-"); sb.append(getId_articolo()); sb.append("-"); sb.append((getId_articoloVariante() == 0L) ? "" : getId_articoloVariante()); sb.append("-"); sb.append(lang); String res = convertStringToLink(sb.toString().toLowerCase()) + ".html"; return res; } public String getTFLinkDettaglioCanonical() { return getWwwAddressParm() + getWwwAddressParm(); } public boolean isReadyForMarketplace(String lang) { if (isReadyForWeb(lang)) { if (getFlgSubito() == 1L || getFlgEbay() == 1L) { long maxlen = getMaxLenNomeMarketplace(); long maxlenDesc = getMaxLenDescMarketplace(); String temp = getDescTxtLang("nomeMarketplace", lang); if (temp.isEmpty() || (long)temp.length() > maxlen) return false; temp = getDescTxtLang("descrizioneMarketplace", lang); if (temp.isEmpty() || (long)temp.length() > maxlenDesc) return false; } return true; } return false; } public Date getDataScadenzaOffertaFornitore() { return this.dataScadenzaOffertaFornitore; } public void setDataScadenzaOffertaFornitore(Date dataScadenzaOffertaFornitore) { this.dataScadenzaOffertaFornitore = dataScadenzaOffertaFornitore; } public boolean isEbayPubblicato() { if (getEbayOfferId().isEmpty()) return false; return true; } public boolean isAmazonPubblicato() { return false; } public double getPercRicaricoEffettivo() { return getRicaricoEffettivoDaCostoNetto(); } public double getPerRicaricoEffettivoEbay() { if (getCostoNetto() > 0.0D) { DoubleOperator dop = new DoubleOperator(getPrezzoArticoloEbay().getPrezzoFinale()); dop.setScale(4, 5); dop.divide(getCostoNetto()); dop.subtract(1); dop.multiply(100); return dop.getResult(); } return 0.0D; } public void setPercRicaricoEffettivo(double percRicaricoEffettivo) { this.percRicaricoEffettivo = percRicaricoEffettivo; } public static String getEventTypeString(int eventType) { switch (eventType) { case 1: return "START_ELEMENT"; case 2: return "END_ELEMENT"; case 3: return "PROCESSING_INSTRUCTION"; case 4: return "CHARACTERS"; case 5: return "COMMENT"; case 7: return "START_DOCUMENT"; case 8: return "END_DOCUMENT"; case 9: return "ENTITY_REFERENCE"; case 10: return "ATTRIBUTE"; case 11: return "DTD"; case 12: return "CDATA"; case 6: return "SPACE"; } return "UNKNOWN_EVENT_TYPE , " + eventType; } public static final String getNascondi(long l_flgNascondi) { if (l_flgNascondi == 0L) return "No"; if (l_flgNascondi == 1L) return "Si"; return "??"; } public static final String getStato(long l_flgStato) { if (l_flgStato == 0L) return "Ok"; if (l_flgStato == 1L) return "A Richista"; if (l_flgStato == 2L) return "Fine Serie"; return "??"; } public static final String getNoleggio(long l_noleggio) { if (l_noleggio == 0L) return "No"; if (l_noleggio == 1L) return "Solo Noleggio"; if (l_noleggio == 2L) return "Vendita e Noleggio"; return "??"; } public static String getUdm(long l_flgUdm) { return TipologiaArticolo.getUdm(l_flgUdm); } public long getId_confezionistaDefault() { return this.id_confezionistaDefault; } public void setId_confezionistaDefault(long id_confezionistaDefault) { this.id_confezionistaDefault = id_confezionistaDefault; setConfezionistaDefault(null); } private long flgTrovaprezzi = 0L; private long flgIdealo = -1L; private long id_magFisico; private MagFisico magFisico; public Clifor getConfezionistaDefault() { this.confezionistaDefault = (Clifor)getSecondaryObject(this.confezionistaDefault, Clifor.class, getId_confezionistaDefault()); return this.confezionistaDefault; } public void setConfezionistaDefault(Clifor confezionistaDefault) { this.confezionistaDefault = confezionistaDefault; } public String getGoogleFeedFileName() { return (this.googleFeedFileName == null) ? "" : this.googleFeedFileName.trim(); } public void setGoogleFeedFileName(String googleFeedFileName) { this.googleFeedFileName = googleFeedFileName; } public long getFlgAmazon() { return this.flgAmazon; } public void setFlgAmazon(long flgAmazon) { this.flgAmazon = flgAmazon; } public double getTariffaAmazon() { DoubleOperator dop = new DoubleOperator(getPrezzoArticoloAmazonIva().getPrezzoFinale()); dop.setScale(4, 5); dop.multiply(getTipo().getAmazonCommissione()); dop.divide(100.0F); TipoPagamento tpAmz = TipoPagamento.getTipoPagamentoAmazon(getApFull()); dop.add(tpAmz.getWwwTariffaFissa()); dop.setScale(2, 5); return dop.getResult(); } public void setTariffaAmazon(double tariffaAmazon) { this.tariffaAmazon = tariffaAmazon; } public long getId_listinoAmazon() { if (this.id_listinoAmazon == 0L && getApFull() != null) this.id_listinoAmazon = getTipo().getId_listinoAmazon(); return this.id_listinoAmazon; } public void setId_listinoAmazon(long id_listinoAmazon) { this.id_listinoAmazon = id_listinoAmazon; setListinoAmazon(null); } public Listino getListinoAmazon() { this.listinoAmazon = (Listino)getSecondaryObject(this.listinoAmazon, Listino.class, getId_listinoAmazon()); return this.listinoAmazon; } public void setListinoAmazon(Listino listinoAmazon) { this.listinoAmazon = listinoAmazon; } public long getQtaAmz() { return this.qtaAmz; } public void setQtaAmz(long qtaAmazon) { this.qtaAmz = qtaAmazon; } public PrezzoArticolo getPrezzoArticoloAmazon() { if (getId_listinoAmazon() == 0L) return getListinoBase().getPrezzoBaseLA(this); return getListinoAmazon().getPrezzo(this); } public PrezzoArticolo getPrezzoArticoloAmazonIva() { if (getId_listinoAmazon() == 0L) return getListinoBase().getPrezzoBaseIvaLA(this); return getListinoAmazon().getPrezzoIva(this); } public double getPrezzoArticoloAmazonIvaExport(String currentLang, long qty) { if (getFlgPriceTypeAmz() == 0L) return getPrezzoArticoloAmazonIva().getPrezzoFinale(); if (getFlgPriceTypeAmz() == 1L) return getPrezzoArticoloAmazonSpedIva(currentLang, true, qty); return getPrezzoArticoloAmazonSpedIva(currentLang, false, qty); } public double getPercScontoPrezzoAmzQty(String currentLang, boolean conPercentile, long qtyDa) { DoubleOperator dop = new DoubleOperator(-getPrezzoArticoloAmazonSpedIva(currentLang, conPercentile, qtyDa)); dop.setScale(4, 5); dop.divide(getPrezzoArticoloAmazonSpedIva(currentLang, conPercentile, 1L)); dop.add(1); dop.multiply(100); dop.setScale(2, 5); return dop.getResult(); } public String getAmzPrezziDesc() { StringBuilder sb = new StringBuilder(); sb.append("+"); sb.append(getNf().format(getListinoAmazon().getPercL())); sb.append("% "); sb.append("
"); if (getFlgPriceTypeAmz() == 0L) sb.append(""); sb.append(getNf().format(getPrezzoArticoloAmazonIva().getPrezzoFinale())); if (getFlgPriceTypeAmz() == 0L) sb.append(""); sb.append("
"); if (getPercentileSpedizione() > 100L) { if (getFlgPriceTypeAmz() == 1L) sb.append(""); sb.append("sp1 "); sb.append(getNf().format(getPrezzoArticoloAmazonSpedIva("it", true, 1L))); sb.append(" "); sb.append("sp2 "); sb.append(getNf().format(getPrezzoArticoloAmazonSpedIva("it", true, 2L))); sb.append(" "); sb.append("-"); sb.append(getNf().format(getPercScontoPrezzoAmzQty("it", true, 2L))); sb.append("% "); if (getFlgPriceTypeAmz() == 1L) sb.append(""); sb.append("
"); if (getFlgPriceTypeAmz() == 2L) sb.append(""); sb.append("s1 "); sb.append(getNf().format(getPrezzoArticoloAmazonSpedIva("it", false, 1L))); sb.append(" "); sb.append("s2 "); sb.append(getNf().format(getPrezzoArticoloAmazonSpedIva("it", false, 2L))); sb.append(" "); sb.append("-"); sb.append(getNf().format(getPercScontoPrezzoAmzQty("it", false, 2L))); sb.append("% "); if (getFlgPriceTypeAmz() == 2L) sb.append(""); } else { if (getFlgPriceTypeAmz() != 0L) sb.append(""); sb.append("s1 "); sb.append(getNf().format(getPrezzoArticoloAmazonSpedIva("it", false, 1L))); sb.append(" "); sb.append("s2 "); sb.append(getNf().format(getPrezzoArticoloAmazonSpedIva("it", false, 2L))); sb.append(" "); sb.append("-"); sb.append(getNf().format(getPercScontoPrezzoAmzQty("it", false, 2L))); sb.append("% "); if (getFlgPriceTypeAmz() != 0L) sb.append(""); } return sb.toString(); } public String getAmzPrezziDescInline() { return getAmzPrezziDesc().replace("
", " "); } public double getPrezzoArticoloAmazonSpedIva(String l_nazioneCodice, boolean conPercentile, long qty) { double l_costoSpedIva; if (qty == 0L) return getPrezzoArticoloAmazonIva().getPrezzoFinale(); if (l_nazioneCodice.isEmpty()) l_nazioneCodice = "it"; Nazione nazione = new Nazione(getApFull()); nazione.findByCodice(l_nazioneCodice); if (conPercentile) { l_costoSpedIva = getDeliveryCostPercentileIVA(nazione); } else { l_costoSpedIva = nazione.getCostoSpedizioneConIva(); if (getFornitoreCostoNuovo().getCostoSpedizioneAggiuntivo() > 0.0D) { DoubleOperator doubleOperator = new DoubleOperator(l_costoSpedIva); doubleOperator.add(getFornitoreCostoNuovo().getCostoSpedizioneAggiuntivoConIva()); doubleOperator.setScale(2, 5); l_costoSpedIva = doubleOperator.getResult(); } } DoubleOperator dop = new DoubleOperator(l_costoSpedIva); dop.setScale(2, 5); dop.divide((float)qty); dop.add(getPrezzoArticoloAmazonIva().getPrezzoFinale()); return dop.getResult(); } public double getPrezzoMinimoAmazon() { double tariffaFissa = 0.3D; double percAmazon = 0.0721D; double percExtra = 0.0D; if (getTipo().getAmazonCommissione() > 0.0D) percAmazon = getTipo().getAmazonCommissione() / 100.0D; if (getTipo().getAmazonCommissioneOltreSoglia() > 0.0D) percExtra = getTipo().getAmazonCommissioneOltreSoglia() / 100.0D; if (getTipo().getAmazonFissa() > 0.0D) tariffaFissa = getTipo().getAmazonFissa(); if (getTipo().getAmazonSoglia() == 0.0D) { DoubleOperator dop = new DoubleOperator(getCostoNetto()); dop.setScale(4, 5); dop.add(tariffaFissa); DoubleOperator perc = new DoubleOperator(1.0F); perc.subtract(percAmazon); dop.divide(perc); return dop.getResult(); } if (getCostoNetto() <= getTipo().getAmazonSoglia() && percExtra > 0.0D) { DoubleOperator dop = new DoubleOperator(getCostoNetto()); dop.setScale(4, 5); dop.add(tariffaFissa); DoubleOperator perc = new DoubleOperator(1.0F); perc.subtract(percAmazon); dop.divide(perc); return dop.getResult(); } DoubleOperator numer = new DoubleOperator(getCostoNetto()); numer.setScale(4, 5); numer.add(tariffaFissa); DoubleOperator numer2 = new DoubleOperator(getTipo().getAmazonSoglia()); numer2.setScale(4, 5); DoubleOperator perc12 = new DoubleOperator(percAmazon); perc12.setScale(4, 5); perc12.subtract(percExtra); numer2.multiply(perc12); numer.add(numer2); DoubleOperator denom = new DoubleOperator(1.0F); denom.subtract(percExtra); numer.divide(denom); return numer.getResult(); } public double getPrezzoMinimoEbayIva() { return conIva(getPrezzoMinimoEbay(), (double)getIva().getAliquota()); } public Vectumerator findArticoliEan14() { String s_Sql_Find = "select A.* from ARTICOLO as A "; String s_Sql_order = " "; WcString wc = new WcString(); wc.addWc("char_length(A.codiceean)>=14"); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + String.valueOf(wc)); return findRows(stmt); } catch (Exception e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public Vectumerator findDoppioniEan() { String s_Sql_Find = "Select A.* from ARTICOLO as A where codiceEan in(SELECT codiceEan FROM ARTICOLO GROUP BY codiceEan HAVING count(codiceEan) > 1 and codiceEan is not null)"; String s_sql_orderby = " order by codiceEan , readyForWeb desc, quantita desc, costoNetto"; try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find); return findRows(stmt); } catch (Exception e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public ResParm unisciDoppioniEan() { ResParm rp = new ResParm(); int countDoppioni = 0; String TAG_THREAD_MSG = "UNIONE DOPPIONI EAN "; StringBuilder sbErr = new StringBuilder(); LinkedHashSet hsArticoli = new LinkedHashSet<>(); String currenteEan = ""; Vectumerator vec = findDoppioniEan(); StatusMsg.updateMsgByTag(getApFull(), TAG_THREAD_MSG, "...inizio ..."); long totDoppioni = (long)(vec.getTotNumberOfRecords() / 2); while (vec.hasMoreElements()) { Articolo row = (Articolo)vec.nextElement(); if (currenteEan.isEmpty()) currenteEan = row.getCodiceEan(); if (currenteEan.equals(row.getCodiceEan())) { hsArticoli.add(row); continue; } StatusMsg.updateMsgByTag(getApFull(), TAG_THREAD_MSG, "current ean; " + currenteEan + " " + countDoppioni + " su " + totDoppioni); Articolo articolo1 = null; for (Articolo ele : hsArticoli) { if (articolo1 == null) { articolo1 = ele; continue; } rp = unisciArticoli(articolo1, ele); if (!rp.getStatus()) { sbErr.append(currenteEan + ": " + currenteEan); sbErr.append("\n"); } } countDoppioni++; currenteEan = row.getCodiceEan(); hsArticoli = new LinkedHashSet<>(); hsArticoli.add(row); } StatusMsg.updateMsgByTag(getApFull(), TAG_THREAD_MSG, "current ean; " + currenteEan + " " + countDoppioni + " su " + totDoppioni); countDoppioni++; Articolo master = null; for (Articolo ele : hsArticoli) { if (master == null) { master = ele; continue; } rp = unisciArticoli(master, ele); if (!rp.getStatus()) { sbErr.append(currenteEan + ": " + currenteEan); sbErr.append("\n"); } } if (sbErr.length() > 0) { rp.setStatus(false); rp.setMsg("Record processati:" + countDoppioni + " " + sbErr.toString()); } else { rp.setStatus(true); rp.setMsg("Record processati:" + countDoppioni); } StatusMsg.deleteMsgByTag(getApFull(), TAG_THREAD_MSG); return rp; } public ResParm unisciArticoli(Articolo master, Articolo slave) { ResParm rp = new ResParm(); ArticoloFornitore af = new ArticoloFornitore(getApFull()); Vectumerator vecAf = af.findById_articolo(slave.getId_articolo(), 0, 0); while (vecAf.hasMoreElements()) { ArticoloFornitore rowAf = (ArticoloFornitore)vecAf.nextElement(); af.findByFornitoreArticolo(rowAf.getId_clifor(), master.getId_articolo(), -1L); if (af.getId_articoloFornitore() > 0L) { rp = rowAf.delete(); continue; } rowAf.setId_articolo(master.getId_articolo()); rp = rowAf.save(); } if (rp.getStatus()) rp = af.aggiornaCodiciAlternativiByArticolo(master, true); if (rp.getStatus()) rp = aggiornaPrezziEDispoByFornitori(0.0D, false); rp = master.update("update RIGA_DOCUMENTO SET id_articolo=" + master.getId_articolo() + " where id_articolo=" + slave.getId_articolo()); if (rp.getStatus()) rp = slave.delete(); return rp; } public long getFlgControlloCostoAggArt() { return this.flgControlloCostoAggArt; } public void setFlgControlloCostoAggArt(long flgControlloCostoAggArt) { this.flgControlloCostoAggArt = flgControlloCostoAggArt; } public String getCodiciAlternativiLinkAll() { assert false : "Decompilation failed at line #22024 -> offsets [0]"; assert false : "Decompilation failed at line #22026 -> offsets [8]"; assert false : "Decompilation failed at line #22028 -> offsets [16]"; assert false : "Decompilation failed at line #22033 -> offsets [25]"; assert false : "Decompilation failed at line #22035 -> offsets [35]"; assert false : "Decompilation failed at line #22036 -> offsets [42]"; assert false : "Decompilation failed at line #22037 -> offsets [49]"; assert false : "Decompilation failed at line #22039 -> offsets [57]"; assert false : "Decompilation failed at line #22040 -> offsets [65, 85]"; assert false : "Decompilation failed at line #22041 -> offsets [73]"; assert false : "Decompilation failed at line #22042 -> offsets [92]"; assert false : "Decompilation failed at line #22043 -> offsets [100]"; assert false : "Decompilation failed at line #22044 -> offsets [114]"; assert false : "Decompilation failed at line #22047 -> offsets [122]"; assert false : "Decompilation failed at line #22048 -> offsets [129]"; assert false : "Decompilation failed at line #22050 -> offsets [137]"; assert false : "Decompilation failed at line #22052 -> offsets [146]"; assert false : "Decompilation failed at line #22053 -> offsets [153]"; assert false : "Decompilation failed at line #22055 -> offsets [161]"; assert false : "Decompilation failed at line #22056 -> offsets [169, 189]"; assert false : "Decompilation failed at line #22057 -> offsets [177]"; assert false : "Decompilation failed at line #22058 -> offsets [196]"; assert false : "Decompilation failed at line #22059 -> offsets [204]"; assert false : "Decompilation failed at line #22060 -> offsets [218]"; assert false : "Decompilation failed at line #22062 -> offsets [226]"; assert false : "Decompilation failed at line #22063 -> offsets [234]"; assert false : "Decompilation failed at line #22067 -> offsets [235]"; } public void resetImpression() { if (getApFull() != null) { update("update ARTICOLO SET impression=0"); update("update ARTICOLO SET tmstLastImpression=null"); } } public String getCCLinkInfo(ArticoloCR CR) { String lang = (CR == null || CR.getLang().isEmpty()) ? "it" : CR.getLang(); StringBuilder sb = new StringBuilder(); StringBuilder sbCmd = new StringBuilder(); if (getId_articoloVariante() == 0L) { sb.append(convertStringToLink(getDescrizioneNomeUrl()).toLowerCase()); } else { sb.append(convertStringToLink(getArticoloVariante().getDescrizioneNomeUrl()).toLowerCase()); } sb.append("-"); if (!getTipo().getDescrizioneLink(lang).isEmpty()) { sb.append(getTipo().getDescrizioneLink(lang).replace(" ", "-").toLowerCase()); } else { sb.append(getTipo().getDescrizioneCompletaMinus(lang).toLowerCase()); } sb = new StringBuilder(eliminaDoppioniInStringa(sb.toString().toLowerCase(), "-", 1, false)); sbCmd.append("+"); sbCmd.append("info"); sbCmd.append("-"); sbCmd.append(getId_articolo()); sbCmd.append("-"); sbCmd.append((getId_articoloVariante() == 0L) ? "" : getId_articoloVariante()); sbCmd.append("-"); if (CR != null) sbCmd.append(CR.getSearchTxtWeb()); sbCmd.append("-"); sbCmd.append(lang); sbCmd.append(".html"); if (getParm("CC_LINK_WEB_CON_MARCA").isTrue()) if (sb.toString().toLowerCase().indexOf(getMarca().getDescrizione().toLowerCase()) < 0) sb.insert(0, getMarca().getDescrizione().toLowerCase() + "-"); long realMaxlinkLength = 80L - (long)getWwwAddressParm().length(); if ((long)(sb.length() + sbCmd.length()) > realMaxlinkLength) { String pre = sb.substring(0, (int)(realMaxlinkLength - (long)sbCmd.length() + 1L)); if (pre.lastIndexOf("-") > 0) pre = pre.substring(0, pre.lastIndexOf("-")); return pre.toLowerCase() + pre.toLowerCase(); } return sb.toString().toLowerCase() + sb.toString().toLowerCase(); } public ResParm creaFileXmlTrovaprezzi(ArticoloCR CR) { int numRecord = 0; ResParm rp = new ResParm(true); String trovaprezziFile = "trovaprezzi_" + System.currentTimeMillis() + ".xml"; String filename = getDocBase() + getDocBase() + getParm("PATH_TMP").getTesto(); String trovaprezziPermanentFileName = getDocBase() + "_trovaprezzi/" + getDocBase(); File xmlFile = new File(filename); String theDir = xmlFile.getAbsolutePath().substring(0, xmlFile.getAbsolutePath().lastIndexOf(File.separator) + 1); File theDirFile = new File(theDir); if (!theDirFile.exists()) theDirFile.mkdirs(); new File(filename).delete(); File theDirFileGoogle = new File(getDocBase() + "_trovaprezzi/"); if (!theDirFileGoogle.exists()) theDirFileGoogle.mkdirs(); org.w3c.dom.Element e = null; CR.setFlgTrovaprezzi(1L); CR.setFlgEscludiWeb(0L); CR.setFlgWebNoVendita(0L); Vectumerator vec = findByCR(CR, 0, 0); System.out.println("creaFileXmlTrovaprezzi: tot record:" + vec.getTotNumberOfRecords()); String title = getParm("TITLE").getTesto(); String site = getParm("P_WWW_ADDRESS").getTesto(); String lang = CR.getLang(); if (lang.isEmpty()) { lang = "it"; CR.setLang(lang); } NumberFormat nf2 = NumberFormat.getInstance(Locale.US); nf2.setMaximumFractionDigits(2); nf2.setMinimumFractionDigits(2); String wwwSite = getWwwAddressParm(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); try { DocumentBuilder db = dbf.newDocumentBuilder(); org.w3c.dom.Document dom = db.newDocument(); org.w3c.dom.Element rootElement = dom.createElement("Products"); rootElement.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); while (vec.hasMoreElements()) { Articolo rowbean = (Articolo)vec.nextElement(); if (rowbean.getFlgUsaVarianti() == 0L) { String temp; numRecord++; org.w3c.dom.Element entryEl = dom.createElement("Offer"); e = dom.createElement("Code"); e.setTextContent(rowbean.getCodice()); entryEl.appendChild(e); e = dom.createElement("Name"); if (!rowbean.getDescTxtLangScript("nomeMarketplace", lang).isEmpty()) { temp = rowbean.getDescTxtLangScript("nomeMarketplace", lang).replaceAll("€", "€").replace(";", " "); } else { temp = rowbean.getCCNome(lang); } e.setTextContent(convertTo1stCap(temp)); entryEl.appendChild(e); e = dom.createElement("Description"); if (!rowbean.getDescrizioneMarketplace(lang).isEmpty()) { e.setTextContent(rowbean.getDescrizioneMarketplace(lang)); } else if (!rowbean.getDescrizioneBreve(lang).isEmpty()) { e.setTextContent(rowbean.getDescrizioneBreve(lang)); } else { e.setTextContent(rowbean.getNome(lang)); } entryEl.appendChild(e); e = dom.createElement("Link"); e.setTextContent(wwwSite + wwwSite); entryEl.appendChild(e); e = dom.createElement("Image"); e.setTextContent(wwwSite + wwwSite + getPathImg()); entryEl.appendChild(e); for (int i = 2; i <= 10; i++) { if (new File(getDocBase() + getDocBase() + rowbean.getPathImg()).exists()) { e = dom.createElement("Image" + i); e.setTextContent(wwwSite + wwwSite + rowbean.getPathImg()); entryEl.appendChild(e); } } e = dom.createElement("Stock"); if (rowbean.getAvail() > 0.0D) { if (rowbean.getAvail() == 1.0D) { e.setTextContent(String.valueOf(2)); } else { e.setTextContent(String.valueOf((long)rowbean.getAvail())); } } else { e.setTextContent("in arrivo"); } entryEl.appendChild(e); boolean gestioneOfferteAttive = true; if (gestioneOfferteAttive) { if (rowbean.isPrezzoBarratoValido()) { e = dom.createElement("OriginalPrice"); e.setTextContent(String.valueOf(rowbean.getPrezzoIvatoBarrato())); entryEl.appendChild(e); e = dom.createElement("Price"); e.setTextContent(String.valueOf(rowbean.getPrezzoPubblicoIva())); entryEl.appendChild(e); } else if (rowbean.getListinoArticoloBase().isOffertaValida()) { e = dom.createElement("OriginalPrice"); e.setTextContent(String.valueOf(rowbean.getPrezzoBaseIva())); entryEl.appendChild(e); e = dom.createElement("Price"); e.setTextContent(String.valueOf(rowbean.getPrezzoPubblicoIva())); entryEl.appendChild(e); } else { e = dom.createElement("Price"); e.setTextContent(String.valueOf(rowbean.getPrezzoPubblicoIva())); entryEl.appendChild(e); } } else { if (rowbean.isPrezzoBarratoValido()) { e = dom.createElement("OriginalPrice"); e.setTextContent(String.valueOf(rowbean.getPrezzoIvatoBarrato())); entryEl.appendChild(e); } e = dom.createElement("Price"); e.setTextContent(String.valueOf(rowbean.getPrezzoPubblicoIva())); entryEl.appendChild(e); } if (rowbean.getTipo().getTrovaprezziCategoria().isEmpty()) { e = dom.createElement("Categories"); e.setTextContent(rowbean.getTipo().getDescrizioneCompletaKeyword("it")); entryEl.appendChild(e); } else { e = dom.createElement("Categories"); e.setTextContent(rowbean.getTipo().getTrovaprezziCategoria()); entryEl.appendChild(e); } e = dom.createElement("Brand"); e.setTextContent(rowbean.getMarca().getDescrizione()); entryEl.appendChild(e); if (!rowbean.getCodiceEan().isEmpty()) { e = dom.createElement("EanCode"); e.setTextContent(rowbean.getCodiceEan()); entryEl.appendChild(e); } Nazione nazione = new Nazione(getApFull()); nazione.findByPrimaryKey("I"); e = dom.createElement("ShippingCost"); if (rowbean.getPercentileSpedizione() <= 100L) { e.setTextContent(String.valueOf(conIva(nazione.getCostoSpedizione(), (double)rowbean.getIva().getAliquota()))); } else { DoubleOperator dop = new DoubleOperator(nazione.getCostoSpedizione()); dop.multiply(rowbean.getPercentileSpedizione()); dop.divide(100.0F); dop.setScale(2, 5); e.setTextContent(String.valueOf(conIva(dop.getResult(), (double)rowbean.getIva().getAliquota()))); } entryEl.appendChild(e); if (!rowbean.getCodiceProduttore().isEmpty()) { e = dom.createElement("PartNumber"); e.setTextContent(rowbean.getCodiceProduttore()); entryEl.appendChild(e); } rootElement.appendChild(entryEl); continue; } ArticoloVarianteCR CRAv = new ArticoloVarianteCR(); CRAv.setId_articolo(rowbean.getId_articolo()); CRAv.setFlgQta(CR.getFlgQta()); CRAv.setQtaDa(CR.getQtaDa()); CRAv.setQtaA(CR.getQtaA()); Vectumerator vecAV = new ArticoloVariante(getApFull()).findByCR(CRAv, 0, 0); while (vecAV.hasMoreElements()) { ArticoloVariante rowAV = (ArticoloVariante)vecAV.nextElement(); numRecord++; org.w3c.dom.Element entryEl = dom.createElement("Offer"); e = dom.createElement("Code"); e.setTextContent(rowAV.getCodiceVariante()); entryEl.appendChild(e); e = dom.createElement("Name"); if (!rowAV.getDescTxtLangScript("nomeMarketplaceV", lang).isEmpty()) { e.setTextContent( rowAV.getDescTxtLangScript("nomeMarketplaceV", lang).replaceAll("€", "€").replace(";", " ")); } else { e.setTextContent(rowAV.getCCNome(lang)); } entryEl.appendChild(e); e = dom.createElement("Description"); if (!rowAV.getDescrizioneMarketplaceV(lang).isEmpty()) { e.setTextContent(rowAV.getDescrizioneMarketplaceV(lang)); } else if (!rowAV.getDescrizioneV(lang).isEmpty()) { e.setTextContent(rowAV.getDescrizioneV(lang)); } else { e.setTextContent(rowAV.getCCNome(lang)); } entryEl.appendChild(e); e = dom.createElement("Link"); e.setTextContent(wwwSite + wwwSite); entryEl.appendChild(e); e = dom.createElement("Image"); e.setTextContent(wwwSite + "/_img/_imgArt/_var/" + wwwSite); entryEl.appendChild(e); for (int i = 2; i <= 10; i++) { if (new File(getDocBase() + "/_img/_imgArt/_var/" + getDocBase()).exists()) { e = dom.createElement("Image" + i); e.setTextContent(wwwSite + "/_img/_imgArt/_var/" + wwwSite); entryEl.appendChild(e); } } e = dom.createElement("Stock"); if (rowAV.getAvail() > 0.0D) { e.setTextContent(String.valueOf((long)rowAV.getAvail())); } else { e.setTextContent("in arrivo"); } entryEl.appendChild(e); boolean gestioneOfferteAttive = false; if (gestioneOfferteAttive) { if (rowAV.isPrezzoBarratoValido()) { e = dom.createElement("OriginalPrice"); e.setTextContent(String.valueOf(rowAV.getPrezzoIvatoBarrato())); entryEl.appendChild(e); e = dom.createElement("Price"); e.setTextContent(String.valueOf(rowAV.getPrezzoPubblicoIva())); entryEl.appendChild(e); } else if (rowbean.getListinoArticoloBase().isOffertaValida()) { e = dom.createElement("OriginalPrice"); e.setTextContent(String.valueOf(rowAV.getPrezzoBaseIva())); entryEl.appendChild(e); e = dom.createElement("Price"); e.setTextContent(String.valueOf(rowAV.getPrezzoPubblicoIva())); entryEl.appendChild(e); } else { e = dom.createElement("Price"); e.setTextContent(String.valueOf(rowAV.getPrezzoPubblicoIva())); entryEl.appendChild(e); } } else { if (rowAV.isPrezzoBarratoValido()) { e = dom.createElement("OriginalPrice"); e.setTextContent(String.valueOf(rowAV.getPrezzoIvatoBarrato())); entryEl.appendChild(e); } e = dom.createElement("Price"); e.setTextContent(String.valueOf(rowAV.getPrezzoPubblicoIva())); entryEl.appendChild(e); } if (rowAV.getTipo().getTrovaprezziCategoria().isEmpty()) { e = dom.createElement("Categories"); e.setTextContent(rowAV.getTipo().getDescrizioneCompletaKeyword("it")); entryEl.appendChild(e); } else { e = dom.createElement("Categories"); e.setTextContent(rowAV.getTipo().getTrovaprezziCategoria()); entryEl.appendChild(e); } e = dom.createElement("Brand"); e.setTextContent(rowAV.getMarca().getDescrizione()); entryEl.appendChild(e); if (!rowbean.getCodiceEan().isEmpty()) { e = dom.createElement("EanCode"); e.setTextContent(rowAV.getCodiceEanAv()); entryEl.appendChild(e); } Nazione nazione = new Nazione(getApFull()); nazione.findByPrimaryKey("I"); e = dom.createElement("ShippingCost"); if (rowAV.getPercentileSpedizione() <= 100L) { e.setTextContent(String.valueOf(conIva(nazione.getCostoSpedizione(), (double)rowbean.getIva().getAliquota()))); } else { DoubleOperator dop = new DoubleOperator(nazione.getCostoSpedizione()); dop.multiply(rowAV.getPercentileSpedizione()); dop.divide(100.0F); dop.setScale(2, 5); e.setTextContent(String.valueOf(conIva(dop.getResult(), (double)rowbean.getIva().getAliquota()))); } entryEl.appendChild(e); } } dom.appendChild(rootElement); Transformer tr = TransformerFactory.newInstance().newTransformer(); tr.setOutputProperty("indent", "yes"); tr.setOutputProperty("method", "xml"); tr.setOutputProperty("encoding", "UTF-8"); tr.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); tr.transform(new DOMSource(dom), new StreamResult(new FileOutputStream(filename))); new File(trovaprezziPermanentFileName).delete(); tr.transform(new DOMSource(dom), new StreamResult(new FileOutputStream(trovaprezziPermanentFileName))); rp.setStatus(true); rp.setReturnObj(trovaprezziFile); rp.setMsg("Generazione file TROVAPREZZI XML " + trovaprezziPermanentFileName + " avvenuta con successo.
Numero Record: " + numRecord); } catch (ParserConfigurationException|javax.xml.transform.TransformerFactoryConfigurationError|java.io.FileNotFoundException|javax.xml.transform.TransformerException pce) { rp.setStatus(false); rp.setMsg("BuildXml: Error trying to instantiate DocumentBuilder " + String.valueOf(pce)); System.out.println(rp.getMsg()); } catch (Exception e2) { rp.setStatus(false); rp.setMsg("BuildXml: Error trying to instantiate DocumentBuilder " + String.valueOf(e2)); System.out.println(rp.getMsg()); } return rp; } public long getFlgTrovaprezzi() { return this.flgTrovaprezzi; } public void setFlgTrovaprezzi(long flgTrovaprezzi) { this.flgTrovaprezzi = flgTrovaprezzi; } public boolean isCostoSpedizionePreventivo(String l_id_nazione) { if (l_id_nazione.isEmpty()) l_id_nazione = "I"; if (getFlgPreventivoWwwArt() == 1L) return true; Nazione nazione = new Nazione(getApFull()); nazione.findByPrimaryKey(l_id_nazione); if (nazione.getId_nazione().isEmpty()) return false; if (nazione.getFlgPreventivoWww() == 1L) return false; return (nazione.getFlgPreventivoWww() == 1L); } public long getFlgIdealo() { return this.flgIdealo; } public void setFlgIdealo(long flgIdealo) { this.flgIdealo = flgIdealo; } public long getFlgTipoSchedaArticoloWww() { return this.flgTipoSchedaArticoloWww; } public static final String getTipoSchedaArticoloWww(long l_getFlgTipoSchedaArticoloWww) { switch ((int)l_getFlgTipoSchedaArticoloWww) { case -1: return ""; case 0: return "Manuale"; case 1: return "ICECAT"; case 2: return "Runner"; case 3: return "Bestit"; } return "??"; } public String getTipoSchedaArticoloWww() { return getTipoSchedaArticoloWww(getFlgTipoSchedaArticoloWww()); } public void setFlgTipoSchedaArticoloWww(long flgTipoSchedaArticoloWww) { this.flgTipoSchedaArticoloWww = flgTipoSchedaArticoloWww; } public ResParm unisciArticoliByCodiceEan() { ResParm rp = new ResParm(); Vectumerator vec = findCodiciEanDuplicati(); if (vec == null || vec.getTotNumberOfRecords() == 0) { rp.appendMsg(" nessun record trovato..."); } else { Articolo art1 = null; while (vec.hasMoreElements()) { Articolo row = (Articolo)vec.nextElement(); if (!row.getCodiceEan().isEmpty()) unisciArticoliByCodiceEan(row.getCodiceEan()); } } return rp; } public ResParm unisciArticoliByCodiceEan(String l_codiceEan) { ResParm rp = new ResParm(); ArticoloCR CR = new ArticoloCR(); CR.setCodiceEan(l_codiceEan); Vectumerator vec = findByCR(CR, 0, 0); if (vec == null || vec.getTotNumberOfRecords() == 0) { rp.appendMsg(" nessun record trovato....... "); } else { ArticoloFornitore af = new ArticoloFornitore(getApFull()); Articolo art1 = null; while (vec.hasMoreElements()) { Articolo row = (Articolo)vec.nextElement(); System.out.println(row.getCodiceEan()); if (!row.getCodiceEan().isEmpty()) if (art1 == null) { art1 = row; } else if (row.getFlgEscludiWebArt() == 0L && art1.getFlgEscludiWebArt() != 0L) { art1 = row; } else if (row.getReadyForWeb().indexOf("it") >= 0 && art1.getReadyForWeb().indexOf("it") < 0) { art1 = row; } System.out.println("art1: " + art1.getCodice()); } vec.moveFirst(); while (vec.hasMoreElements()) { Articolo row = (Articolo)vec.nextElement(); if (row.getId_articolo() != art1.getId_articolo()) rp = art1.unisciArticolo(row, false, false); } rp = af.aggiornaCodiciAlternativiByArticolo(art1, true); } return rp; } public ResParm unisciArticolo(Articolo artDaUnire, boolean aggiornaCodiciAlternativi, boolean aggiornaPrezzi) { ResParm rp = new ResParm(); if (getId_articolo() > 0L) if (artDaUnire.getId_articolo() == getId_articolo()) { rp.setStatus(false); rp.setMsg("Articolo da unire e articolo principale sono lo stesso!!!"); } else { rp = update("UPDATE ARTICOLO_FORNITORE SET id_articolo=" + getId_articolo() + " where id_articolo=" + artDaUnire.getId_articolo()); if (!rp.getStatus()) update("delete from ARTICOLO_FORNITORE WHERE id_articolo=" + artDaUnire.getId_articolo()); rp.append(update("UPDATE RIGA_DOCUMENTO SET id_articolo=" + getId_articolo() + " where id_articolo=" + artDaUnire.getId_articolo())); rp.append(artDaUnire.delete()); if (aggiornaCodiciAlternativi) rp.append(aggiornaCodiciAlternativi(true)); if (aggiornaPrezzi); } return rp; } public ResParm aggiornaCodiciAlternativi(boolean salva) { if (getId_articolo() > 0L) { ArticoloFornitore af = new ArticoloFornitore(getApFull()); return af.aggiornaCodiciAlternativiByArticolo(this, salva); } return new ResParm(false, "Articolo non valido"); } public Vectumerator findCodiciEanDuplicati() { String s_Sql_Find = "select A.* from articolo AS A "; String s_sql_having = " group by A.codiceEan having count(*) >1"; String s_Sql_Order = " order by codiceEan"; Vectumerator vec = null; WcString wc = new WcString(); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString() + s_sql_having); return findRows(stmt); } catch (SQLException e) { handleDebug(e); return AB_EMPTY_VECTUMERATOR; } } public void findByCodiceProduttoreMarca(String l_codiceProduttore, long l_id_marca) { String s_Sql_Find = "select A.* from ARTICOLO AS A"; String s_Sql_Order = ""; WcString wc = new WcString(); wc.addWc("A.codiceProduttore='" + prepareInputMySqlString(l_codiceProduttore, false) + "'"); if (l_id_marca > 0L) wc.addWc("A.id_marca=" + l_id_marca); try { PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString()); findFirstRecord(stmt); } catch (SQLException e) { handleDebug(e); } } public String getSeoTitle(String lang) { if (lang.isEmpty()) lang = "it"; return getDescTxtLang("seoTitle", lang); } public String getMetaDescription(String lang) { if (lang.isEmpty()) lang = "it"; return getDescTxtLang("metaDescription", lang); } public String getNomeSeo() { return (this.nomeSeo == null) ? "" : this.nomeSeo.trim(); } public void setNomeSeo(String nomeSeo) { this.nomeSeo = nomeSeo; } public String getErroriSeo() { return (this.erroriSeo == null) ? "" : this.erroriSeo.trim(); } boolean isSeoOk() { return getErroriSeo().isEmpty(); } public void setErroriSeo(String erroriSeo) { this.erroriSeo = erroriSeo; } public String getCCTagH1Web(String lang) { if (getCCTagH1(lang).isEmpty()) return convertStringToHtml(getCCTagH1Calc(lang)); return convertStringToHtml(getCCTagH1(lang)); } public String getCCTagH2Calc(String lang) { String result = getDescrizioneBreveWeb(lang); if (result.isEmpty()) result = DBAdapter.eliminaDoppioniTokenInStringa(getTipo().getDescrizioneCompletaSpaces(lang), " "); return eliminaDoppioniTokenInStringa(result.replace("/", "/ "), " "); } public String getCCTagH1(String lang) { if (lang.isEmpty()) lang = "it"; return getDescTxtLang("tagH1", lang); } public String getCCTagH2(String lang) { if (lang.isEmpty()) lang = "it"; return getDescTxtLang("tagH2", lang); } public String getCCMetaDescriptionWeb(String lang) { if (!getMetaDescription(lang).isEmpty()) return convertStringToHtml(getMetaDescription(lang)); return convertStringToHtml(getCCMetaDescriptionCalc(lang)); } public String getCCTagH1Calc(String lang) { if ((long)getCCNome(lang).length() <= 70L) return getCCNome(lang); return getCCNome(lang); } public String getCCTagH2Web(String lang) { if (getCCTagH2(lang).isEmpty()) return convertStringToHtml(getCCTagH2Calc(lang)); return convertStringToHtml(getCCTagH2(lang)); } public String getTFMetaDescriptionCalc(String lang) { StringBuilder sb = new StringBuilder(); String modello = getTipo().getMetaDescTemplateLeafWeb(lang); if (!modello.isEmpty()) { sb.append(getMarca().getDescrizione()); sb.append(" "); if (getDescrizioneBreveWeb(lang).isEmpty()) { sb.append(getDescrizioneCompleta(lang)); } else { sb.append(getDescrizioneBreveWeb(lang)); } sb.append(" "); if (!getCodiceProduttore().isEmpty()) { sb.append(" "); sb.append(getCodiceProduttore()); } if (isOffertaValida()) { StringBuilder sb2 = new StringBuilder( modello.replace("#", eliminaDoppioniInStringa(sb.toString()))); sb2.append(". "); sb2.append(translate("Articolo in offerta", lang)); return sb2.toString(); } return modello.replace("#", eliminaDoppioniInStringa(sb.toString())); } sb.append(getDescrizioneCompleta("it")); sb.append(" "); sb.append(getTipo().getDescrizioneCompleta(lang)); if (isOffertaValida()) { sb.append(" "); sb.append(translate("articolo in offerta", lang)); } String result = sb.toString().replace("(", "").replace(")", "").replace("\"", """); return eliminaDoppioniInStringa(result); } public String getTFMetaDescriptionWeb(String lang) { if (!getMetaDescription(lang).isEmpty()) return getMetaDescription(lang); return getTFMetaDescriptionCalc(lang); } public String getTFSeoTitle(String lang) { if (!getSeoTitle(lang).isEmpty()) return getSeoTitle(lang); return getTFSeoTitleCalc(lang); } public String getTFSeoTitleCalc(String lang) { return getCCSeoTitleCalc(lang); } public final ResParm startThreadIcecatAuto(ApplParmFull apFull, ArticoloCR CR) { if (!isThreadCancellazione()) { new ThreadIcecatAuto(apFull, CR); return new ResParm(true, "Thread Icecat auto avviato"); } return new ResParm(false, "ATTENZIONE!! Thread in esecuzione!!!"); } public void creaPreviewH(String sizes, int fotoFinale, String TAG_THREAD_MSG, String statusMsg) { if (!sizes.isEmpty()) { String targetDir = getDocBase() + getDocBase(); StringTokenizer st = new StringTokenizer(sizes, ","); while (st.hasMoreTokens()) { int size = Integer.parseInt(st.nextToken()); for (int j = 1; j <= fotoFinale; j++) { String currentImageName = targetDir + targetDir; if (new File(currentImageName).exists()) { StatusMsg.updateMsgByTag(getApFull(), TAG_THREAD_MSG, statusMsg + " crea preview foto " + statusMsg + " size " + j + " ....."); ScaleImage si = new ScaleImage(currentImageName, "" + size + "H/" + size + "+", 0L, 0, size, false, false); si.scaleIt(); } } } } } public String getDescrizionePerMail(boolean intestazione) { if (intestazione) return "Tipo|Codice|Nome|Pr. Pubblico|Qta.|Vis.|Fornitore"; StringBuilder sb = new StringBuilder(); sb.append(getTipo().getDescrizioneCompletaSpaces("it")); sb.append("
"); sb.append(getCategoriaImport()); sb.append("|"); sb.append(""); sb.append(getCodice()); sb.append(""); sb.append("|"); sb.append(""); sb.append(getNome()); sb.append(""); sb.append("|"); sb.append("Eu "); sb.append(getNf().format(getPrezzoPubblico())); sb.append(" ("); sb.append(getNf().format(getRicaricoEffettivoDaCostoNetto())); sb.append(" %)"); sb.append("|"); sb.append(getQuantita()); sb.append("|"); sb.append(getEscludiWeb()); sb.append("|"); sb.append(getFornitoreCostoNuovo().getCognome()); return sb.toString(); } public String getCCLinkDettaglioCanonicalDefault() { ArticoloCR CR = new ArticoloCR(); CR.setLang("it"); return getWwwAddressParm() + getWwwAddressParm(); } public String getCCSeoTitleCalc2(String lang) { StringBuilder sb = new StringBuilder(); Attivita attivita = Attivita.getDefaultInstance(getApFull()); if (!getTipo().getDescrizioneSeo(lang).isEmpty()) { sb.append(getTipo().getDescrizioneSeo(lang)); } else { sb.append(getTipo().getDescrizioneCompletaSpaces(lang)); } int sbLen = sb.length() + getCCNome(lang).length(); if ((long)sbLen < 60L) { sb.append(" "); sb.append(getCCNome(lang)); if ((long)(sb.length() + attivita.getNomeAttivitaSeo().length()) < 60L) { sb.append(" | "); sb.append(Attivita.getDefaultInstance(getApFull()).getNomeAttivitaSeo()); } } else { sb.append(" "); if (!getCodiceProduttore().isEmpty()) { sb.append(getMarca().getDescrizione()); sb.append(" "); sb.append(getCodiceProduttore()); } else { sb.append(getCCNome(lang)); } if ((long)(sb.length() + attivita.getNomeAttivitaSeo().length()) < 60L) { sb.append(" | "); sb.append(Attivita.getDefaultInstance(getApFull()).getNomeAttivitaSeo()); } } return eliminaDoppioniInStringa(sb.toString()); } public String getTFNome(String lang) { StringBuilder sb = new StringBuilder(); sb.append(getMarca().getDescrizione()); sb.append(" "); if (!getDescrizioneBreve(lang).isEmpty() && getDescrizioneBreve(lang).length() < getNome(lang).length()) { sb.append(getDescrizioneBreve(lang).replace("/", "/ ")); } else { sb.append(getNome(lang).replace("/", "/ ")); } return eliminaDoppioniInStringa(sb.toString()); } public String getTFTagH1Web(String lang) { if (getCCTagH1(lang).isEmpty()) return convertStringToHtml(getTFTagH1Calc(lang)); return convertStringToHtml(getCCTagH1(lang)); } public String getTFTagH1Calc(String lang) { if ((long)getTFNome(lang).length() <= 70L) return getTFNome(lang); return getTFNome(lang); } public Date getDataChiamataIcecat() { return this.dataChiamataIcecat; } public void setDataChiamataIcecat(Date dataChiamataIcecat) { this.dataChiamataIcecat = dataChiamataIcecat; } public long getHashCodeCurrent() { return this.hashCodeCurrent; } public void setHashCodeCurrent(long hashCodeCurrent) { this.hashCodeCurrent = hashCodeCurrent; } public long getHashCodeIndexNow() { return this.hashCodeIndexNow; } public void setHashCodeIndexNow(long hasCodeIndexNow) { this.hashCodeIndexNow = hasCodeIndexNow; } public ResParm sendIndexNowUrl() { ResParm rp = new ResParm(true); if (getId_articolo() == 0L) { rp.setStatus(false); rp.setMsg("Errore! Articolo nullo"); return rp; } if (getFlgEscludiWeb() == 1L || !isReadyForWeb("it")) { rp.setStatus(false); rp.setMsg("Errore! Articolo escluso, non pronto oppure non acquistabile."); return rp; } ArticoloCR CR = new ArticoloCR(); CR.setId_articolo(getId_articolo()); callIndexNow(CR); return rp; } public ResParm callIndexNow(ArticoloCR CR) { boolean debug = false; CR.setTAG_THREAD_MSG("CALL INDEX NOW"); StatusMsg.updateMsgByTag(getApFull(), CR.getTAG_THREAD_MSG(), "...inizio ..."); ResParm rp = new ResParm(); try { DBAdapter.printDebug(debug, "callIndexNow --> "); JSONObject jsonUrls = getIndexNowJson(CR); if (jsonUrls != null) { DBAdapter.printDebug(debug, jsonUrls.toString(4)); CloseableHttpClient client = HttpClients.createDefault(); HttpPost request = new HttpPost("https://www.bing.com/IndexNow"); request.setHeader("Content-Type", "application/json; charset=utf-8"); StringEntity stringEntity = new StringEntity(jsonUrls.toString(4), "UTF-8"); request.setEntity((HttpEntity)stringEntity); CloseableHttpResponse closeableHttpResponse = client.execute((HttpUriRequest)request); String content = EntityUtils.toString(closeableHttpResponse.getEntity()); int statusCode = closeableHttpResponse.getStatusLine().getStatusCode(); DBAdapter.printDebug(debug, "Status Code: " + statusCode); DBAdapter.printDebug(debug, "content = " + content); if (statusCode == 400) { rp.setStatus(false); rp.setMsg("Errore!! Bad request Invalid format!"); } else if (statusCode == 403) { rp.setStatus(false); rp.setMsg("Errore!! Forbidden key not valid !"); } else if (statusCode == 422) { rp.setStatus(false); rp.setMsg("Errore!! Unprocessable Entity URLs don’t belong to the host or the key is not matching the schema in the protocol!"); } else if (statusCode == 429) { rp.setStatus(false); rp.setMsg("Errore!! Too Many Requests!"); } else if (statusCode == 202) { rp.setStatus(true); rp.setMsg("Attenzione!! Accepted, IndexNow Key Validation pending!"); } else if (statusCode == 200) { rp.setStatus(true); rp.setMsg("Accepted, URL submitted!"); } else { rp.setStatus(false); rp.setMsg("ERRORE NON GESTITO: status code:" + statusCode); } } else { rp.setStatus(false); rp.setMsg("Errore!! nessun url da inviare!"); } StatusMsg.deleteMsgByTag(getApFull(), CR.getTAG_THREAD_MSG()); } catch (Exception e) { DBAdapter.printDebug(true, e.getMessage()); e.printStackTrace(); rp.setStatus(false); rp.setMsg(e.getMessage()); } return rp; } private JSONObject getIndexNowJson(ArticoloCR CR) { boolean debug = false; DBAdapter.printDebug(debug, "getIndexNowJson"); Attivita attivita = Attivita.getDefaultInstance(getApFull()); JSONObject jo = new JSONObject(); String host = attivita.getWwwAddress(); host = host.substring(host.indexOf("//") + 2, host.lastIndexOf("/")); jo.put("host", host); jo.put("key", attivita.getIndexNowApiKey()); jo.put("keyLocation", attivita.getIndexNowKeyLocation()); JSONArray urls = new JSONArray(); String l_icecatLang = getParm("LANG_AVAILABLE").getTesto(); if (l_icecatLang.isEmpty()) l_icecatLang = "it"; StringTokenizer st = new StringTokenizer(l_icecatLang, ","); HashSet hsLangs = new HashSet<>(); while (st.hasMoreTokens()) { String lang = st.nextToken(); hsLangs.add(lang); } long numMaxUrls = 100L; if (attivita.getIndexNowDay() == null || getDateDiff(attivita.getIndexNowDay(), getToday()) != 0L) { numMaxUrls = attivita.getIndexNowUrlQuota() / (long)hsLangs.size(); } else { numMaxUrls = (attivita.getIndexNowUrlQuota() - attivita.getIndexNowDayCount()) / (long)hsLangs.size(); } DBAdapter.printDebug(debug, "getIndexNowJson: HLANGSIZE:" + hsLangs.size() + " numMaxUrls=" + numMaxUrls); if (numMaxUrls <= 0L) return null; Vectumerator vec = findByCR(CR, 1, (int)numMaxUrls); int i = 0; while (vec.hasMoreElements()) { Articolo row = (Articolo)vec.nextElement(); if (row.getFlgEscludiWeb() == 0L && row.isReadyForWeb("it")) { for (String lang : hsLangs) { urls.put(row.getCCLinkDettaglioCanonical(lang)); i++; } row.updateHashCodeCurrent(); row.setHashCodeIndexNow(row.getHashCodeCurrent()); row.superSave(); StatusMsg.updateMsgByTag(getApFull(), CR.getTAG_THREAD_MSG(), "aggiunto " + i + " url"); DBAdapter.printDebug(debug, "getIndexNowJson: aggiunto " + i + " url"); } } DBAdapter.printDebug(debug, "getIndexNowJson: tot inviati=" + i); if (i == 0) return null; jo.put("urlList", urls); if (attivita.getIndexNowDay() == null || getDateDiff(attivita.getIndexNowDay(), getToday()) != 0L) { attivita.setIndexNowDayCount((long)i); } else { attivita.setIndexNowDayCount(attivita.getIndexNowDayCount() + (long)i); } attivita.setIndexNowDay(getToday()); attivita.superSave(); return jo; } private void updateHashCodeCurrent() { StringBuilder sb = new StringBuilder(); sb.append(getNome()); sb.append("|"); sb.append(getDescrizioneBreve("it")); sb.append("|"); sb.append(getDescrizioneCommerciale("it")); sb.append("|"); sb.append(getSpecifiche("it")); sb.append("|"); sb.append(getPrezzoBaseIva()); setHashCodeCurrent((long)sb.toString().hashCode()); } public ResParm creaFileXmlGoogle(ArticoloCR CR, boolean updateFeed, boolean isIdealo) { String TAG_THREAD_MSG = "GOOGLE MERCHANT CREAZIONE FILE "; boolean exportGtin = false; StatusMsg.updateMsgByTag(getApFull(), TAG_THREAD_MSG, "creazione file xml...."); boolean soloLink = false; int numRecord = 0; ResParm rp = new ResParm(true); String tagIdealo = ""; Attivita attivita = Attivita.getDefaultInstance(getApFull()); if (isIdealo) { updateFeed = false; tagIdealo = "," + attivita.getIdealoTag() + ","; } String googleFile = "google_" + System.currentTimeMillis() + ".xml"; String filename = getDocBase() + getDocBase() + getParm("PATH_TMP").getTesto(); String googlePermanentFileName = getDocBase() + "_feed/" + getDocBase(); File xmlFile = new File(filename); String theDir = xmlFile.getAbsolutePath().substring(0, xmlFile.getAbsolutePath().lastIndexOf(File.separator) + 1); File theDirFile = new File(theDir); if (!theDirFile.exists()) theDirFile.mkdirs(); new File(filename).delete(); File theDirFileGoogle = new File(getDocBase() + "_feed/"); if (!theDirFileGoogle.exists()) theDirFileGoogle.mkdirs(); org.w3c.dom.Element e = null; if (isIdealo) { CR.setFlgIdealo(1L); } else { CR.setFlgGoogle(3L); } CR.setFlgReadyForWeb(1L); CR.setFlgEscludiWeb(0L); if (CR.getPrezzoDa() == 0.0D) CR.setPrezzoDa(attivita.getPGooglePrezzoPubblicoMinimoXExport()); if (CR.getQtaDa() == 0L && attivita.getPGoogleQtaMinimaXExport() > 0L) { CR.setQtaDa(attivita.getPGoogleQtaMinimaXExport()); CR.setFlgQta(1L); } Vectumerator vec = findByCR(CR, 0, 0); String title = getParm("TITLE").getTesto(); String site = getParm("P_WWW_ADDRESS").getTesto(); String lang = CR.getLang(); if (lang.isEmpty()) { lang = "it"; CR.setLang(lang); } NumberFormat nf2 = NumberFormat.getInstance(Locale.US); nf2.setMaximumFractionDigits(2); nf2.setMinimumFractionDigits(2); String wwwSite = getWwwAddressParm(); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); try { DocumentBuilder db = dbf.newDocumentBuilder(); org.w3c.dom.Document dom = db.newDocument(); org.w3c.dom.Element rootElement = dom.createElement("feed"); rootElement.setAttribute("xmlns", "http://www.w3.org/2005/Atom"); rootElement.setAttribute("xmlns:g", "http://base.google.com/ns/1.0"); org.w3c.dom.Element titleEl = dom.createElement("title"); titleEl.setTextContent(title); rootElement.appendChild(titleEl); org.w3c.dom.Element linkEl = dom.createElement("link"); linkEl.setAttribute("rel", "self"); linkEl.setAttribute("href", site); rootElement.appendChild(linkEl); org.w3c.dom.Element updatedEl = dom.createElement("updated"); updatedEl.setTextContent(getTimestamp().toString()); rootElement.appendChild(updatedEl); int currentRecord = 0; while (vec.hasMoreElements()) { currentRecord++; StatusMsg.updateMsgByTag(getApFull(), TAG_THREAD_MSG, "creazione file xml...." + currentRecord + " su " + vec.getTotNumberOfRecords()); Articolo rowbean = (Articolo)vec.nextElement(); if (rowbean.getFlgUsaVarianti() == 0L) { String temp, dispo, condition; numRecord++; org.w3c.dom.Element entryEl = dom.createElement("entry"); e = dom.createElement("g:id"); e.setTextContent(rowbean.getCodice()); entryEl.appendChild(e); e = dom.createElement("g:title"); if (!rowbean.getDescTxtLangScript("nomeMarketplace", lang).isEmpty()) { temp = rowbean.getDescTxtLangScript("nomeMarketplace", lang).replaceAll("€", "€").replace(";", " "); } else { temp = rowbean.getCCNome(lang); } e.setTextContent(convertTo1stCap(temp)); entryEl.appendChild(e); if (rowbean.getFlgGoogle() == 1L) { e = dom.createElement("g:excluded_destination"); e.setTextContent("Shopping_ads"); entryEl.appendChild(e); } e = dom.createElement("g:description"); if (!rowbean.getDescrizioneMarketplace(lang).isEmpty()) { e.setTextContent(rowbean.getDescrizioneMarketplace(lang)); } else if (!rowbean.getDescrizioneBreve(lang).isEmpty()) { e.setTextContent(rowbean.getDescrizioneBreve(lang)); } else { e.setTextContent(rowbean.getNome(lang)); } entryEl.appendChild(e); if (soloLink) { e = dom.createElement("g:link"); e.setTextContent(wwwSite + wwwSite); entryEl.appendChild(e); } else { e = dom.createElement("g:link"); e.setTextContent(wwwSite + wwwSite + "?utm_source=google_shopping&utm_medium=organic"); entryEl.appendChild(e); e = dom.createElement("g:ads_redirect"); e.setTextContent(wwwSite + wwwSite); entryEl.appendChild(e); } e = dom.createElement("g:image_link"); e.setTextContent(wwwSite + wwwSite + rowbean.getPathImg()); entryEl.appendChild(e); for (int i = 2; i <= 10; i++) { if (new File(getDocBase() + getDocBase() + getPathImg()).exists()) { e = dom.createElement("g:additional_image_link"); e.setTextContent(wwwSite + wwwSite + rowbean.getPathImg()); entryEl.appendChild(e); } } e = dom.createElement("g:availability"); switch (rowbean.getDispoLevel()) { case 0: dispo = "out of stock"; break; case 1: dispo = "in stock"; break; case 2: dispo = "in stock"; break; default: dispo = ""; break; } e.setTextContent(dispo); entryEl.appendChild(e); boolean gestioneOfferteAttive = false; if (gestioneOfferteAttive) { if (rowbean.isOffertaValida()) { e = dom.createElement("g:price"); e.setTextContent(nf2.format(rowbean.getPrezzoBaseIva()) + " EUR"); entryEl.appendChild(e); e = dom.createElement("g:sale_price"); e.setTextContent(nf2.format(rowbean.getPrezzoPubblicoIva()) + " EUR"); entryEl.appendChild(e); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); } else if (rowbean.isPrezzoBarratoValido()) { e = dom.createElement("g:price"); e.setTextContent(nf2.format(rowbean.getPrezzoIvatoBarrato()) + " EUR"); entryEl.appendChild(e); e = dom.createElement("g:sale_price"); e.setTextContent(nf2.format(rowbean.getPrezzoPubblicoIva()) + " EUR"); entryEl.appendChild(e); } else { e = dom.createElement("g:price"); e.setTextContent(nf2.format(rowbean.getPrezzoPubblicoIva()) + " EUR"); entryEl.appendChild(e); } } else { e = dom.createElement("g:price"); e.setTextContent(nf2.format(rowbean.getPrezzoPubblicoIva()) + " EUR"); entryEl.appendChild(e); } if (rowbean.getTipo().getId_googleCategory() != 0L) { e = dom.createElement("g:google_product_category"); e.setTextContent(String.valueOf(rowbean.getTipo().getGoogleCategory().getCodice())); entryEl.appendChild(e); } e = dom.createElement("g:product_type"); e.setTextContent(rowbean.getTipo().getDescrizioneCompletaGreater(lang)); entryEl.appendChild(e); e = dom.createElement("g:brand"); e.setTextContent(rowbean.getMarca().getDescrizione()); entryEl.appendChild(e); if (!rowbean.getCodiceProduttore().isEmpty()) { e = dom.createElement("g:mpn"); e.setTextContent(rowbean.getCodiceProduttore()); entryEl.appendChild(e); } if (!rowbean.getCodiceEan().isEmpty() && exportGtin) { e = dom.createElement("g:gtin"); e.setTextContent(rowbean.getCodiceEan()); entryEl.appendChild(e); } else { e = dom.createElement("g:identifier_exists"); e.setTextContent("no"); entryEl.appendChild(e); } if (rowbean.getStatoUsato().isNuovo()) { condition = "new"; } else { condition = "used"; } e = dom.createElement("g:condition"); e.setTextContent(condition); entryEl.appendChild(e); if (!rowbean.getTagArticolo().isEmpty()) { StringTokenizer st = new StringTokenizer(rowbean.getTagArticolo(), ","); int j = 0; while (st.hasMoreTokens() && j <= 4) { String token = st.nextToken().trim().toLowerCase(); if (!token.isEmpty()) { e = dom.createElement("g:custom_label_" + j); e.setTextContent(token); entryEl.appendChild(e); j++; } } } Nazione nazione = new Nazione(getApFull()); Vectumerator vecNaz = nazione.findAllAttiveGoogle(lang); while (vecNaz.hasMoreElements()) { Nazione rowNaz = (Nazione)vecNaz.nextElement(); if ((isIdealo && rowNaz.getTag().toLowerCase().indexOf(tagIdealo) >= 0) || !isIdealo) { org.w3c.dom.Element shippingEl = dom.createElement("g:shipping"); e = dom.createElement("g:country"); e.setTextContent(rowNaz.getCodice()); shippingEl.appendChild(e); e = dom.createElement("g:price"); if (rowbean.getPercentileSpedizione() <= 100L) { e.setTextContent(nf2.format(conIva(rowNaz.getCostoSpedizione(), (double)rowbean.getIva().getAliquota())) + " EUR"); } else { DoubleOperator dop = new DoubleOperator(rowNaz.getCostoSpedizione()); dop.multiply(rowbean.getPercentileSpedizione()); dop.divide(100.0F); dop.setScale(2, 5); e.setTextContent(nf2.format(conIva(dop.getResult(), (double)rowbean.getIva().getAliquota())) + " EUR"); } shippingEl.appendChild(e); entryEl.appendChild(shippingEl); } } rootElement.appendChild(entryEl); } else { ArticoloVarianteCR CRAv = new ArticoloVarianteCR(); CRAv.setId_articolo(rowbean.getId_articolo()); CRAv.setFlgQta(CR.getFlgQta()); CRAv.setQtaDa(CR.getQtaDa()); CRAv.setQtaA(CR.getQtaA()); Vectumerator vecAV = new ArticoloVariante(getApFull()).findByCR(CRAv, 0, 0); while (vecAV.hasMoreElements()) { String dispo, condition; ArticoloVariante rowAV = (ArticoloVariante)vecAV.nextElement(); numRecord++; org.w3c.dom.Element entryEl = dom.createElement("entry"); e = dom.createElement("g:id"); e.setTextContent(rowAV.getCodiceVariante()); entryEl.appendChild(e); e = dom.createElement("g:title"); if (!rowAV.getDescTxtLangScript("nomeMarketplaceV", lang).isEmpty()) { e.setTextContent( rowAV.getDescTxtLangScript("nomeMarketplaceV", lang).replaceAll("€", "€").replace(";", " ")); } else { e.setTextContent(rowAV.getCCNome(lang)); } entryEl.appendChild(e); if (rowAV.getArticolo().getFlgGoogle() == 1L) { e = dom.createElement("g:excluded_destination"); e.setTextContent("Shopping_ads"); entryEl.appendChild(e); } e = dom.createElement("g:description"); if (!rowAV.getDescrizioneMarketplaceV(lang).isEmpty()) { e.setTextContent(rowAV.getDescrizioneMarketplaceV(lang)); } else if (!rowAV.getDescrizioneV(lang).isEmpty()) { e.setTextContent(rowAV.getDescrizioneV(lang)); } else { e.setTextContent(rowAV.getCCNome(lang)); } entryEl.appendChild(e); if (soloLink) { e = dom.createElement("g:link"); e.setTextContent(wwwSite + wwwSite); entryEl.appendChild(e); } else { e = dom.createElement("g:link"); e.setTextContent(wwwSite + wwwSite + "?utm_source=google_shopping&utm_medium=organic"); entryEl.appendChild(e); e = dom.createElement("g:ads_redirect"); e.setTextContent(wwwSite + wwwSite); entryEl.appendChild(e); } e = dom.createElement("g:image_link"); e.setTextContent(wwwSite + wwwSite + rowAV.getPathImg()); entryEl.appendChild(e); for (int i = 2; i <= 10; i++) { if (new File(getDocBase() + getDocBase() + rowAV.getPathImg()).exists()) { e = dom.createElement("g:additional_image_link"); e.setTextContent(wwwSite + wwwSite + rowAV.getPathImg()); entryEl.appendChild(e); } } e = dom.createElement("g:availability"); switch (rowAV.getDispoLevel()) { case 0: dispo = "out of stock"; break; case 1: dispo = "in stock"; break; case 2: dispo = "in stock"; break; default: dispo = ""; break; } e.setTextContent(dispo); entryEl.appendChild(e); boolean gestioneOfferteAttive = false; if (gestioneOfferteAttive) { if (rowAV.isOffertaValida()) { e = dom.createElement("g:price"); e.setTextContent(nf2.format(rowAV.getPrezzoBaseIva()) + " EUR"); entryEl.appendChild(e); e = dom.createElement("g:sale_price"); e.setTextContent(nf2.format(rowAV.getPrezzoPubblicoIva()) + " EUR"); entryEl.appendChild(e); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); } else if (rowAV.isPrezzoBarratoValido()) { e = dom.createElement("g:price"); e.setTextContent(nf2.format(rowAV.getPrezzoIvatoBarrato()) + " EUR"); entryEl.appendChild(e); e = dom.createElement("g:sale_price"); e.setTextContent(nf2.format(rowAV.getPrezzoPubblicoIva()) + " EUR"); entryEl.appendChild(e); } else { e = dom.createElement("g:price"); e.setTextContent(nf2.format(rowAV.getPrezzoPubblicoIva()) + " EUR"); entryEl.appendChild(e); } } else { e = dom.createElement("g:price"); e.setTextContent(nf2.format(rowAV.getPrezzoPubblicoIva()) + " EUR"); entryEl.appendChild(e); } if (rowAV.getTipo().getId_googleCategory() != 0L) { e = dom.createElement("g:google_product_category"); e.setTextContent(String.valueOf(rowAV.getTipo().getGoogleCategory().getCodice())); entryEl.appendChild(e); } e = dom.createElement("g:product_type"); e.setTextContent(rowAV.getTipo().getDescrizioneCompletaGreater(lang)); entryEl.appendChild(e); e = dom.createElement("g:brand"); e.setTextContent(rowAV.getMarca().getDescrizione()); entryEl.appendChild(e); if (!rowAV.getCodiceEanAv().isEmpty() && exportGtin) { e = dom.createElement("g:gtin"); e.setTextContent(rowAV.getCodiceEanAv()); entryEl.appendChild(e); } else { e = dom.createElement("g:identifier_exists"); e.setTextContent("no"); entryEl.appendChild(e); } if (rowbean.getFlgStockOfferte() == 3L) { condition = "used"; } else { condition = "new"; } e = dom.createElement("g:condition"); e.setTextContent(condition); entryEl.appendChild(e); if (!rowbean.getTagArticolo().isEmpty()) { StringTokenizer st = new StringTokenizer(rowbean.getTagArticolo(), ","); int j = 0; while (st.hasMoreTokens() && j <= 4) { String token = st.nextToken().trim().toLowerCase(); if (!token.isEmpty()) { e = dom.createElement("g:custom_label_​" + j); e.setTextContent(token); entryEl.appendChild(e); j++; } } } Nazione nazione = new Nazione(getApFull()); Vectumerator vecNaz = nazione.findAllAttiveGoogle(lang); while (vecNaz.hasMoreElements()) { org.w3c.dom.Element shippingEl = dom.createElement("g:shipping"); Nazione rowNaz = (Nazione)vecNaz.nextElement(); e = dom.createElement("g:country"); e.setTextContent(rowNaz.getCodice()); shippingEl.appendChild(e); e = dom.createElement("g:price"); if (rowbean.getPercentileSpedizione() <= 100L) { e.setTextContent(nf2.format(conIva(rowNaz.getCostoSpedizione(), (double)rowbean.getIva().getAliquota())) + " EUR"); } else { DoubleOperator dop = new DoubleOperator(rowNaz.getCostoSpedizione()); dop.multiply(rowbean.getPercentileSpedizione()); dop.divide(100.0F); dop.setScale(2, 5); e.setTextContent(nf2.format(conIva(dop.getResult(), (double)rowbean.getIva().getAliquota())) + " EUR"); } shippingEl.appendChild(e); entryEl.appendChild(shippingEl); } rootElement.appendChild(entryEl); } } if (updateFeed && !CR.getFileNameGoogle().isEmpty()) { rowbean.setGoogleFeedFileName(CR.getFileNameGoogle()); rowbean.superSave(); } } dom.appendChild(rootElement); Transformer tr = TransformerFactory.newInstance().newTransformer(); tr.setOutputProperty("indent", "yes"); tr.setOutputProperty("method", "xml"); tr.setOutputProperty("encoding", "UTF-8"); tr.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); tr.transform(new DOMSource(dom), new StreamResult(new FileOutputStream(filename))); new File(googlePermanentFileName).delete(); if (!isIdealo && !CR.getFileNameGoogle().isEmpty()) tr.transform(new DOMSource(dom), new StreamResult(new FileOutputStream(googlePermanentFileName))); rp.setStatus(true); rp.setReturnObj(googleFile); if (isIdealo) { rp.setMsg("Generazione file IDEALO XML tmp " + filename + " avvenuta con successo.
Numero Record: " + numRecord); } else { rp.setMsg("Generazione file GOOGLE XML " + googlePermanentFileName + " avvenuta con successo.
Numero Record: " + numRecord); } } catch (ParserConfigurationException|javax.xml.transform.TransformerFactoryConfigurationError|java.io.FileNotFoundException|javax.xml.transform.TransformerException pce) { rp.setStatus(false); rp.setMsg("BuildXml: Error trying to instantiate DocumentBuilder " + String.valueOf(pce)); System.out.println(rp.getMsg()); } catch (Exception e2) { rp.setStatus(false); rp.setMsg("BuildXml: Error trying to instantiate DocumentBuilder " + String.valueOf(e2)); System.out.println(rp.getMsg()); } StatusMsg.deleteMsgByTag(getApFull(), TAG_THREAD_MSG); return rp; } private String getRecordMicrosoftMerchant(String lang, ArticoloCR CR) { String temp2, dispo; StringBuilder temp = new StringBuilder(); String sep = "/t"; temp.append(getCodice()); temp.append(sep); if (!getDescTxtLangScript("nomeMarketplace", lang).isEmpty()) { temp2 = getDescTxtLangScript("nomeMarketplace", lang).replaceAll("€", "€").replace(";", " "); } else { temp2 = getCCNome(lang); } temp.append(convertTo1stCap(temp2)); temp.append(sep); temp.append(""); temp.append(sep); temp.append(getWwwAddressParm() + getWwwAddressParm()); temp.append(sep); temp.append(""); temp.append(sep); if (!getDescrizioneMarketplace(lang).isEmpty()) { temp2 = getDescrizioneMarketplace(lang); } else if (!getDescrizioneBreve(lang).isEmpty()) { temp2 = getDescrizioneBreve(lang); } else { temp2 = getNome(lang); } temp.append(temp2); temp.append(sep); temp.append(getWwwAddressParm() + getWwwAddressParm() + getPathImg()); temp.append(sep); temp.append(""); temp.append(sep); temp.append(""); temp.append(sep); switch (getDispoLevel()) { case 0: dispo = "out of stock"; break; case 1: dispo = "in stock"; break; case 2: dispo = "in stock"; break; default: dispo = ""; break; } temp.append(dispo); temp.append(sep); temp.append(""); temp.append(sep); temp.append(""); temp.append(sep); temp.append(""); temp.append(sep); temp.append(""); temp.append(sep); temp.append(""); temp.append(sep); temp.append(""); temp.append(sep); temp.append(""); temp.append(sep); temp.append(""); temp.append(sep); temp.append(""); temp.append(sep); temp.append(""); temp.append(sep); temp.append(""); temp.append(sep); temp.append(getPrezzoPubblicoIva()); temp.append(sep); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); temp.append(df.format(getDataCambiamentoPrezzo())); temp.append(sep); return temp.toString(); } public static ResParm clearImg(Articolo bean) { boolean debug = false; ResParm rp = new ResParm(true); StringBuilder sb = new StringBuilder(); int totFile = 0, nonCancellati = 0, cancellati = 0, totSpostati = 0; ArticoloVariante av = new ArticoloVariante(bean.getApFull()); String pathImgArt = bean.getParm("PATH_IMG_ART").getTesto(); sb.append("----------------- clearImg -----------------"); sb.append("\n"); boolean isVariante = false; File directory = new File(bean.getDocBase() + bean.getDocBase()); System.out.println("clearImg: start cleaning: " + directory.getName()); if (directory.isDirectory()) { URI base = directory.toURI(); Deque queue = new LinkedList<>(); queue.push(directory); try { while (!queue.isEmpty()) { directory = queue.pop(); if (directory.getAbsolutePath().indexOf(av.getPathImg()) >= 0) { isVariante = true; } else { isVariante = false; } for (File kid : directory.listFiles()) { String name = base.relativize(kid.toURI()).getPath(); if (kid.isDirectory()) { queue.push(kid); } else { totFile++; if (debug) System.out.print("" + totFile + " " + totFile + " " + cancellati + " - clearImg: checking file " + nonCancellati + ( isVariante ? "variante " : "")); sb.append("" + totFile + " " + totFile + " " + cancellati + " - checking file " + nonCancellati + ( isVariante ? "variante " : "")); String fileName = kid.getName(); String[] tokens = kid.getName().split("_"); if (tokens.length >= 3) { long currentid; String currentTs = tokens[1]; String tempId = tokens[0]; if (tempId.lastIndexOf("+") >= 0) { currentid = Long.valueOf(tokens[0].substring(tempId.lastIndexOf("+") + 1)); } else { currentid = Long.valueOf(tokens[0]); } if (!isVariante) { bean.findByPrimaryKey(currentid); if (bean.getId_articolo() == 0L || !bean.getImgTmst().equals(currentTs)) { if (debug) System.out.print(" DA CANCELLARE!!!"); sb.append(" CANCELLATO!!"); new File(kid.getCanonicalPath()).delete(); cancellati++; } else { nonCancellati++; if (kid.getCanonicalPath().indexOf(bean.getPathImg()) < 0) { totSpostati++; String newImage = kid.getCanonicalPath().replace(pathImgArt, bean.getPathImg()); System.out.println("" + totFile + " " + totFile + " sposto " + totSpostati + " su\n" + kid.getCanonicalPath()); sb.append("\n"); sb.append(" ---> sposto " + kid.getCanonicalPath() + " su\n" + newImage); File targetDir = new File(newImage.substring(0, newImage.lastIndexOf(File.separator))); if (!targetDir.exists()) targetDir.mkdirs(); new File(kid.getCanonicalPath()).renameTo(new File(newImage)); } } } } else { sb.append("************** FILE NON GESTIBILE " + (isVariante ? "variante " : "") + kid.getCanonicalPath()); } if (debug) System.out.println(); sb.append("\n"); } } } } catch (Exception e) { rp.setStatus(false); sb.append("Errore!!! "); sb.append("\n"); sb.append(e.getMessage()); sb.append("\n"); rp.setException(e); e.printStackTrace(); } } sb.append("\n"); sb.append("TOTALI CANCELLATI: " + cancellati); sb.append("\n"); sb.append("TOTALI NON CANCELLATI: " + nonCancellati); sb.append("\n"); sb.append("TOTALI SPOSTATI: " + totSpostati); rp.setMsg(sb.toString()); return rp; } public String getPathIdStepDir() { if (getPathIdStep() <= 0L) return ""; if (getId_articolo() == 0L) System.out.println("pio"); return "_" + getPathIdStep() * (getId_articolo() / getPathIdStep() + 1L) + "/"; } public long getId_magFisico() { return this.id_magFisico; } public MagFisico getMagFisico() { this.magFisico = (MagFisico)getSecondaryObject(this.magFisico, MagFisico.class, getId_magFisico()); return this.magFisico; } public void setId_magFisico(long id_magFisico) { this.id_magFisico = id_magFisico; setMagFisico(null); } public void setMagFisico(MagFisico magFisico) { this.magFisico = magFisico; } public void creaFileCvsAmazonPrezzoQuantita(ArticoloCR CR) { try { Vectumerator list = findByCR(CR, 0, 0); CR.setFileName( getPathTmp() + "exportArticoliAmazonPrezzoQuantita_" + getPathTmp() + "_" + getTimeNameForFileUpload() + ".csv"); String theCvsFile = getDocBase() + getDocBase(); NumberFormat nf = NumberFormat.getNumberInstance(Locale.ITALIAN); DecimalFormat df = (DecimalFormat)nf; df.applyPattern("###.##"); String SEP = "\t"; new File(theCvsFile).delete(); FileWr outCvsFile = new FileWr(theCvsFile, false); String s1 = "sku\tprice\tminimum-seller-allowed-price\tmaximum-seller-allowed-price\tquantity\tfulfillment-channel\thandling-time\tminimum_order_quantity_minimum"; outCvsFile.writeLine(s1); while (list.hasMoreElements()) { Articolo row = (Articolo)list.nextElement(); s1 = row.getCodiceEanNoZero() + row.getCodiceEanNoZero() + SEP + df.format(row.getPrezzoArticoloAmazonIvaExport("it", 1L)) + SEP + SEP + SEP + (long)row.getQuantita() + SEP + "3"; outCvsFile.writeLine(s1); } outCvsFile.closeFile(); } catch (Exception e) { handleDebug(e); } } public void creaFileCvsAmazon(ArticoloCR CR) { try { Vectumerator list = findByCR(CR, 0, 0); CR.setFileName(getPathTmp() + "exportArticoliAmazon_" + getPathTmp() + "_" + getTimeNameForFileUpload() + ".csv"); String theCvsFile = getDocBase() + getDocBase(); String SEP = "|"; new File(theCvsFile).delete(); FileWr outCvsFile = new FileWr(theCvsFile, false); String s1 = "Codice" + SEP + "EAN" + SEP + "Titolo" + SEP + "PrezzoPubblico" + SEP + "Dispo"; outCvsFile.writeLine(s1); while (list.hasMoreElements()) { Articolo row = (Articolo)list.nextElement(); s1 = row.getCodice() + row.getCodice() + SEP + row.getCodiceEan() + SEP + row.getCCTagH1Web(CR.getLang()) + SEP + row.getPrezzoArticoloAmazonIva().getPrezzoFinale() + SEP + getNf0().format(row.getQuantita()) + SEP + row.getMarca().getDescrizione() + SEP; outCvsFile.writeLine(s1); } outCvsFile.closeFile(); } catch (Exception e) { handleDebug(e); } } public double getPrezzoSuAmzIva() { return this.prezzoSuAmzIva; } public void setPrezzoSuAmzIva(double prezzoSuAmzIva) { this.prezzoSuAmzIva = prezzoSuAmzIva; } public long getQtaSuAmz() { return this.qtaSuAmz; } public void setQtaSuAmz(long qtaSuAmz) { this.qtaSuAmz = qtaSuAmz; } public String getProductTypeAmz() { return (this.productTypeAmz == null) ? "" : this.productTypeAmz.trim(); } public void setProductTypeAmz(String productTypeAmz) { this.productTypeAmz = productTypeAmz; } public String getAsinAmz() { return (this.asinAmz == null) ? "" : this.asinAmz.trim(); } public void setAsinAmz(String asinAmz) { this.asinAmz = asinAmz; } public long getFlgPriceTypeAmz() { return this.flgPriceTypeAmz; } public void setFlgPriceTypeAmz(long flgPriceTypeAmz) { this.flgPriceTypeAmz = flgPriceTypeAmz; } public String getDescAmz() { return (this.descAmz == null) ? "" : this.descAmz.trim(); } public void setDescAmz(String descAmz) { this.descAmz = descAmz; } public long getFlgAmzWarn() { return this.flgAmzWarn; } public void setFlgAmzWarn(long flgAmzWarn) { this.flgAmzWarn = flgAmzWarn; } public final ResParm startThreadUpdateOfferAmz(ApplParmFull apFull, ArticoloCR CR, long flgPriceTypeAmz) { if (!isThreadUpdateOfferAmz()) { new ThreadUpdOfferAmz(this, apFull, CR, flgPriceTypeAmz); return new ResParm(true, "Thread update offer amz avviato"); } return new ResParm(false, "ATTENZIONE!! Thread in esecuzione!!!"); } public String getAmzPrezziFoepDesc(String currentLang) { StringBuilder sb = new StringBuilder(); AmzFeaturedPrice afp = new AmzFeaturedPrice(getApFull()); afp.findByArticoloLang(this, currentLang); if (afp.getId_amzFeaturedPrice() > 0L) { sb.append("
"); sb.append("Foep:"); sb.append(getNf().format(afp.getFeaturedOEPriceAmz())); sb.append("
"); sb.append("Cofop:"); sb.append(getNf().format(afp.getCompetingFOPriceAmz())); sb.append("
"); sb.append("Cufop:"); sb.append(getNf().format(afp.getCurrentFOPriceAmz())); sb.append("
"); DoubleOperator l_prezzoPubblico = new DoubleOperator(getPrezzoPubblicoIva()); l_prezzoPubblico.setScale(2, 5); l_prezzoPubblico.add(getDeliveryCost(currentLang)); if (afp.isMyPriceBetter(l_prezzoPubblico.getResult())) { sb.append("   "); } else { sb.append("   "); } if (afp.isMyPriceBetter(getPrezzoArticoloAmazonSpedIva("it", true, 1L))) { sb.append(""); } else { sb.append(""); } } return sb.toString(); } public String getAmzPrezziFoepDesc() { return getAmzPrezziFoepDesc(getCurrentLang()); } public String getAmzPrezziFoepDescInline(String currentLang) { return getAmzPrezziFoepDesc(currentLang).replace("
", " "); } public String getAmzPrezziFoepDescInline() { return getAmzPrezziFoepDesc(getCurrentLang()).replace("
", " "); } public ResParm amzPostItemsOffersBatch(ArticoloCR CR, String currentLang) { ResParm rp = new ResParm(); Attivita attivita = Attivita.getDefaultInstance(getApFull()); CR.setFlgAsinAmzNull(1L); Vectumerator vec = findByCR(CR, 0, 0); while (vec.hasMoreElements()) { Articolo row = (Articolo)vec.nextElement(); rp = row.amzCatalogItem(); if (!rp.getStatus()) System.out.println("amzPostItemsOffersBatch amzCatalogItem: " + rp.getErrMsg()); } CR.setFlgAsinAmzNull(0L); vec = findByCR(CR, 1, 1); if (vec.getTotNumberOfRecords() > 0) { AmzSellerApi asa = new AmzSellerApi(attivita); AmzResult aRes = asa.amzPostItemsOffersBatch(CR, currentLang); if (aRes.isOk()) { rp.setStatus(true); rp.setMsg(aRes.getMsg()); } else { rp.setStatus(false); rp.setMsg("Errore! " + aRes.getMsg()); } } else { rp.setStatus(false); rp.setMsg("Errore! non ci sono articoli con asin impostati!"); } return rp; } public String getPathImg() { return getParm("PATH_IMG_ART").getTesto() + getParm("PATH_IMG_ART").getTesto(); } public static boolean isThreadUpdateOfferAmz() { return threadUpdateOfferAmz; } public static boolean isThreadPostItemOfferAmz() { return threadPostItemOfferAmz; } public Articolo() {} }