Regalamiunsorriso/decompiled-libs/www/acxent-common-1.0.1/AggiornaMagMovimento.java

189 lines
7.9 KiB
Java

import it.acxent.anag.MagFisico;
import it.acxent.art.Articolo;
import it.acxent.art.ArticoloCR;
import it.acxent.art.ArticoloVariante;
import it.acxent.contab.Movimento;
import it.acxent.contab.RigaDocumento;
import it.acxent.contab.RigaDocumentoP;
import it.acxent.contab.RigaDocumentoPCR;
import it.acxent.db.ApplParm;
import it.acxent.db.ApplParmFull;
import it.acxent.db.ResParm;
import it.acxent.util.DbConsole;
import it.acxent.util.Vectumerator;
import java.sql.Timestamp;
import java.util.Calendar;
public class AggiornaMagMovimento extends DbConsole {
public static void main(String[] args) {
AggiornaMagMovimento bean = new AggiornaMagMovimento();
bean.doImport();
System.exit(0);
}
public void doImport() {
int i = 0, j = 0;
int se1 = 10;
int se2 = 100;
String hostname = "localhost";
String db = "guidoreni";
boolean step1 = true, step2 = true, step3 = true, step4 = true, step5 = true;
System.out.println("Db: " + db);
ApplParmFull apTarget = new ApplParmFull(new ApplParm(3, "//" + hostname + "/" + db, "root", "root", 1, 10, 60));
apTarget.setDebug(false);
StringBuffer msg = new StringBuffer();
try {
long l_id_articolo = 0L;
ResParm rp = new ResParm(true);
int pagerow = 1000;
Timestamp start = new Timestamp(Calendar.getInstance().getTimeInMillis());
System.out.println("START: " + start.toString());
if (step1) {
System.out.println("Delete All Movimento");
Movimento mov = new Movimento(apTarget);
String sqlDeleteMov = "delete from MOVIMENTO ";
if (l_id_articolo > 0L)
sqlDeleteMov = sqlDeleteMov + " where id_articolo=" + sqlDeleteMov;
mov.delete(sqlDeleteMov);
i = 0;
System.out.println("Import All Movimento");
RigaDocumento rd = new RigaDocumento(apTarget);
long tot = rd.findAllPerRiordinoMagazzinoTot(l_id_articolo);
System.out.println("tot record: " + tot);
while ((long)j < tot / (long)pagerow + 1L) {
j++;
Vectumerator vec = rd.findAllPerRiordinoMagazzino(l_id_articolo, j, pagerow);
while (vec.hasMoreElements()) {
rd = (RigaDocumento)vec.nextElement();
rp = RigaDocumento.aggiornaMovimento(rd);
i++;
if (se1 > 0 && i % se1 == 0)
System.out.print(".");
if (se2 > 0 && i % se2 == 0)
System.out.println(i);
}
System.out.print("Tot: " + tot + " - Pag: " + j + " - Pag. Lette: " + j * pagerow);
}
}
Timestamp stop = new Timestamp(Calendar.getInstance().getTimeInMillis());
System.out.println("start 2: " + stop.toString());
if (step2) {
i = 0;
j = 0;
RigaDocumentoP rdp = new RigaDocumentoP(apTarget);
Vectumerator vec = rdp.findAll();
long tot = (long)vec.getTotNumberOfRecords();
System.out.println("Riga documento P: tot record: " + vec.getTotNumberOfRecords());
while ((long)j < tot / (long)pagerow + 1L) {
j++;
vec = rdp.findByCR(new RigaDocumentoPCR(), j, pagerow);
while (vec.hasMoreElements()) {
RigaDocumentoP row = (RigaDocumentoP)vec.nextElement();
if (row.getRigaDocumentoPrelevata().getDocumento().getTipoDocumento()
.getFlgTipologia() == 3L) {
Movimento mov = new Movimento(apTarget);
rp = mov.deleteP(row.getId_rigaDocumentoPrelevata());
mov.setId_articolo(row.getRigaDocumentoPrelevata().getId_articolo());
mov.setId_articoloVariante(row.getRigaDocumentoPrelevata().getId_articoloVariante());
mov.setId_articoloTaglia(row.getRigaDocumentoPrelevata().getId_articoloTaglia());
mov.setId_clifor(row.getRigaDocumentoPrelevata().getDocumento().getId_clifor());
MagFisico mf = new MagFisico(apTarget);
mf.findMagazzinoOrdinato();
mov.setId_magFisico(mf.getId_magFisico());
mov.setId_rigaDocumento(row.getId_rigaDocumento());
mov.setNr(-1.0D * row.getQuantitaPrelevata());
rp = mov.save();
} else {
System.out.println("!!! " + row.getRigaDocumentoPrelevata().getDocumento().getNumeroDocumentoCompleto());
row.superDelete();
}
i++;
if (se1 > 0 && i % se1 == 0)
System.out.print(".");
if (se2 > 0 && i % se2 == 0)
System.out.println(i);
}
}
}
stop = new Timestamp(Calendar.getInstance().getTimeInMillis());
System.out.println("start 3: " + stop.toString());
if (step3) {
i = 0;
j = 0;
Articolo art = new Articolo(apTarget);
ArticoloCR CR = new ArticoloCR();
CR.setFlgQta(1L);
CR.setQtaDa(1L);
CR.setQtaA(99999999L);
Vectumerator<Articolo> vec = art.findByCR(CR, 0, 0);
long tot = (long)vec.getTotNumberOfRecords();
Movimento mov = new Movimento(apTarget);
System.out.println("Articolio: tot record: " + vec.getTotNumberOfRecords());
while (vec.hasMoreElements()) {
Articolo row = (Articolo)vec.nextElement();
System.out.println(row.getNome());
if (row.getFlgUsaVarianti() == 1L) {
ArticoloVariante av = new ArticoloVariante(apTarget);
Vectumerator vecAv = av.findById_articolo(row.getId_articolo(), 0, 0, -1L, -1L);
while (vecAv.hasMoreElements()) {
ArticoloVariante rowAV = (ArticoloVariante)vecAv.nextElement();
Movimento.aggiornaDispo(apTarget, rowAV.getId_articolo(), rowAV.getId_articoloVariante(), 0L, 1L);
}
} else {
Movimento.aggiornaDispo(apTarget, row.getId_articolo(), 0L, 0L, 1L);
}
i++;
if (se1 > 0 && i % se1 == 0)
System.out.print(".");
if (se2 > 0 && i % se2 == 0)
System.out.println(i);
}
}
stop = new Timestamp(Calendar.getInstance().getTimeInMillis());
System.out.println("start 4: " + stop.toString());
if (step4) {
i = 0;
j = 0;
RigaDocumento rd = new RigaDocumento(apTarget);
Vectumerator vec = rd.findRigheDocumentoPrelevateDaStornare();
long tot = (long)vec.getTotNumberOfRecords();
Movimento mov = new Movimento(apTarget);
System.out.println("Righe documento ordine da stornare: tot record: " + vec.getTotNumberOfRecords());
while (vec.hasMoreElements()) {
RigaDocumento row = (RigaDocumento)vec.nextElement();
row.aggiornaMovimentoPareggioRigaPrelevata();
i++;
if (se1 > 0 && i % se1 == 0)
System.out.print(".");
if (se2 > 0 && i % se2 == 0)
System.out.println(i);
}
}
if (step5) {
i = 0;
j = 0;
RigaDocumento rd = new RigaDocumento(apTarget);
Vectumerator vec = rd.findRigheDocumentoPrelevateDaStornare();
long tot = (long)vec.getTotNumberOfRecords();
Movimento mov = new Movimento(apTarget);
System.out.println("Righe documento ordine da stornare: tot record: " + vec.getTotNumberOfRecords());
while (vec.hasMoreElements()) {
RigaDocumento row = (RigaDocumento)vec.nextElement();
row.aggiornaMovimentoPareggioRigaPrelevata();
i++;
if (se1 > 0 && i % se1 == 0)
System.out.print(".");
if (se2 > 0 && i % se2 == 0)
System.out.println(i);
}
}
stop = new Timestamp(Calendar.getInstance().getTimeInMillis());
System.out.println("STOP: " + start.toString());
System.out.println("DURATA: " + (double)(stop.getTime() - start.getTime()) / 60000.0D + " minuti");
System.out.println("Fine");
System.out.println(rp.getMsg());
} catch (Exception e) {
e.printStackTrace();
}
}
}