Files correlati : Ricompilazione Demo : [ ] Commento : Riportata la versione 1.7 patch 054 aga sul main trunk git-svn-id: svn://10.65.10.50/trunk@9659 c028cbd2-c16b-5b4b-a496-9718f37d4682
885 lines
29 KiB
C++
Executable File
885 lines
29 KiB
C++
Executable File
#include "dbcv.h"
|
|
#include "dbcv09.h"
|
|
#include "dbcv00a.h"
|
|
#include "dbcv01.h"
|
|
#include "printer.h"
|
|
|
|
#include <automask.h>
|
|
#include <applicat.h>
|
|
#include <execp.h>
|
|
#include "..\mg\anamag.h"
|
|
#include "..\mg\mag.h"
|
|
#include "..\include\doc.h"
|
|
#include "..\include\rdoc.h"
|
|
#include "..\ve\velib.h"
|
|
|
|
#include "dbcvlib.h"
|
|
|
|
class TImpchk_mask : public TAutomask
|
|
{
|
|
protected:
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
public:
|
|
TImpchk_mask() :TAutomask("dbcv03a.msk"){}
|
|
};
|
|
bool TImpchk_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
{
|
|
return TRUE;
|
|
}
|
|
|
|
class TImpchk_BPCS : public TSkeleton_application
|
|
{
|
|
TLocalisamfile * _dist, *_rdist, * _anamag, *_umart, *_codcorr,*_mag;
|
|
private:
|
|
void delete_ghosts();
|
|
void delete_arts();
|
|
bool delete_boms();
|
|
int read_last_rdist(const char *item_code);
|
|
bool read_is_dist(const char *item_code);
|
|
bool is_ghost(const char *item_code);
|
|
const char * read_first_um(const char *item_code);
|
|
void clear_docs(long firm, const char * num, const TDate *fromdate=NULL, const TDate *todate=NULL);
|
|
|
|
protected:
|
|
void add_log_row(TPrinter &prn, TPrintrow &oldrow, const char *m);
|
|
bool compare_item(TPrinter &prn, TPrintrow &prow, const char * anafield, const TString & impfield);
|
|
bool compare_item(TPrinter &prn, TPrintrow &prow, const char * anafield, const real & impfield);
|
|
bool compare_item(TPrinter &prn, TPrintrow &prow, const char * anafield, const long impfield);
|
|
protected:
|
|
virtual bool create();
|
|
virtual bool destroy();
|
|
bool chkimp_boms(TMask &m);
|
|
bool cambia_gmc(TMask & m);
|
|
bool chkimp_arts(TMask &m);
|
|
bool importa_ums_BP(TMask &m);
|
|
protected:
|
|
virtual void main_loop() ;
|
|
};
|
|
|
|
bool TImpchk_BPCS::create()
|
|
{
|
|
open_files(LF_TAB, LF_TABCOM, LF_CLIFO, LF_CFVEN, LF_RIGHEDOC, LF_MOVMAG, LF_RMOVMAG, 0);
|
|
_dist = new TLocalisamfile(LF_DIST);
|
|
_rdist = new TLocalisamfile(LF_RDIST);
|
|
_anamag = new TLocalisamfile(LF_ANAMAG);
|
|
_umart = new TLocalisamfile(LF_UMART);
|
|
_codcorr = new TLocalisamfile(LF_CODCORR);
|
|
_mag = new TLocalisamfile(LF_MAG);
|
|
return TSkeleton_application::create();
|
|
}
|
|
bool TImpchk_BPCS::destroy()
|
|
{
|
|
delete _dist;
|
|
delete _rdist;
|
|
delete _anamag;
|
|
delete _umart;
|
|
delete _codcorr;
|
|
delete _mag;
|
|
return TSkeleton_application::destroy();
|
|
}
|
|
|
|
|
|
int TImpchk_BPCS::read_last_rdist(const char *item_code)
|
|
{
|
|
static TString prevcode="";
|
|
static int nrig=0;
|
|
if (prevcode!=item_code)
|
|
{
|
|
prevcode=item_code;
|
|
nrig=0;
|
|
_rdist->put("CODDIST",item_code);
|
|
int err=_rdist->read(_isgteq);
|
|
while (err==NOERR && _rdist->get("CODDIST")==item_code)
|
|
{
|
|
nrig++;
|
|
err=_rdist->next();
|
|
}
|
|
}
|
|
return ++nrig;
|
|
}
|
|
|
|
bool TImpchk_BPCS::read_is_dist(const char *item_code)
|
|
{
|
|
const TRectype & rec=cache().get(LF_DIST,item_code);
|
|
if (!rec.empty())
|
|
return TRUE;
|
|
return FALSE;
|
|
}
|
|
bool TImpchk_BPCS::is_ghost(const char *item_code)
|
|
{
|
|
const TRectype & rec=cache().get(LF_DIST,item_code);
|
|
if (!rec.empty())
|
|
return rec.get_bool("VIRTUALE") && !rec.get_bool("ARTPROD")&& !rec.get_bool("ARTACQ") ;
|
|
return FALSE;
|
|
}
|
|
const char * TImpchk_BPCS::read_first_um(const char *item_code)
|
|
{
|
|
TToken_string key(item_code);
|
|
key.add(1);
|
|
const TRectype & rec=cache().get(LF_UMART,key);
|
|
if (rec.empty())
|
|
error_box("Impossibile trovare l'item %s",item_code);
|
|
return rec.get("UM");
|
|
}
|
|
|
|
// cancella gli articoli
|
|
void TImpchk_BPCS ::delete_arts()
|
|
{
|
|
message_box("- cancellazione articoli disabilitata -");
|
|
}
|
|
|
|
// cancella le distinte che non sono lavorazioni
|
|
bool TImpchk_BPCS ::delete_boms()
|
|
{
|
|
message_box("- cancellazione distinte disabilitata -");
|
|
return FALSE;
|
|
}
|
|
|
|
// elimina i ghost "di servizio"
|
|
void TImpchk_BPCS ::delete_ghosts()
|
|
{
|
|
message_box("- cancellazione distinte fantasma disabilitata -");
|
|
}
|
|
|
|
bool TImpchk_BPCS::chkimp_boms(TMask &m)
|
|
{
|
|
return TRUE;
|
|
TWait_cursor hourglass;
|
|
cache().flush(LF_DIST);
|
|
cache().flush(LF_ANAMAG);
|
|
cache().flush(LF_UMART);
|
|
|
|
TSupport_file morti(LF_DIST, format("%s\\%s",(const char * ) m.get(F_PATH),ANAGRAFICA_MORTI));
|
|
TImport_file boms(m.get(F_PATH), BPCS_DISTINTE);
|
|
TProgind info(boms.items(),"Importazione distinte...",TRUE,TRUE);
|
|
TToken_string imported_lcode,dead_lcode,skipped_lcode,current_lcode;
|
|
TString old_code,item_code,last_code;
|
|
TString8 impianto,main_imp;
|
|
int bseq=0;
|
|
|
|
boms.first();
|
|
while (!boms.eof())
|
|
{
|
|
info.addstatus(1);
|
|
if (info.iscancelled())
|
|
return FALSE;
|
|
// converte ogni distinta ancora valida
|
|
old_code=(boms.get_codice("BPROD"));
|
|
impianto=(boms.get("BMWHS"));
|
|
int metodo(int(boms.get_long("BMBOMM")));
|
|
current_lcode.add(old_code,0);
|
|
current_lcode.add(impianto,1);
|
|
current_lcode.add(metodo,2);
|
|
|
|
const long ddis=boms.get_long("BDDIS");
|
|
bool skip=!((ddis==99999999)||(ddis==9999999)||(ddis==999999)||(ddis==99999));
|
|
if (skipped_lcode==current_lcode || dead_lcode==current_lcode)
|
|
skip = TRUE;
|
|
if (!skip && m.get_bool(F_CHECKDEADARTS))
|
|
{
|
|
morti.put("CODDIST",old_code);
|
|
if (morti.read()==NOERR)
|
|
{
|
|
skip=TRUE;
|
|
skipped_lcode=current_lcode;
|
|
}
|
|
}
|
|
if (!skip && atol(boms.get("BDEFF"))<m.get_int(F_ANNO)*10000L)
|
|
{
|
|
if (skipped_lcode==current_lcode || dead_lcode==current_lcode)
|
|
skip = TRUE;
|
|
else
|
|
{
|
|
TTimed_skipbox bbox(format("La distinta %s (%s), di %s metodo '%02d', risale al %s; ignoro l'importazione ?",
|
|
(const char *)old_code,
|
|
(const char *)cache().get(LF_ANAMAG,old_code).get("DESCR"),
|
|
(const char *)impianto,
|
|
metodo,
|
|
(const char *)boms.get("BDEFF")),60);
|
|
if (skip=(bbox.run()==K_ESC))
|
|
{
|
|
if (noyes_box("Ignoro l'importazione di tutti i metodi del codice %s?",(const char *) old_code))
|
|
{
|
|
morti.put("CODDIST",old_code);
|
|
morti.write();
|
|
dead_lcode=current_lcode;
|
|
}
|
|
skipped_lcode=current_lcode;
|
|
}
|
|
}
|
|
}
|
|
// importa solo gli impianti SEgrate e TrieSte
|
|
if (!skip && metodo == 99 && (impianto=="SE" || impianto=="TS" ))
|
|
{
|
|
main_imp=impianto;
|
|
do {
|
|
if (impianto == "PD")
|
|
impianto = "PR";
|
|
if (metodo==7)
|
|
{
|
|
impianto = "PD";
|
|
metodo = 0;
|
|
}
|
|
const TString8 father_grmerc= cache().get(LF_ANAMAG,old_code).get("GRMERC");
|
|
if (metodo!=0)
|
|
{
|
|
if (metodo==99)
|
|
{
|
|
if (cache().get(LF_ANAMAG,old_code ).get(ANAMAG_GRMERC)[0]!='F')
|
|
message_box("Il codice %s con metodo 99 non e' un finito",(const char *)old_code);
|
|
// sconfezionamento
|
|
impianto=format("%s9%02d",(const char *)main_imp,metodo);
|
|
if (cache().get("LNP",impianto).empty())
|
|
{
|
|
cache().discard("LNP",impianto);
|
|
// inserisce la linea di sconfezionamento
|
|
TTable imp("LNP");
|
|
imp.put("CODTAB",impianto);
|
|
imp.put("S0","Riconfezionamento/sconfezionamento");
|
|
imp.put("S6",main_imp);
|
|
imp.put("S7",format("%s1",(const char *) impianto));
|
|
imp.put("B9","X");
|
|
//imp.write();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// terzisti
|
|
impianto=format("X%02d%s",metodo,(const char *)main_imp);
|
|
if (cache().get("LNP",impianto).empty())
|
|
{
|
|
cache().discard("LNP",impianto);
|
|
// inserisce il terzista come linea produttiva sull'impianto esterno
|
|
TTable imp("LNP");
|
|
imp.put("CODTAB",impianto);
|
|
imp.put("S0",format("%s (%s)",descr_method(metodo),(const char *) impianto));
|
|
imp.put("S6","XT");
|
|
imp.put("S7",format("%s3%02d",(const char *) impianto,metodo));
|
|
imp.put("B9","X");
|
|
//imp.write();
|
|
}
|
|
}
|
|
}
|
|
// padre
|
|
TString descr,um_f(read_first_um(old_code));
|
|
TString item_code=old_code;
|
|
item_code << "__" << impianto;
|
|
const bool father_ghost= is_ghost(old_code);
|
|
if (father_ghost)
|
|
descr=cache().get(LF_DIST,old_code).get("DESCR");
|
|
else
|
|
descr=cache().get(LF_ANAMAG,old_code).get("DESCR");
|
|
if (!father_ghost && item_code!=last_code)
|
|
{
|
|
// se non e' un fantasma lo definisce come variante (distinta contenente una riga di tipo variabile)
|
|
if (cache().get(LF_DIST,old_code).empty())
|
|
{
|
|
cache().discard(LF_DIST,old_code);
|
|
|
|
_dist->zero();
|
|
_dist->put("CODDIST", old_code);
|
|
_dist->put("DESCR", descr);
|
|
_dist->put("VIRTUALE", " ");
|
|
_dist->put("MASTER", "X");
|
|
_dist->put("ARTPROD", "X");
|
|
_dist->put("UM", um_f);
|
|
TString varvar("VARIANTE=");
|
|
varvar << "_DISTINTA+\"__\"+IF(_IMPIANTO!=\"XT\",_IMPIANTO,_LINEA)" ;
|
|
_dist->put("PARAMETRI",varvar);
|
|
int err=_dist->write();
|
|
if (err!=_isreinsert)
|
|
{
|
|
_rdist->zero();
|
|
_rdist->put("CODDIST", old_code);
|
|
_rdist->put("NRIG", 1 );
|
|
_rdist->put("TIPO", "V" );
|
|
_rdist->put("CODCOMP", "VARIANTE" );
|
|
_rdist->put("UM", "");
|
|
_rdist->put("EXPR", 1 );
|
|
_rdist->write();
|
|
}
|
|
}
|
|
}
|
|
// figlio
|
|
TString son_code=boms.get_codice("BCHLD");
|
|
TString um_s=read_first_um(son_code) ;
|
|
const bool son_ghost=is_ghost(son_code);
|
|
if (son_ghost)
|
|
son_code << "__" << impianto ;
|
|
// scrivi la bom
|
|
if (last_code!=item_code)
|
|
{
|
|
if (cache().get(LF_DIST,item_code).empty())
|
|
{
|
|
cache().discard(LF_DIST,item_code);
|
|
descr << " (impianto " << main_imp << ")";
|
|
_dist->zero(' ');
|
|
_dist->put("CODDIST", item_code);
|
|
_dist->put("DESCR", descr);
|
|
_dist->put("VIRTUALE", "X" );
|
|
_dist->put("ARTPROD", "");
|
|
_dist->put("UM", "BP");
|
|
|
|
if (impianto.left(2)!= "XT")
|
|
{
|
|
// l'albero della distinte di un impianto e' su qyell'impianto
|
|
// i terzisti seguono l'impianto di pianificazione
|
|
TString varimp("_IMPIANTO=");
|
|
varimp << '"'<< main_imp <<'"';
|
|
_dist->put("PARAMETRI",varimp);
|
|
}
|
|
_dist->write(); // fallisce se esiste gia'
|
|
|
|
_umart->zero(' ');
|
|
_umart->put("CODART",item_code);
|
|
_umart->put("NRIGA",1);
|
|
_umart->put("UM",um_f);
|
|
_umart->put("FC","1");
|
|
force_write(*_umart);
|
|
}
|
|
last_code=item_code;
|
|
if (bseq>0 || (impianto != "PD" && impianto != "PR"))
|
|
bseq=0;
|
|
}
|
|
if (impianto == "PD")
|
|
bseq--;
|
|
else if (impianto != "PR")
|
|
bseq++;
|
|
if (bseq==0) error_box("Numero riga 0 per %s / %s",(const char *)item_code,(const char *)son_code);
|
|
_rdist->zero(' ');
|
|
_rdist->put("CODDIST", item_code);
|
|
_rdist->put("NRIG", bseq >0 ? bseq : -bseq);
|
|
if (son_ghost)
|
|
_rdist->put("TIPO", "D");
|
|
else if (son_code=="ACQUA" || son_code=="ACQUADEION")
|
|
_rdist->put("TIPO", "L");
|
|
else
|
|
_rdist->put("TIPO", "A");
|
|
_rdist->put("CODCOMP", son_code );
|
|
_rdist->put("UM", um_s);
|
|
_rdist->put("EXPR", boms.get_real("BQREQ") );
|
|
_rdist->write();
|
|
|
|
imported_lcode=current_lcode;
|
|
} while (impianto == "PD");
|
|
}
|
|
boms.next();
|
|
}
|
|
delete_ghosts();
|
|
return TRUE;
|
|
}
|
|
|
|
void TImpchk_BPCS::add_log_row(TPrinter &prn, TPrintrow &oldrow, const char *m)
|
|
{
|
|
TString mm(m);
|
|
if (oldrow.lastpos())
|
|
prn.print(oldrow);
|
|
oldrow.reset();
|
|
oldrow.put(mm,4);
|
|
prn.print(oldrow);
|
|
oldrow.reset();
|
|
}
|
|
|
|
bool TImpchk_BPCS::compare_item(TPrinter &prn, TPrintrow &prow, const char * anafield,
|
|
const real & impfield)
|
|
{
|
|
real r_eurocampo(_anamag->get_real( anafield));
|
|
if (r_eurocampo != impfield && !impfield.is_zero())
|
|
{
|
|
if (r_eurocampo.is_zero())
|
|
{
|
|
_anamag->put(anafield, impfield);
|
|
return TRUE;
|
|
} else {
|
|
TString messaggio = format("Il campo %s manca dei decimali", anafield);
|
|
messaggio << "(" << r_eurocampo << " invece di " << impfield << "\nAggiorno automaticamente?";
|
|
real r_bpcs(impfield);
|
|
if (r_bpcs.trunc() == r_eurocampo && yesno_box(messaggio))
|
|
{
|
|
_anamag->put(anafield, impfield);
|
|
return TRUE;
|
|
}
|
|
messaggio = anafield;
|
|
messaggio << "=" << _anamag->get_real( anafield) << " , " << impfield << " su BPCS";
|
|
add_log_row(prn, prow, messaggio);
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
bool TImpchk_BPCS::compare_item(TPrinter &prn, TPrintrow &prow, const char * anafield,
|
|
const TString & impfield)
|
|
{
|
|
if (_anamag->get( anafield) != impfield && !impfield.blank())
|
|
if (_anamag->get( anafield).blank())
|
|
{
|
|
_anamag->put( anafield, impfield);
|
|
return TRUE;
|
|
} else {
|
|
add_log_row(prn, prow, format ("%s = '%s', '%s'su BPCS",
|
|
(const char *) anafield,(const char *)_anamag->get( anafield), (const char *)impfield));
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
bool TImpchk_BPCS::compare_item(TPrinter &prn, TPrintrow &prow, const char * anafield,
|
|
const long impfield)
|
|
{
|
|
if (_anamag->get_long( anafield) != impfield && impfield!=0L)
|
|
if (_anamag->get_long( anafield) == 0L)
|
|
{
|
|
_anamag->put( anafield, impfield);
|
|
return TRUE;
|
|
} else {
|
|
add_log_row(prn, prow, format ("%s = '%ld', '%ld'su BPCS",
|
|
(const char *) anafield,_anamag->get_long( anafield), impfield));
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
// importa le ums dal file di anagrafica
|
|
bool TImpchk_BPCS ::chkimp_arts(TMask & m)
|
|
{
|
|
TPrinter prn;
|
|
TPrintrow prow;
|
|
TWait_cursor hourglass;
|
|
cache().flush(LF_ANAMAG);
|
|
cache().flush(LF_DIST);
|
|
cache().flush(LF_UMART);
|
|
|
|
TSupport_file morti(LF_DIST, format("%%%s\\%s",(const char * ) m.get(F_PATH),ANAGRAFICA_MORTI));
|
|
TImport_file items_ext(m.get(F_PATH),BPCS_IMPORTEX);
|
|
TImport_file items(m.get(F_PATH),BPCS_ANAGRAFICA);
|
|
TString item_code,item_type,tmp;
|
|
bool skip;
|
|
|
|
TProgind info(items.items(),"Controllo articoli e distinte fantasma...",TRUE,TRUE);
|
|
prn.open();
|
|
|
|
items_ext.first();
|
|
items.first();
|
|
while (!items.eof())
|
|
{
|
|
info.addstatus(1);
|
|
if (info.iscancelled())
|
|
break;
|
|
item_type=items.get("IITYP");
|
|
if (items.get("IID")=="IM" && atoi(item_type)!=6)
|
|
{
|
|
if (item_type!="0") // non fantasma
|
|
{
|
|
item_code=items.get_codice("IPROD");
|
|
skip=FALSE;
|
|
// sincronizza il file dell'anagrafica Importex
|
|
while (items_ext.get_codice("MSITE")<item_code && !items_ext.eof())
|
|
items_ext.next();
|
|
morti.put("CODDIST",item_code);
|
|
if (morti.read()!=NOERR)
|
|
{
|
|
// *******
|
|
// anagrafica
|
|
_anamag->zero();
|
|
_anamag->put( ANAMAG_CODART,item_code);
|
|
bool newart = (_anamag->read()==_iskeynotfound);
|
|
if (newart && yesno_box("Articolo %s '%s'non trovato:\n lo metto tra gli articoli da ignorare?",
|
|
(const char *)item_code,(const char *)items.get("IDESC")))
|
|
{
|
|
morti.put("CODDIST",item_code);
|
|
morti.put("DESCR",items.get("IDESC"));
|
|
morti.write();
|
|
}
|
|
else
|
|
{
|
|
prow.reset();
|
|
prow.put("Articolo ");
|
|
prow.put(item_code);
|
|
if (newart)
|
|
{
|
|
prow.put(" mancante: inserito in automatico");
|
|
prn.print(prow);
|
|
|
|
_anamag->put( ANAMAG_DESCR,items.get("IDESC"));
|
|
_anamag->put( ANAMAG_DESCRAGG,items.get("IDSCE"));
|
|
_anamag->put( ANAMAG_CODFORN, items.get_long("IVEND"));
|
|
_anamag->put( ANAMAG_UMP, "KG");
|
|
_anamag->put( ANAMAG_PESO, items.get_real("IWGHT"));
|
|
// riordino
|
|
_anamag->put( ANAMAG_RIORDINO , "F"); //_anamag->put( ANAMAG_RIORDINO , items.get("IMRP")=="M" ? "F" : "P" );
|
|
_anamag->put( ANAMAG_GIORNIRIOR, items.get_long("ILEAD"));
|
|
_anamag->put( ANAMAG_LOTTORIOR, items.get_real("ILOTS"));
|
|
_anamag->put( ANAMAG_LOTTOIRIOR, items.get_real("IIOQ"));
|
|
//
|
|
_anamag->put( ANAMAG_PPCONF , items.get_long("IFII"));
|
|
_anamag->put( ANAMAG_PPCOLLO , items.get_long("IFII"));
|
|
TString16 gmc=items.get("IITYP");
|
|
switch (gmc[0])
|
|
{
|
|
case 'F':
|
|
case 'E':
|
|
case 'Z':
|
|
case 'G':
|
|
gmc[0]= 'F'; break;
|
|
case 'M':
|
|
gmc[0]= 'S'; break;
|
|
case 'P':
|
|
gmc[0]= 'C'; break;
|
|
}
|
|
TString16 iclas(items.get("ICLAS"));
|
|
if (!iclas.blank())
|
|
{
|
|
switch (m.get(F_ICLAS)[0])
|
|
{
|
|
case 'S':
|
|
complete_gmc(gmc, iclas);
|
|
break;
|
|
case 'C':
|
|
gmc << iclas;
|
|
break;
|
|
case ' ':
|
|
break;
|
|
}
|
|
}
|
|
_anamag->put( ANAMAG_GRMERC,gmc);
|
|
_anamag->put( ANAMAG_COSTSTD, items.get_real("ISCST"));
|
|
_anamag->put( ANAMAG_ULTCOS1, items.get_real("IACST"));
|
|
tmp=items.get("TAXC1");
|
|
if (tmp.left(3)=="IVA")
|
|
tmp=tmp.sub(3);
|
|
_anamag->put( ANAMAG_CODIVA , tmp);
|
|
if (items_ext.get_codice("MSITE")==items.get_codice("IPROD"))
|
|
{
|
|
_anamag->put( ANAMAG_CLASSDOG , check_clasdog(items_ext.get_long("MSTDO")));
|
|
_anamag->put( ANAMAG_USER1 , items_ext.get_real("MSIDR"));// idrati
|
|
_anamag->put( ANAMAG_USER2 , items_ext.get_real("MSANI"));//anidri
|
|
_anamag->put( ANAMAG_USER3 , items_ext.get("MSTAL"));//alcool
|
|
// dimensioni
|
|
_anamag->put( ANAMAG_USER4, items_ext.get_long("MSPLU"));
|
|
_anamag->put( ANAMAG_USER5, items_ext.get_long("MSPAL"));
|
|
_anamag->put( ANAMAG_USER6, items_ext.get_long("MSPPR"));
|
|
// composizione pallets
|
|
_anamag->put( ANAMAG_USER7, items_ext.get_long("MSCST")); // casse per strato
|
|
_anamag->put( ANAMAG_USER8, items_ext.get_long("MSSTP")); // strati per pallet
|
|
}
|
|
//_anamag.write();
|
|
real smin(items.get("IMIN"));
|
|
if (smin!=ZERO)
|
|
{
|
|
_mag->zero();
|
|
_mag->put(MAG_SCORTAMIN,smin);
|
|
_mag->put(MAG_ANNOES,"1999");
|
|
_mag->put(MAG_CODART,item_code);
|
|
_mag->put(MAG_NRIGA,1);
|
|
_mag->put(MAG_CODMAG,"SE1PF");
|
|
//force_write(*_mag);
|
|
_mag->put(MAG_NRIGA,2);
|
|
_mag->put(MAG_CODMAG,"TS1PF");
|
|
//force_write(*_mag);
|
|
}
|
|
} else {
|
|
bool changed=FALSE;
|
|
bool different=FALSE;
|
|
changed |= compare_item(prn, prow, ANAMAG_DESCR, items.get("IDESC"));
|
|
changed |= compare_item(prn, prow, ANAMAG_DESCRAGG, items.get("IDSCE"));
|
|
changed |= compare_item(prn, prow, ANAMAG_CODFORN, items.get_long("IVEND"));
|
|
if (_anamag->get( ANAMAG_UMP).blank())
|
|
{
|
|
_anamag->put( ANAMAG_UMP,"KG");
|
|
changed = TRUE;
|
|
} else {
|
|
if (_anamag->get( ANAMAG_UMP) != "KG")
|
|
add_log_row(prn, prow, format("Unita' di misura del peso insolita: %s",(const char *)_anamag->get( ANAMAG_UMP)));
|
|
}
|
|
changed |= compare_item(prn, prow, ANAMAG_PESO, items.get_real("IWGHT"));
|
|
// riordino
|
|
if (_anamag->get( ANAMAG_RIORDINO).blank())
|
|
{
|
|
_anamag->put( ANAMAG_RIORDINO,"F");
|
|
changed = TRUE;
|
|
} else {
|
|
if (_anamag->get( ANAMAG_RIORDINO) != "F")
|
|
add_log_row(prn, prow, format("TIpo di riordino insolito: %s",(const char *)_anamag->get( ANAMAG_RIORDINO)));
|
|
}
|
|
changed |= compare_item(prn, prow, ANAMAG_GIORNIRIOR, items.get_long( "ILEAD"));
|
|
changed |= compare_item(prn, prow, ANAMAG_LOTTORIOR, items.get_real( "ILOTS"));
|
|
changed |= compare_item(prn, prow, ANAMAG_LOTTOIRIOR, items.get_real( "IIOQ"));
|
|
//
|
|
changed |= compare_item(prn, prow, ANAMAG_PPCONF, items.get_long("IFII"));
|
|
changed |= compare_item(prn, prow, ANAMAG_PPCOLLO, items.get_long("IFII"));
|
|
TString8 gmc=items.get("IITYP");
|
|
switch (gmc[0])
|
|
{
|
|
case 'F':
|
|
case 'E':
|
|
case 'Z':
|
|
case 'G':
|
|
gmc[0]= 'F'; break;
|
|
case 'M':
|
|
gmc[0]= 'S'; break;
|
|
case 'P':
|
|
gmc[0]= 'C'; break;
|
|
}
|
|
TString16 iclas(items.get("ICLAS"));
|
|
if (!iclas.blank())
|
|
{
|
|
switch (m.get(F_ICLAS)[0])
|
|
{
|
|
case 'S':
|
|
complete_gmc(gmc, iclas);
|
|
break;
|
|
case 'C':
|
|
gmc << iclas;
|
|
break;
|
|
case ' ':
|
|
break;
|
|
}
|
|
}
|
|
changed |= compare_item(prn, prow, ANAMAG_GRMERC, gmc);
|
|
changed |= compare_item(prn, prow, ANAMAG_COSTSTD, items.get_real("ISCST"));
|
|
changed |= compare_item(prn, prow, ANAMAG_ULTCOS1, items.get_real("IACST"));
|
|
tmp=items.get("TAXC1");
|
|
if (tmp.left(3)=="IVA")
|
|
tmp=tmp.sub(3);
|
|
changed |= compare_item(prn, prow, ANAMAG_CODIVA, tmp);
|
|
|
|
if (items_ext.get_codice("MSITE")==items.get_codice("IPROD"))
|
|
{
|
|
changed |= compare_item(prn, prow, ANAMAG_CLASSDOG, atol(check_clasdog(items_ext.get_long("MSTDO"))));
|
|
changed |= compare_item(prn, prow, ANAMAG_USER1, items_ext.get_real("MSIDR"));
|
|
changed |= compare_item(prn, prow, ANAMAG_USER2, items_ext.get_real("MSANI"));
|
|
changed |= compare_item(prn, prow, ANAMAG_USER3, items_ext.get("MSTAL"));
|
|
// dimensioni
|
|
changed |= compare_item(prn, prow, ANAMAG_USER4, items_ext.get_long("MSPLU"));
|
|
changed |= compare_item(prn, prow, ANAMAG_USER5, items_ext.get_long("MSPAL"));
|
|
changed |= compare_item(prn, prow, ANAMAG_USER6, items_ext.get_long("MSPPR"));
|
|
// composizione pallets
|
|
changed |= compare_item(prn, prow, ANAMAG_USER7, items_ext.get_long("MSCST"));
|
|
changed |= compare_item(prn, prow, ANAMAG_USER8, items_ext.get_long("MSSTP"));
|
|
}
|
|
//_anamag.write();
|
|
real smin(items.get("IMIN"));
|
|
if (smin!=ZERO)
|
|
{
|
|
_mag->zero();
|
|
_mag->put(MAG_SCORTAMIN,smin);
|
|
_mag->put(MAG_ANNOES,"1999");
|
|
_mag->put(MAG_CODART,item_code);
|
|
_mag->put(MAG_NRIGA,1);
|
|
_mag->put(MAG_CODMAG,"SE1PF");
|
|
//force_write(*_mag);
|
|
_mag->put(MAG_NRIGA,2);
|
|
_mag->put(MAG_CODMAG,"TS1PF");
|
|
//force_write(*_mag);
|
|
}
|
|
if (changed)
|
|
_anamag->rewrite();
|
|
}
|
|
} // inserisco - ignoro
|
|
// *******
|
|
// UMS
|
|
TString4 um,ums(items.get("IUMS"));
|
|
real fc;
|
|
int nriga=1;
|
|
for (int u=0; u<3; u++)
|
|
{
|
|
switch (u)
|
|
{
|
|
case 1:
|
|
um=items.get("IUMP");
|
|
fc=items.get_real("IUMCN");
|
|
break;
|
|
case 2:
|
|
um=items.get("IUMR");
|
|
fc=items.get_real("IUMRC");
|
|
break;
|
|
default:
|
|
um=ums;
|
|
fc=1.0;
|
|
}
|
|
if (!um.blank() && (u==0 || um!=ums))
|
|
{
|
|
_umart->zero();
|
|
_umart->put("CODART",item_code);
|
|
_umart->put("NRIGA",nriga);
|
|
_umart->put("UM",um);
|
|
if (nriga==1)
|
|
_umart->put("PREZZO",items.get("ILIST"));
|
|
_umart->put("FC",fc);
|
|
//force_write(*_umart);
|
|
nriga++;
|
|
}
|
|
} // fine ciclo unita' di misura
|
|
long ean=items.get_long("IDRAW");
|
|
if (!m.get(F_EAN).blank())
|
|
{
|
|
TString16 eancode=items.get("IDRAW");
|
|
if (ean!=0L || (eancode[0]>='A' && eancode[0]<='Z' && atol(eancode.sub(1))!=0L))
|
|
{
|
|
_codcorr->zero();
|
|
_codcorr->put("CODARTALT",eancode);
|
|
_codcorr->put("NRIGA",1);
|
|
_codcorr->put("TIPO",m.get(F_EAN));
|
|
_codcorr->put("CODART",item_code);
|
|
//force_write(*_codcorr);
|
|
}
|
|
}
|
|
} // controllo morti
|
|
} // articolo magazzino
|
|
} // record type check
|
|
items.next();
|
|
} // while
|
|
prn.close();
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
bool TImpchk_BPCS ::cambia_gmc(TMask & m)
|
|
{
|
|
TWait_cursor hourglass;
|
|
cache().flush(LF_ANAMAG);
|
|
cache().flush(LF_DIST);
|
|
cache().flush(LF_UMART);
|
|
|
|
TImport_file items_ext(m.get(F_PATH),BPCS_IMPORTEX);
|
|
TImport_file items(m.get(F_PATH),BPCS_ANAGRAFICA);
|
|
TString item_code,item_type,tmp;
|
|
TProgind info(items.items(),"Importazione gruppi merceologici e classi doganali",TRUE,TRUE);
|
|
items_ext.first();
|
|
items.first();
|
|
while (!items.eof())
|
|
{
|
|
info.addstatus(1);
|
|
if (info.iscancelled())
|
|
return FALSE;
|
|
item_type=items.get("IITYP");
|
|
if (items.get("IID")=="IM" && atoi(item_type)!=6)
|
|
{
|
|
item_code=items.get_codice("IPROD");
|
|
if (item_type!="0") // fantasma
|
|
{
|
|
_anamag->zero();
|
|
_anamag->put( ANAMAG_CODART,item_code);
|
|
if (_anamag->read()==NOERR)
|
|
{
|
|
// sincronizza il file dell'anagrafica Importex
|
|
while (items_ext.get_codice("MSITE")<item_code && !items_ext.eof())
|
|
items_ext.next();
|
|
if (items_ext.get_codice("MSITE")==items.get_codice("IPROD"))
|
|
{
|
|
TString cld=check_clasdog(items_ext.get_long("MSTDO"));
|
|
if (!cld.blank())
|
|
_anamag->put( ANAMAG_CLASSDOG , cld);
|
|
}
|
|
TString16 gmc=items.get("IITYP");
|
|
switch (gmc[0])
|
|
{
|
|
case 'F':
|
|
case 'E':
|
|
case 'Z':
|
|
case 'G':
|
|
gmc[0]= 'F'; break; // finiti
|
|
case 'M':
|
|
gmc[0]= 'S'; break; // semilavorati ()
|
|
case 'P':
|
|
gmc[0]= 'C'; break; // componenti (parts)
|
|
}
|
|
TString16 iclas(items.get("ICLAS"));
|
|
if (!iclas.blank())
|
|
{
|
|
switch (m.get(F_ICLAS)[0])
|
|
{
|
|
case 'S':
|
|
complete_gmc(gmc, iclas);
|
|
break;
|
|
case 'C':
|
|
gmc << iclas;
|
|
break;
|
|
case ' ':
|
|
break;
|
|
}
|
|
}
|
|
_anamag->put( ANAMAG_GRMERC,gmc);
|
|
_anamag->rewrite();
|
|
}
|
|
}
|
|
}
|
|
items.next();
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
// importa le ums dal file dei divisori
|
|
bool TImpchk_BPCS ::importa_ums_BP(TMask & m)
|
|
{
|
|
return TRUE;
|
|
TWait_cursor hourglass;
|
|
cache().flush(LF_UMART);
|
|
|
|
TImport_file divisori(m.get(F_PATH),BPCS_DIVISORI);
|
|
TProgind info(divisori.items(),"Importazione divisori (batch di produzione)...",TRUE,TRUE);
|
|
divisori.first();
|
|
TString item_code,impianto;
|
|
while (!divisori.eof())
|
|
{
|
|
info.addstatus(1);
|
|
if (info.iscancelled())
|
|
return FALSE;
|
|
impianto=divisori.get("ICFAC");
|
|
if (impianto=="SE" || impianto == "TS")
|
|
{
|
|
for (int falsi_terzisti=0;falsi_terzisti<3; falsi_terzisti++)
|
|
{
|
|
item_code=(divisori.get_codice("ICPROD"));
|
|
item_code << "__";
|
|
switch (falsi_terzisti)
|
|
{
|
|
case 1:
|
|
item_code << "PD"; break;
|
|
case 2:
|
|
item_code << "PR"; break;
|
|
default:
|
|
item_code << impianto; break;
|
|
}
|
|
if (read_is_dist(item_code))
|
|
{
|
|
_umart->zero();
|
|
_umart->put("CODART",item_code);
|
|
_umart->put("NRIGA",2);
|
|
_umart->put("UM","BP");
|
|
_umart->put("FC",divisori.get("ICBTCH"));
|
|
force_write(*_umart);
|
|
}
|
|
}
|
|
}
|
|
divisori.next();
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void TImpchk_BPCS ::main_loop()
|
|
{
|
|
TImpchk_mask m;
|
|
while (m.run()!=K_QUIT)
|
|
{
|
|
bool ok = TRUE;
|
|
ok &= chkimp_arts(m); // articoli e distinte virtuali fantasma
|
|
ok &= chkimp_boms(m); // distinte non fantasma
|
|
ok &= importa_ums_BP(m);
|
|
if (ok)
|
|
message_box("Operazione conclusa");
|
|
else
|
|
message_box("Operazione interrotta");
|
|
}
|
|
}
|
|
|
|
|
|
int dbcv03(int argc, char* argv[])
|
|
{
|
|
int n = argc > 1 ? (argv[1][1] - '0') : 0;
|
|
TImpchk_BPCS dt;
|
|
dt.run(argc, argv, "Controllo archivi importati da BPCS");
|
|
|
|
return 0;
|
|
}
|