www in docker support
This commit is contained in:
parent
539a848e95
commit
c227fce036
2145 changed files with 399596 additions and 58 deletions
|
|
@ -0,0 +1,281 @@
|
|||
package it.acxent.cc;
|
||||
|
||||
import it.acxent.anag.ListinoArticolo;
|
||||
import it.acxent.art.Articolo;
|
||||
import it.acxent.art.ArticoloCR;
|
||||
import it.acxent.art.Marca;
|
||||
import it.acxent.art.Vetrina;
|
||||
import it.acxent.common.StatusMsg;
|
||||
import it.acxent.db.ApplParmFull;
|
||||
import it.acxent.db.DBAdapter;
|
||||
import it.acxent.db.ResParm;
|
||||
import it.acxent.db.WcString;
|
||||
import it.acxent.util.Timer;
|
||||
import it.acxent.util.Vectumerator;
|
||||
import java.sql.Date;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ArticoloAutoOfferte {
|
||||
private static boolean threadAutoOfferte = false;
|
||||
|
||||
private long nArticoliAO = 30L;
|
||||
|
||||
private long nGiorniAO = 3L;
|
||||
|
||||
private long id_vetrinaAO;
|
||||
|
||||
private double prezzoDaAO;
|
||||
|
||||
private long giacenzaMinimaAO = 10L;
|
||||
|
||||
private double percScontoOffertaAO;
|
||||
|
||||
private ApplParmFull apFull;
|
||||
|
||||
class ThreadAutoOfferte extends Thread {
|
||||
private ApplParmFull apFull;
|
||||
|
||||
private boolean sendEmail;
|
||||
|
||||
private final String TAG_THREAD_MSG = "AUTO OFFERTE ";
|
||||
|
||||
public ThreadAutoOfferte(ApplParmFull apFull, boolean sendEmail) {
|
||||
this.apFull = apFull;
|
||||
this.sendEmail = sendEmail;
|
||||
if (!ArticoloAutoOfferte.isThreadAttivo()) {
|
||||
ArticoloAutoOfferte.threadAutoOfferte = true;
|
||||
start();
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
boolean debug = false;
|
||||
Timer timer = new Timer();
|
||||
timer.start();
|
||||
StatusMsg.updateMsgByTag(ArticoloAutoOfferte.this.getApFull(), "AUTO OFFERTE ", "...inizio ...");
|
||||
ResParm rp = new ResParm(true);
|
||||
int i = 1;
|
||||
int se1 = 10;
|
||||
int se2 = 100;
|
||||
ArticoloCR CR = new ArticoloCR();
|
||||
Articolo bean = new Articolo(this.apFull);
|
||||
Vetrina vetrina = new Vetrina(this.apFull);
|
||||
vetrina.findByPrimaryKey(ArticoloAutoOfferte.this.getId_vetrinaAO());
|
||||
if (vetrina.getId_vetrina() == 0L) {
|
||||
rp.setMsg("ERRORE! vetrina non definito..");
|
||||
rp.setStatus(false);
|
||||
} else {
|
||||
if (ArticoloAutoOfferte.this.getPercScontoOffertaAO() > 0.0D) {
|
||||
String sqlUpdate = "update ARTICOLO as A set id_vetrina=null";
|
||||
String today = DBAdapter.getToday().toString();
|
||||
WcString updateCR = new WcString();
|
||||
updateCR.addWc("id_vetrina=" + ArticoloAutoOfferte.this.getId_vetrinaAO());
|
||||
updateCR.addWc("(A.dataScadenzaOfferta<'" + today + "' or A.dataScadenzaOffertaFornitore<'" + today + "' OR (A.dataScadenzaOfferta is null and A.dataScadenzaOffertaFornitore is null) )");
|
||||
bean.update(sqlUpdate + sqlUpdate);
|
||||
CR.setFlgOfferta(4L);
|
||||
CR.setFlgEscludiWeb(0L);
|
||||
if (!debug)
|
||||
CR.setFlgReadyForWeb(1L);
|
||||
CR.setFlgOrderBy(99L);
|
||||
CR.setPrezzoDa(ArticoloAutoOfferte.this.getPrezzoDaAO());
|
||||
if (ArticoloAutoOfferte.this.getGiacenzaMinimaAO() > 0L) {
|
||||
CR.setQtaDa(ArticoloAutoOfferte.this.getGiacenzaMinimaAO());
|
||||
CR.setQtaA(999999L);
|
||||
CR.setFlgQta(1L);
|
||||
}
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add(6, (int)ArticoloAutoOfferte.this.getNGiorniAO());
|
||||
Date dataScadenzaOfferta = new Date(cal.getTimeInMillis());
|
||||
Vectumerator<Articolo> vectumerator = bean.findByCR(CR, 1, (int)ArticoloAutoOfferte.this.getNArticoliAO());
|
||||
System.out.println("Tot Record: " + vectumerator.getTotNumberOfRecords());
|
||||
while (vectumerator.hasMoreElements()) {
|
||||
Articolo row = (Articolo)vectumerator.nextElement();
|
||||
String temp = "Aggiornamento " + i + " su " + vectumerator.getTotNumberOfRecords() + " " + row.getCodice() + " " + row.getNome();
|
||||
StatusMsg.updateMsgByTag(ArticoloAutoOfferte.this.getApFull(), "AUTO OFFERTE ", temp);
|
||||
DBAdapter.printDebug(debug, "AUTO OFFERTE " + temp);
|
||||
row.setPrezzoIvatoBarrato(row.getStreetPriceIva());
|
||||
row.setId_vetrina(ArticoloAutoOfferte.this.getId_vetrinaAO());
|
||||
if (debug)
|
||||
System.out.println("AUTO OFFERTE ora salvo...");
|
||||
row.save();
|
||||
if (debug)
|
||||
System.out.println("AUTO OFFERTE salvataggio ok");
|
||||
if (DBAdapter.getDateDiff(DBAdapter.getToday(), dataScadenzaOfferta) < 0L) {
|
||||
if (debug)
|
||||
System.out.println("AUTO OFFERTE cancello offerta....");
|
||||
ListinoArticolo la = row.getListinoArticoloBase();
|
||||
la.setDataScadenzaOffertaLA(null);
|
||||
la.setPercScontoOffertaLA(0.0D);
|
||||
la.setPrezzoOffertaLA(0.0D);
|
||||
la.save();
|
||||
}
|
||||
if (dataScadenzaOfferta != null && DBAdapter.getDateDiff(DBAdapter.getToday(), dataScadenzaOfferta) >= 0L &&
|
||||
ArticoloAutoOfferte.this.getPercScontoOffertaAO() > 0.0D) {
|
||||
if (debug)
|
||||
System.out.println("AUTO OFFERTE inserisco offerta....");
|
||||
ListinoArticolo la = row.getListinoArticoloBase();
|
||||
la.setDataScadenzaOffertaLA(dataScadenzaOfferta);
|
||||
la.setPercScontoOffertaLA(ArticoloAutoOfferte.this.getPercScontoOffertaAO());
|
||||
la.save();
|
||||
}
|
||||
if (bean.isLocalhost())
|
||||
System.out.println("Auto Offerta:.... localhost");
|
||||
if (debug)
|
||||
System.out.println("AUTO OFFERTE FINE CICLO.... RIPARTO... " + i + "\n");
|
||||
i++;
|
||||
if (se1 > 0 && i % se1 == 0)
|
||||
System.out.print(".");
|
||||
if (se2 > 0 && i % se2 == 0)
|
||||
System.out.println("" + i + " / " + i);
|
||||
}
|
||||
}
|
||||
String tagVetrina = vetrina.getDescrizione().toLowerCase();
|
||||
bean.update("update ARTICOLO as A set tagArticolo = replace(A.tagArticolo,'" + tagVetrina + ",','') ");
|
||||
Marca marca = new Marca(this.apFull);
|
||||
Vectumerator<Marca> vecMarca = marca.findMarcheConTagOfferta();
|
||||
HashMap<Long, String> hmMarcaTag = new HashMap<>();
|
||||
while (vecMarca.hasMoreElements()) {
|
||||
Marca row = (Marca)vecMarca.nextElement();
|
||||
bean.update("update ARTICOLO as A set tagArticolo = replace(A.tagArticolo,'" + row.getTagOfferta() + ",','') ");
|
||||
hmMarcaTag.put(Long.valueOf(row.getId_marca()), row.getTagOfferta());
|
||||
}
|
||||
CR = new ArticoloCR();
|
||||
CR.setFlgOfferta(1L);
|
||||
CR.setFlgEscludiWeb(0L);
|
||||
if (!debug)
|
||||
CR.setFlgReadyForWeb(1L);
|
||||
Vectumerator<Articolo> vec = bean.findByCR(CR, 0, 0);
|
||||
if (debug)
|
||||
System.out.println("AUTO OFFERTE CICLO TAG ...tot record " + vec.getTotNumberOfRecords() + "\n");
|
||||
i = 0;
|
||||
while (vec.hasMoreElements()) {
|
||||
boolean isTagAggiornato = false;
|
||||
Articolo row = (Articolo)vec.nextElement();
|
||||
String temp = "Aggiornamento tag " + i + " su " + vec.getTotNumberOfRecords() + " " + row.getCodice() + " " + row.getNome();
|
||||
StatusMsg.updateMsgByTag(ArticoloAutoOfferte.this.getApFull(), "AUTO OFFERTE ", temp);
|
||||
String l_tag = row.getTagArticolo();
|
||||
if (l_tag.indexOf(tagVetrina) < 0) {
|
||||
if (!l_tag.endsWith(","))
|
||||
l_tag = l_tag + ",";
|
||||
l_tag = l_tag + l_tag + ",";
|
||||
row.setTagArticolo(l_tag);
|
||||
isTagAggiornato = true;
|
||||
}
|
||||
if (hmMarcaTag.containsKey(Long.valueOf(row.getId_marca()))) {
|
||||
l_tag = row.getTagArticolo();
|
||||
String tagMarca = hmMarcaTag.get(Long.valueOf(row.getId_marca()));
|
||||
if (l_tag.indexOf(tagMarca) < 0) {
|
||||
if (!l_tag.endsWith(","))
|
||||
l_tag = l_tag + ",";
|
||||
l_tag = l_tag + l_tag + ",";
|
||||
row.setTagArticolo(l_tag);
|
||||
isTagAggiornato = true;
|
||||
}
|
||||
}
|
||||
if (isTagAggiornato)
|
||||
row.superSave();
|
||||
i++;
|
||||
if (se1 > 0 && i % se1 == 0)
|
||||
System.out.print(".");
|
||||
if (se2 > 0 && i % se2 == 0)
|
||||
System.out.println("" + i + " / " + i);
|
||||
}
|
||||
if (debug)
|
||||
System.out.println("AUTO OFFERTE FINE CICLO TAG " + i + "\n");
|
||||
}
|
||||
timer.stop();
|
||||
rp.setMsg("AUTO OFFERTE concluso. DURATA: " + timer.getDurataHourMin() + "\n" + rp.getMsg());
|
||||
if (this.sendEmail);
|
||||
StatusMsg.updateMsgByTag(ArticoloAutoOfferte.this.getApFull(), "AUTO OFFERTE ", rp.getMsg());
|
||||
try {
|
||||
sleep(10000L);
|
||||
} catch (Exception e) {}
|
||||
StatusMsg.deleteMsgByTag(ArticoloAutoOfferte.this.getApFull(), "AUTO OFFERTE ");
|
||||
ArticoloAutoOfferte.threadAutoOfferte = false;
|
||||
System.out.println(rp.getMsg());
|
||||
}
|
||||
|
||||
public boolean isSendEmail() {
|
||||
return this.sendEmail;
|
||||
}
|
||||
|
||||
public void setSendEmail(boolean sendEmail) {
|
||||
this.sendEmail = sendEmail;
|
||||
}
|
||||
}
|
||||
|
||||
public ArticoloAutoOfferte(ApplParmFull apFull) {
|
||||
this.apFull = apFull;
|
||||
}
|
||||
|
||||
public ArticoloAutoOfferte() {}
|
||||
|
||||
public static boolean isThreadAttivo() {
|
||||
return threadAutoOfferte;
|
||||
}
|
||||
|
||||
public long getNArticoliAO() {
|
||||
return this.nArticoliAO;
|
||||
}
|
||||
|
||||
public void setNArticoliAO(long nArticoliAO) {
|
||||
this.nArticoliAO = nArticoliAO;
|
||||
}
|
||||
|
||||
public long getNGiorniAO() {
|
||||
return this.nGiorniAO;
|
||||
}
|
||||
|
||||
public void setNGiorniAO(long nGiorniAO) {
|
||||
this.nGiorniAO = nGiorniAO;
|
||||
}
|
||||
|
||||
public long getId_vetrinaAO() {
|
||||
return this.id_vetrinaAO;
|
||||
}
|
||||
|
||||
public void setId_vetrinaAO(long id_vetrinaAO) {
|
||||
this.id_vetrinaAO = id_vetrinaAO;
|
||||
}
|
||||
|
||||
public double getPrezzoDaAO() {
|
||||
return this.prezzoDaAO;
|
||||
}
|
||||
|
||||
public void setPrezzoDaAO(double prezzoDaAO) {
|
||||
this.prezzoDaAO = prezzoDaAO;
|
||||
}
|
||||
|
||||
public long getGiacenzaMinimaAO() {
|
||||
return this.giacenzaMinimaAO;
|
||||
}
|
||||
|
||||
public void setGiacenzaMinimaAO(long giacenzaMinimaAO) {
|
||||
this.giacenzaMinimaAO = giacenzaMinimaAO;
|
||||
}
|
||||
|
||||
public double getPercScontoOffertaAO() {
|
||||
return this.percScontoOffertaAO;
|
||||
}
|
||||
|
||||
public void setPercScontoOffertaAO(double percScontoOffertaAO) {
|
||||
this.percScontoOffertaAO = percScontoOffertaAO;
|
||||
}
|
||||
|
||||
public ApplParmFull getApFull() {
|
||||
return this.apFull;
|
||||
}
|
||||
|
||||
public void setApFull(ApplParmFull apFull) {
|
||||
this.apFull = apFull;
|
||||
}
|
||||
|
||||
public final ResParm starAutoOfferte(ApplParmFull apFull, boolean sendEmail) {
|
||||
if (!isThreadAttivo()) {
|
||||
new ThreadAutoOfferte(apFull, sendEmail);
|
||||
return new ResParm(true, "Thread AUTO OFFERTE avviato");
|
||||
}
|
||||
return new ResParm(false, "ATTENZIONE!! Thread AUTO OFFERTE in esecuzione!!!");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue