Files correlati : Ricompilazione Demo : [ ] Commento : Riportata la versione 10.05 patch 502 git-svn-id: svn://10.65.10.50/trunk@8388 c028cbd2-c16b-5b4b-a496-9718f37d4682
878 lines
23 KiB
C++
Executable File
878 lines
23 KiB
C++
Executable File
#include "dbcv.h"
|
|
#include "dbcv09.h"
|
|
#include "dbcv02a.h"
|
|
|
|
#include <automask.h>
|
|
#include <applicat.h>
|
|
#include <relation.h>
|
|
#include <execp.h>
|
|
#include "..\mg\anamag.h"
|
|
#include "..\mg\mag.h"
|
|
#include "..\include\doc.h"
|
|
#include "..\include\rdoc.h"
|
|
#include "..\db\dblib.h"
|
|
|
|
typedef void (*SET_DOC_FUN)(TImport_file & import,TConfig &trans);
|
|
typedef bool (*FILTER_FUN)(TImport_file & import);
|
|
|
|
bool unevadi_orc(TMask &m, const TString & codimp)
|
|
{
|
|
TString8 codnum=codimp;
|
|
codnum<< "OC";
|
|
TRelation *r= new TRelation(LF_DOC);
|
|
r->add(LF_RIGHEDOC,"CODNUM==CODNUM|ANNO==ANNO|PROVV==PROVV|NDOC==NDOC");
|
|
TCursor c(r);
|
|
TRectype frec(LF_DOC);
|
|
frec.put("CODNUM",codnum);
|
|
frec.put("PROVV","D");
|
|
frec.put("ANNO" ,"1999");
|
|
c.setregion(frec,frec);
|
|
c.freeze();
|
|
|
|
const long items=c.items();
|
|
TProgind info(items,"Reset evasione commesse cliente...",FALSE,TRUE);
|
|
for (long i= 0; i< items ; i++)
|
|
{
|
|
c=i;
|
|
info.addstatus(1);
|
|
TRelation *r =c.relation();
|
|
TLocalisamfile & righe = c.relation()->lfile(LF_RIGHEDOC);
|
|
bool ok = r->is_first_match(LF_RIGHEDOC);
|
|
while (ok)
|
|
{
|
|
if (righe.get_bool("RIGAEVASA") ||righe.get_real("QTAEVASA")!=ZERO )
|
|
{
|
|
righe.put("RIGAEVASA"," ");
|
|
righe.put("QTAEVASA","0.0");
|
|
righe .rewrite();
|
|
}
|
|
ok = r->next_match(LF_RIGHEDOC);
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
bool evadi_orc(TCursor & c, TAssoc_array & evasioni)
|
|
{
|
|
const long items=c.items();
|
|
TProgind info(items,"Evasione commesse cliente...",FALSE,TRUE);
|
|
for (long i= 0; i< items ; i++)
|
|
{
|
|
c=i;
|
|
info.addstatus(1);
|
|
TRelation *r =c.relation();
|
|
TLocalisamfile & righe = c.relation()->lfile(LF_RIGHEDOC);
|
|
bool ok = r->is_first_match(LF_RIGHEDOC);
|
|
while (ok)
|
|
{
|
|
const TString codprod = righe.get("CODARTMAG");
|
|
real *qta=NULL;
|
|
if (evasioni.is_key(codprod))
|
|
qta=(real*)evasioni.objptr(codprod);
|
|
if (!righe.get_bool("RIGAEVASA") && qta!=NULL)
|
|
{
|
|
real q(righe.get_real("QTA"));
|
|
real qevasa(righe.get_real("QTAEVASA"));
|
|
if (*qta>ZERO && q>qevasa)
|
|
{
|
|
if (q-qevasa>*qta)
|
|
{
|
|
qevasa+=*qta;
|
|
*qta = 0;
|
|
} else {
|
|
*qta -= q;
|
|
qevasa=q;
|
|
righe.put("RIGAEVASA","X");
|
|
}
|
|
righe.put("QTAEVASA",qevasa);
|
|
righe .rewrite();
|
|
}
|
|
}
|
|
ok = r->next_match(LF_RIGHEDOC);
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool evadi_orc(TMask & m, const TString & codimp)
|
|
{
|
|
if (!yesno_box("I movimenti 00 e T-04 sul mag. 25 verranno usati per evadere le commesse. Procedo?"))
|
|
return FALSE;
|
|
TFilename source(m.get(S_MOVMAG_FILE));
|
|
if (source.blank())
|
|
source=BPCS_MOVMAG;
|
|
TDate fromdate(m.get(S_MOVMAG_FROMD));
|
|
TDate todate(m.get(S_MOVMAG_TOD));
|
|
TImport_file movmag(m.get(F_PATH),source);
|
|
bool ok = TRUE;
|
|
if (noyes_box("Attenzione: l'operazione non e' ripetibile;assicurarsi che la situazione del pending delle commesse sia relativa alla bolla indicata. Procedo?"))
|
|
{
|
|
const int expmag= codimp == "SE" ? 25 : 27;
|
|
|
|
TString8 codnum=codimp;
|
|
codnum<< "OC";
|
|
TRelation *r= new TRelation(LF_DOC);
|
|
r->add(LF_RIGHEDOC,"CODNUM==CODNUM|ANNO==ANNO|PROVV==PROVV|NDOC==NDOC");
|
|
TCursor c(r,"!DOCEVASO");
|
|
TRectype frec(LF_DOC);
|
|
frec.put("CODNUM",codnum);
|
|
frec.put("PROVV","D");
|
|
frec.put("ANNO" ,"1999");
|
|
c.setregion(frec,frec);
|
|
c.freeze();
|
|
|
|
long lastbolla(m.get_int(S_LASTBOLLA)),nobolla;
|
|
TProgind info(movmag.items(),"Estrazione ultime consegne...",FALSE,TRUE);
|
|
|
|
TAssoc_array evasioni;
|
|
movmag.first();
|
|
while(!movmag.eof())
|
|
{
|
|
info.addstatus(1);
|
|
const TDate dmov = movmag.get_date("TTDTE");
|
|
if (movmag.get_int("TWHS")==expmag &&
|
|
(!fromdate.ok() || dmov >= fromdate) &&
|
|
(!todate.ok() || dmov <= todate) )
|
|
{
|
|
TString codprod(movmag.get("TPROD"));
|
|
real qta(movmag.get_real("TQTY"));
|
|
TString com(movmag.get("TCOM"));
|
|
nobolla = -1;
|
|
if (movmag.get("TTYPE")=="T")
|
|
{
|
|
if (movmag.get("TRES")=="04" && com.len()==15)
|
|
nobolla=atol(com.mid(7));
|
|
else
|
|
if (yesno_box("Includo il trasferimento del %s, %s per %s,\n '%s'",
|
|
(const char *)dmov,(const char *)codprod,(const char *)qta.string(),(const char *)com))
|
|
nobolla=lastbolla+1; // non so come filtrarla !!!
|
|
}
|
|
else if (movmag.get("TTYPE")=="00")
|
|
{
|
|
if (yesno_box("Includo il carico da terzi del %s, %s per %s,\n '%s'",
|
|
(const char *)dmov,(const char *)codprod,(const char *)qta.string(),(const char *)com))
|
|
nobolla=lastbolla+1; // non so come filtrarla !!!
|
|
}
|
|
if (nobolla>lastbolla)
|
|
{
|
|
// evadi
|
|
if (evasioni.is_key(codprod))
|
|
qta+=(real&)evasioni.find(codprod);
|
|
evasioni.add(codprod, qta, TRUE);
|
|
}
|
|
}
|
|
movmag.next();
|
|
}
|
|
ok = evadi_orc(c, evasioni);
|
|
}
|
|
return FALSE;
|
|
return ok;
|
|
}
|
|
|
|
|
|
void crea_mag3()
|
|
{
|
|
TString codmag;TString desc;
|
|
TTable mag("MAG");
|
|
mag.put("CODTAB","SE1");
|
|
mag.put("B0","X");
|
|
mag.put("S0","Magazzino di Segrate (ex mag. 26,91 e 93)");
|
|
force_write(mag);
|
|
|
|
mag.put("CODTAB","TS1");
|
|
mag.put("B0","X");
|
|
mag.put("S0","Magazzino di Trieste (ex mag. 28 e 92)");
|
|
force_write(mag);
|
|
|
|
mag.put("CODTAB","PR1");
|
|
mag.put("B0","X");
|
|
mag.put("S0","Magazzino di Parma");
|
|
force_write(mag);
|
|
|
|
mag.put("CODTAB","PD1");
|
|
mag.put("B0","X");
|
|
mag.put("S0","Magazzino di Padova");
|
|
force_write(mag);
|
|
const char *codimp[] = {"SE","TS","PR","PD"};
|
|
const char *descimp[] = {"Segrate","Trieste","Parma","Padova"};
|
|
for (int t=0 ; t<99;t++)
|
|
for (int i=0 ; i<4;i++)
|
|
{
|
|
mag.zero();
|
|
long l=-1;
|
|
if (t==0)
|
|
{
|
|
codmag.format("%s1PF", codimp[i]);
|
|
desc = "Deposito prodotti finiti ";
|
|
desc << descimp[i];
|
|
l=0;
|
|
}
|
|
else
|
|
if (i<2)
|
|
{
|
|
l = method2location(t);
|
|
desc=descr_method(t);
|
|
desc << " (ex locazione " << l << ")";
|
|
codmag.format("%s1%02d", codimp[i], t);
|
|
}
|
|
if (l >= 0)
|
|
{
|
|
mag.put("CODTAB",codmag);
|
|
mag.put("S0",desc);
|
|
force_write(mag);
|
|
}
|
|
}
|
|
}
|
|
|
|
void crea_linee3()
|
|
{
|
|
TTable lnp("LNP");
|
|
TString8 code;
|
|
TString8 codimp;
|
|
for (int imp=0; imp<4; imp++)
|
|
{
|
|
switch (imp)
|
|
{
|
|
case 0: codimp ="SE"; break;
|
|
case 1: codimp ="TS"; break;
|
|
case 2: codimp ="PD"; break;
|
|
case 3: codimp ="PR"; break;
|
|
}
|
|
for (int terz=1; terz<99; terz++)
|
|
{
|
|
code =format("X%02d",terz);
|
|
code << codimp;
|
|
lnp.put("CODTAB",code);
|
|
if (lnp.read()==NOERR)
|
|
{
|
|
lnp.put("S0",format("%s (%s)",descr_method(terz), (const char *)codimp)) ;
|
|
lnp.rewrite();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
bool find_wrongcycle()
|
|
{
|
|
TIndwin iw(80, "Ricerca errori sui cicli di lavoro ...",FALSE,FALSE);
|
|
bool some_done=FALSE;
|
|
int err;
|
|
long distno=1L;
|
|
TString cod="";
|
|
TLocalisamfile umart(LF_UMART);
|
|
TRelation r(new TLocalisamfile(LF_RDIST));
|
|
r.add(LF_DIST,"CODDIST==CODDIST");
|
|
r.add(LF_UMART,"CODART==CODDIST|UM=UM",2,LF_DIST);
|
|
r.add(LF_UMART,"CODART==CODDIST",1,LF_DIST,LF_UMART);
|
|
err = r.first();
|
|
while (err == NOERR)
|
|
{
|
|
if ((distno%TICK)==1)
|
|
{
|
|
iw.set_text(format("Ricerca errori riga n. %ld", distno));
|
|
do_events();
|
|
}
|
|
distno++;
|
|
if (r.lfile().get("TIPO")=="L" )
|
|
{
|
|
long expr=atol(r.lfile().get("EXPR")), newexpr;
|
|
bool ask=FALSE;
|
|
if (r.update()==NOERR)
|
|
{
|
|
long divisore=r.lfile(LF_UMART).get_long("FC");
|
|
TString lav(r.lfile().get("CODCOMP"));
|
|
if (expr < divisore && lav.left(5)!="ACQUA")
|
|
{
|
|
TString codice(r.lfile().get("CODDIST"));
|
|
// caso sospetto
|
|
TString4 main_um(r.lfile(-LF_UMART).get("UM"));
|
|
int formato=lav.find(format("_X"));
|
|
if (formato<0)
|
|
formato=lav.find(format(".X"));
|
|
if (formato<0)
|
|
formato=lav.find(format(" X12"));
|
|
newexpr=divisore;
|
|
if (formato>0)
|
|
{
|
|
// lav in casse
|
|
int pzxca=atoi(lav.sub(formato+2));
|
|
if (pzxca>0)
|
|
{
|
|
if (main_um=="PZ")
|
|
newexpr/=atoi(lav.sub(formato+2));
|
|
ask=TRUE;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (main_um=="PZ")
|
|
ask=TRUE;
|
|
}
|
|
if (ask)
|
|
{
|
|
if (yesno_box("Il codice %s espresso in '%s'(=%ld %s) \ncontiene la lavorazione %s in quantita' %ld; \nsostituisco con %ld?", (const char *)codice,
|
|
(const char *)r.lfile(LF_DIST).get("UM"),
|
|
divisore,
|
|
(const char *)main_um,
|
|
(const char *)lav, expr,newexpr))
|
|
{
|
|
r.lfile().put("EXPR",newexpr);
|
|
r.lfile().rewrite();
|
|
}
|
|
} else {
|
|
message_box("Il codice %s espresso in '%s'(=%ld %s) \ncontiene la lavorazione %s in quantita' %ld", (const char *)codice,
|
|
(const char *)r.lfile(LF_DIST).get("UM"),
|
|
divisore,
|
|
(const char *)main_um,
|
|
(const char *)lav, expr,newexpr);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
err = r.next();
|
|
}
|
|
return TRUE;
|
|
}
|
|
class TMov_diff_inv : public TConfig
|
|
{
|
|
int _nriga;
|
|
public:
|
|
void set_header(const char *imp_filter);
|
|
int righe () {return _nriga;}
|
|
bool max_righe () {return _nriga > 99 ;}
|
|
void locate_bpcs_stock(const TString &codice , int mag , long loc, TImport_file &mag_bpcs, real &giac) ;
|
|
int compare_stocks(TLocalisamfile &mag, const real & bpcs_stock, bool giac);
|
|
TMov_diff_inv (int num);
|
|
} ;
|
|
|
|
TMov_diff_inv::TMov_diff_inv (int num) :
|
|
TConfig (format("ND_%05d.ini",num)) , _nriga(0)
|
|
{}
|
|
|
|
void TMov_diff_inv ::locate_bpcs_stock(const TString &codice , int mag , long loc, TImport_file &mag_bpcs, real & giac)
|
|
{
|
|
int direction = 0;
|
|
long diff = 0;
|
|
do {
|
|
diff = codice.compare(mag_bpcs.get("CODICE"));
|
|
if (diff == 0)
|
|
diff = mag - mag_bpcs.get_int("MAG");
|
|
if (diff == 0)
|
|
diff = loc - mag_bpcs.get_long("LOC");
|
|
if (diff > 0 && direction != -1)
|
|
{
|
|
direction = +1;
|
|
if (mag_bpcs.next()!=NOERR)
|
|
direction = 0;
|
|
}
|
|
if (diff < 0 && direction != 1)
|
|
{
|
|
direction = -1;
|
|
if (mag_bpcs.prev()!=NOERR)
|
|
direction = 0;
|
|
}
|
|
} while (diff*direction>0 && direction != 0 );
|
|
if (diff != 0)
|
|
giac = ZERO;
|
|
else
|
|
giac = mag_bpcs.get_real("QTY");
|
|
}
|
|
int TMov_diff_inv ::compare_stocks(TLocalisamfile &mag, const real & val_bpcs, bool giac)
|
|
{
|
|
if (!giac)
|
|
return _nriga;
|
|
TRectype newmag = mag.curr();
|
|
if (mag.read() != NOERR)
|
|
mag.curr() = newmag;
|
|
real val(mag.get_real("GIAC"));
|
|
if (!giac)
|
|
val = (mag.get_real("VEN"));
|
|
real diff = (val_bpcs - val);
|
|
if (!diff.is_zero())
|
|
{
|
|
set_paragraph(format("34,%d", ++_nriga));
|
|
set("TIPORIGA", "01");
|
|
set("CODART", mag.get("CODART"));
|
|
set("CODARTMAG", mag.get("CODART"));
|
|
set("DESCR", cache().get(LF_ANAMAG,mag.get("CODART")).get("DESCR"));
|
|
set("CODMAG", mag.get("CODMAG"));
|
|
TToken_string um_key(mag.get("CODART"));
|
|
um_key.add("1");
|
|
set("UMQTA", cache().get(LF_UMART,um_key).get("UM"));
|
|
set("QTA", diff.string());
|
|
set("CODCAUS", giac ? "CAR" : "");
|
|
}
|
|
return _nriga;
|
|
}
|
|
|
|
void TMov_diff_inv ::set_header(const char * imp_filter)
|
|
{
|
|
TDate today(TODAY);
|
|
set_paragraph("Transaction");
|
|
set("Action","INSERT");
|
|
set("Mode","AUTO");
|
|
set_paragraph("33");
|
|
TString8 codimp = imp_filter ;
|
|
codimp << "DI";
|
|
set("CODNUM",codimp);
|
|
set("CAUSMAG","");
|
|
set("NOTE","\"Differenze inventariali rilevate per confronto con gli archivi di BPCS\"");
|
|
set("DATADOC",today.string());
|
|
}
|
|
void sinchro_stock(const TMask & m, const char * imp_filter)
|
|
{
|
|
if (!yesno_box(format("Confermi l'allineamento giacenze per %s ?",imp_filter)))
|
|
return ;
|
|
TDate today(TODAY);
|
|
TIndwin info(60,format("Allineamento giacenze per %s...",imp_filter),FALSE,FALSE);
|
|
TImport_file mag_bpcs(m.get(F_PATH),BPCS_STOCK);
|
|
TLocalisamfile mag(LF_MAG);
|
|
TString codart,codmag, coddep, codimp;
|
|
long terzista;
|
|
int nummag, movimenti = 0;
|
|
bool ok;
|
|
|
|
delete_files("ND_*.ini");
|
|
TMov_diff_inv *action;
|
|
action = new TMov_diff_inv(movimenti++);
|
|
action->set_header(imp_filter);
|
|
|
|
mag.setkey(2);
|
|
ok = mag_bpcs.first()==NOERR;
|
|
while (ok)
|
|
{
|
|
codart = mag_bpcs.get("CODICE");
|
|
nummag = mag_bpcs.get_int("MAG");
|
|
num_mag2main_imp(nummag, codimp);
|
|
if (codimp == imp_filter)
|
|
{
|
|
terzista = location2method(mag_bpcs.get_int("LOC"));
|
|
num_mag2cod_imp(nummag, codmag);
|
|
if (terzista)
|
|
codmag << format("3%02d",terzista);
|
|
else
|
|
codmag << "1";
|
|
mag.put("ANNOES", today.year());
|
|
mag.put("CODART", codart);
|
|
mag.put("CODMAG", codmag);
|
|
if (mag.read()!=NOERR)
|
|
{
|
|
int nriga = 0;
|
|
mag.put("ANNOES", today.year());
|
|
mag.put("CODART", codart);
|
|
mag.put("NRIGA", ++nriga);
|
|
mag.setkey(1);
|
|
while (mag.read()==NOERR)
|
|
mag.put("NRIGA", ++nriga);
|
|
mag.zero(' ');
|
|
mag.put("ANNOES", today.year());
|
|
mag.put("CODART", codart);
|
|
mag.put("NRIGA", nriga);
|
|
mag.put("CODMAG", codmag);
|
|
mag.write();
|
|
mag.setkey(2);
|
|
}
|
|
}
|
|
ok = mag_bpcs.next()==NOERR;
|
|
}
|
|
|
|
real bpcsstock;
|
|
mag_bpcs.first();
|
|
mag.setkey(1);
|
|
mag.zero();
|
|
mag.put("ANNOES", today.year());
|
|
ok = mag.read(_isgteq)==NOERR;
|
|
// magazzino Eurocampo vs mag BPCS
|
|
while (ok)
|
|
{
|
|
codart = mag.get("CODART");
|
|
codmag = mag.get("CODMAG");
|
|
coddep = codmag.sub(3);
|
|
codimp = codmag.left(2);
|
|
codmag.cut(3);
|
|
nummag = cod_mag2num_mag(codmag);
|
|
if (codimp == imp_filter && nummag>0)
|
|
{
|
|
terzista = method2location(atoi(coddep));
|
|
action->locate_bpcs_stock(codart, nummag, terzista, mag_bpcs, bpcsstock);
|
|
action->compare_stocks(mag, bpcsstock, TRUE);
|
|
if (FALSE && nummag < 30)
|
|
{
|
|
action->locate_bpcs_stock( codart, nummag-1 ,0 , mag_bpcs, bpcsstock);
|
|
action->compare_stocks(mag, bpcsstock, FALSE);
|
|
}
|
|
}
|
|
if (action->max_righe())
|
|
{
|
|
TExternal_app gestdoc(format("ve0.exe -1 -i%s",(const char *)action->name()));
|
|
delete action;
|
|
gestdoc.run();
|
|
action = new TMov_diff_inv(movimenti++);
|
|
action->set_header(imp_filter);
|
|
}
|
|
|
|
ok = mag.next()==NOERR;
|
|
}
|
|
|
|
|
|
if (action->righe())
|
|
{
|
|
TExternal_app gestdoc(format("ve0.exe -1 -i%s",(const char *)action->name()));
|
|
delete action;
|
|
gestdoc.run();
|
|
}
|
|
}
|
|
|
|
void unlink_numdoc(const char *codnum, int anno)
|
|
{
|
|
TRelation *r = new TRelation(LF_DOC);
|
|
r->add(LF_RIGHEDOC,"PROVV==PROVV|ANNO==ANNO|CODNUM==CODNUM|NDOC==NDOC");
|
|
TCursor c(r);
|
|
TRectype from(LF_DOC),to(LF_DOC);
|
|
from.put("PROVV","D");
|
|
from.put("ANNO",anno);
|
|
from.put("CODNUM",codnum);
|
|
to = from;
|
|
c.setregion(from,to);
|
|
const long items=c.items();
|
|
TProgind info(items,format("Scollegamento documenti %s anno %d...",codnum,anno),FALSE,TRUE);
|
|
for (long i=items-1; i>=0 ; i--)
|
|
{
|
|
c = i;
|
|
info.addstatus(1);
|
|
TLocalisamfile &doc=r->lfile();
|
|
TLocalisamfile &rdoc=r->lfile(LF_RIGHEDOC);
|
|
if (doc.get_long("MOVMAG")!=0L)
|
|
{
|
|
doc.put("MOVMAG",0);
|
|
doc.rewrite();
|
|
}
|
|
if (r->is_first_match(LF_RIGHEDOC))
|
|
do {
|
|
if (rdoc.get_long("MOVMAG")!=0L)
|
|
{
|
|
rdoc.put("MOVMAG",0);
|
|
rdoc.rewrite();
|
|
}
|
|
} while (r->next_match(LF_RIGHEDOC));
|
|
}
|
|
}
|
|
|
|
void unlink_docs()
|
|
{
|
|
unlink_numdoc("SEBA",1998);
|
|
unlink_numdoc("SEBA",1999);
|
|
unlink_numdoc("SEBE",1998);
|
|
unlink_numdoc("SEBE",1999);
|
|
unlink_numdoc("SEBP",1998);
|
|
unlink_numdoc("SEBP",1999);
|
|
unlink_numdoc("SEBT",1998);
|
|
unlink_numdoc("SEBT",1999);
|
|
unlink_numdoc("SEBU",1998);
|
|
unlink_numdoc("SEBU",1999);
|
|
unlink_numdoc("SEBV",1998);
|
|
unlink_numdoc("SEBV",1999);
|
|
unlink_numdoc("SEDI",1998);
|
|
unlink_numdoc("SEDI",1999);
|
|
unlink_numdoc("SEFA",1998);
|
|
unlink_numdoc("SEFA",1999);
|
|
unlink_numdoc("SEMM",1998);
|
|
unlink_numdoc("SEMM",1999);
|
|
unlink_numdoc("SEMP",1998);
|
|
unlink_numdoc("SEMP",1999);
|
|
unlink_numdoc("SEOC",1998);
|
|
unlink_numdoc("SEOC",1999);
|
|
unlink_numdoc("SEOF",1998);
|
|
unlink_numdoc("SEOF",1999);
|
|
unlink_numdoc("SEOP",1998);
|
|
unlink_numdoc("SEOP",1999);
|
|
unlink_numdoc("SERF",1998);
|
|
unlink_numdoc("SERF",1999);
|
|
}
|
|
|
|
void kill_blank_mag(const TMask & m, const char * codmag)
|
|
{
|
|
TLocalisamfile mag(LF_MAG),mag2(LF_MAG);
|
|
mag2.setkey(2);
|
|
TString codart;
|
|
int anno;
|
|
int err = mag.first();
|
|
while (err==NOERR)
|
|
{
|
|
anno = mag.get_int("ANNOES");
|
|
codart = mag.get("CODART");
|
|
mag2.put("ANNOES",anno);
|
|
mag2.put("CODMAG",codmag);
|
|
mag2.put("CODART",codart);
|
|
if (mag2.read()==NOERR)
|
|
{
|
|
}
|
|
else
|
|
{
|
|
}
|
|
err= mag.next();
|
|
}
|
|
|
|
}
|
|
|
|
bool unify_magcode(const char * field, TLocalisamfile & file, bool only3=FALSE)
|
|
{
|
|
TString codmag = file.get(field);
|
|
if (codmag.blank())
|
|
return FALSE;
|
|
if (!only3 && codmag[2]=='1' && codmag[3]=='\0')
|
|
{
|
|
codmag.overwrite("PF",3); // deposito produzione finiti
|
|
}
|
|
else if (codmag[2]=='3'&& codmag[3]!='\0')
|
|
{
|
|
codmag[2]='1';
|
|
} else if (codmag==" PF")
|
|
{
|
|
codmag="";
|
|
} else
|
|
return FALSE;
|
|
file.put(field,codmag);
|
|
if (file.rewrite()!=NOERR)
|
|
file.write();
|
|
do_events();
|
|
return TRUE;
|
|
}
|
|
|
|
void unify_mags_reset_bar(TProgind & pi, const char * msg2, long max)
|
|
{
|
|
const char * msg = "Unificazione magazzini interni e terzisti: ";
|
|
pi.set_text(format("%s%s",msg,msg2));
|
|
pi.setstatus(0);
|
|
pi.setmax(max);
|
|
}
|
|
void unify_mags(const TMask & m)
|
|
{
|
|
TTable impianti("IMP"), linee("LNP"),tabmag("MAG");
|
|
TString codmag;
|
|
TLocalisamfile mag(LF_MAG),
|
|
rmovmag(LF_RMOVMAG),
|
|
rdoc(LF_RIGHEDOC);
|
|
TProgind info(80,"",FALSE,TRUE);
|
|
message_box("Modificare a mano la tabella magazzini");
|
|
unify_mags_reset_bar(info, "tabella impianti", impianti.items());
|
|
impianti.setkey(2);
|
|
int err = impianti.first();
|
|
while (err==NOERR)
|
|
{
|
|
unify_magcode("S7", impianti);
|
|
unify_magcode("S8", impianti);
|
|
err = impianti.next();
|
|
info.addstatus(1);
|
|
}
|
|
unify_mags_reset_bar(info, "tabella linee di produzione", linee.items());
|
|
linee.setkey(2);
|
|
err = linee.first();
|
|
while (err==NOERR)
|
|
{
|
|
unify_magcode("S7", linee);
|
|
unify_magcode("S8", linee);
|
|
err = linee.next();
|
|
info.addstatus(1);
|
|
}
|
|
unify_mags_reset_bar(info, "giacenze", mag.items());
|
|
err = mag.first();
|
|
while (err==NOERR)
|
|
{
|
|
unify_magcode("CODMAG", mag);
|
|
err = mag.next();
|
|
info.addstatus(1);
|
|
}
|
|
unify_mags_reset_bar(info, "movimenti di magazzino", rmovmag.items());
|
|
err = rmovmag.first();
|
|
while (err==NOERR)
|
|
{
|
|
unify_magcode("CODMAG", rmovmag);
|
|
err = rmovmag.next();
|
|
info.addstatus(1);
|
|
}
|
|
unify_mags_reset_bar(info, "righe documenti", rmovmag.items());
|
|
err = rdoc.first();
|
|
while (err==NOERR)
|
|
{
|
|
unify_magcode("CODMAG", rdoc);
|
|
unify_magcode("CODMAGC", rdoc);
|
|
err = rdoc.next();
|
|
info.addstatus(1);
|
|
}
|
|
}
|
|
|
|
void checkexplosions(const TMask & m)
|
|
{
|
|
TLocalisamfile movmag(LF_MOVMAG),
|
|
rmovmag(LF_RMOVMAG);
|
|
TArray boom;
|
|
TAssoc_array movs, arts;
|
|
TDistinta_tree search;
|
|
TString desc,codcaus,key, grmerc;
|
|
TLocalisamfile anamag(LF_ANAMAG);
|
|
int err = rmovmag.last();
|
|
TProgind info(rmovmag.items(),"Controllo scarichi errati da esplosioni distinte",FALSE,TRUE);
|
|
while (err==NOERR)
|
|
{
|
|
movmag.put("ANNOES","1999");
|
|
movmag.put("NUMREG",rmovmag.get("NUMREG"));
|
|
movmag.read();
|
|
desc = movmag.get("DESCR");
|
|
codcaus = rmovmag.get("CAUS");
|
|
if (codcaus.blank())
|
|
codcaus = movmag.get("CODCAUS");
|
|
|
|
key = rmovmag.get("CODART");
|
|
anamag.put("CODART",key);
|
|
if (!arts.is_key(key))
|
|
{
|
|
if (anamag.read()!=NOERR)
|
|
{
|
|
message_box("Articolo '%s' mancante ",
|
|
(const char *)rmovmag.get("CODART"));
|
|
arts.add(key, grmerc);
|
|
grmerc = "~";
|
|
}
|
|
else
|
|
grmerc = anamag.get("GRMERC");
|
|
}
|
|
else
|
|
grmerc = (TString &)arts[key];
|
|
if (grmerc[0] == '~' || codcaus.left(3)=="SCC")
|
|
{
|
|
if (grmerc[0] == '~' || grmerc[0]=='F')
|
|
{
|
|
if (!arts.is_key(key))
|
|
{
|
|
if (search.set_root(key))
|
|
{
|
|
search.explode(boom,FALSE, RAGGR_EXP_NONE, 1, "A");
|
|
if (boom.items() <= 0)
|
|
message_box("Distinta di %s priva di componenti", (const char *)key);
|
|
} else
|
|
message_box("Distinta di %s mancante ", (const char *)key);
|
|
arts.add(key, grmerc);
|
|
}
|
|
key = format("%ld",rmovmag.get_long("NUMREG"));
|
|
if (!movs.is_key(key))
|
|
{
|
|
message_box("Errore nel movimento %ld (%s)",
|
|
rmovmag.get_long("NUMREG"),
|
|
(const char *)desc );
|
|
movs.add(key,key);
|
|
}
|
|
}
|
|
}
|
|
err = rmovmag.prev();
|
|
info.addstatus(1);
|
|
}
|
|
}
|
|
class TCover_services : public TSkeleton_application
|
|
{
|
|
protected:
|
|
virtual void main_loop() ;
|
|
};
|
|
|
|
class TService_mask : public TAutomask
|
|
{
|
|
protected:
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
public:
|
|
TService_mask() :TAutomask("dbcv02a.msk"){}
|
|
};
|
|
bool TService_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
{
|
|
switch (o.dlg())
|
|
{
|
|
case DLG_OK:
|
|
if (e == fe_button)
|
|
{
|
|
switch (get_int(F_SERVICE))
|
|
{
|
|
case 1:
|
|
if (noyes_box("Confermi la cancellazione del file degli articoli da escludere ?"))
|
|
{
|
|
TSupport_file morti(LF_DIST, ANAGRAFICA_MORTI);
|
|
morti.zap();
|
|
}
|
|
break;
|
|
case 2:
|
|
crea_mag3();
|
|
break;
|
|
case 3:
|
|
crea_linee3();
|
|
break;
|
|
case 4:
|
|
if (noyes_box("Rinumero le righe delle distinte?"))
|
|
rinumera_dist();
|
|
break;
|
|
case 5:
|
|
if (noyes_box("Rinumero le unita' di misura?"))
|
|
rinumera_ums();
|
|
break;
|
|
case 6:
|
|
if (noyes_box("Le lavorazioni presenti sui finiti verrano spostate sulle varianti di impianto. Confermi?"))
|
|
if (sposta_lavs() && yesno_box("Rinumero le righe di lavorazione?"))
|
|
rinumera_dist();
|
|
break;
|
|
case 7:
|
|
build2levmsp();
|
|
break;
|
|
case 8:
|
|
setformulavar();
|
|
break;
|
|
case 9:
|
|
//check_mag_locations(get(F_PATH),source);
|
|
break;
|
|
case 10:
|
|
evadi_orc(*this, get(S_CODIMP));
|
|
break;
|
|
case 11:
|
|
unevadi_orc(*this, get(S_CODIMP));
|
|
break;
|
|
case 12:
|
|
find_wrongcycle();
|
|
break;
|
|
case 13:
|
|
sinchro_stock(*this, "SE");
|
|
sinchro_stock(*this, "TS");
|
|
break;
|
|
case 14:
|
|
unlink_docs();
|
|
break;
|
|
case 15:
|
|
kill_blank_mag(*this,"SE1");
|
|
break;
|
|
case 16:
|
|
unify_mags(*this);
|
|
break;
|
|
case 17:
|
|
checkexplosions(*this);
|
|
break;
|
|
case 100:
|
|
if (noyes_box("Esporto le lavorazioni?"))
|
|
//exportlavs();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
void TCover_services ::main_loop()
|
|
{
|
|
TService_mask m;
|
|
while (m.run()!=K_QUIT);
|
|
}
|
|
|
|
|
|
int dbcv02(int argc, char* argv[])
|
|
{
|
|
TString name;
|
|
TCover_services dt;
|
|
dt.run(argc, argv, "Utilita' di conversione BPCS");
|
|
return 0;
|
|
}
|