Riportate dalla 3.3 personalizzazioni MRP per cliente DB Service

git-svn-id: svn://10.65.10.50/branches/R_10_00@22678 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2012-06-18 14:13:00 +00:00
parent 53d90d8c95
commit 48d079a2c3
14 changed files with 1593 additions and 1642 deletions

View File

@ -4,4 +4,3 @@
#define F_CODCLI 103
#define F_RAGSOC 104
#define F_PAGEBREAK 105

View File

@ -1,5 +1,25 @@
#include "ps0920100a.h"
TOOLBAR "topbar" 0 0 0 2
BUTTON DLG_OK 10 2
BEGIN
PROMPT -13 -1 ""
PICTURE TOOL_PRINT
END
BUTTON DLG_SELECT 10 2
BEGIN
PROMPT -23 -1 "~Seleziona"
END
BUTTON DLG_QUIT 10 2
BEGIN
PROMPT -33 -1 ""
END
ENDPAGE
PAGE "Stampa ordini di produzione" -1 -1 80 11
GROUPBOX -1 78 5
@ -81,21 +101,7 @@ BEGIN
GROUP 1
END
BUTTON DLG_OK 10 2
BEGIN
PROMPT -13 -1 ""
END
BUTTON DLG_SELECT 10 2
BEGIN
PROMPT -23 -1 "~Seleziona"
END
BUTTON DLG_QUIT 10 2
BEGIN
PROMPT -33 -1 ""
END
ENDPAGE
ENDMASK

View File

@ -6,6 +6,3 @@
#define F_NDOCDA 105
#define F_NDOCA 106
#define F_CODIVA 107

View File

@ -1,5 +1,9 @@
#include "ps0920200a.h"
TOOLBAR "topbar" 0 0 0 2
#include <elabar.h>
ENDPAGE
PAGE "Aggiornamento IVA Documenti" -1 -1 80 12
GROUPBOX -1 78 5
@ -135,16 +139,6 @@ BEGIN
GROUP 1
END
BUTTON DLG_OK 10 2
BEGIN
PROMPT -12 -1 ""
END
BUTTON DLG_QUIT 10 2
BEGIN
PROMPT -22 -1 ""
END
ENDPAGE
ENDMASK

View File

@ -6,6 +6,7 @@
#include "../db/dblib.h"
#include "../ve/velib.h"
#include "../mr/mrplib.h"
#include "ps0920.h"
#include "ps0920300a.h"
@ -61,6 +62,8 @@ bool TPianifica_impianti_mask::on_field_event(TOperable_field& o, TField_event e
class TPianifica_impianti : public TSkeleton_application
{
TPianifica_impianti_mask * _mask;
TArray _target_dates;
virtual bool check_autorization() const {return false;}
virtual const char * extra_modules() const {return "ve";}
bool find_my_sister_row(const TRiga_documento& source_row, const TString& a_codnum, const TCodice_articolo& son_codartmag,
@ -83,12 +86,11 @@ void TPianifica_impianti::delete_old_docs()
TDate dadata = _mask->get_date(F_DADATA);
TDate adata = _mask->get_date(F_ADATA);
const int lastday = adata - dadata;
const int anno = dadata.year();
const TString& codnum = _mask->get(F_ANUM); //accoppa i documenti con numerazione di destinazione..
const TString& impianto = _mask->get(F_DAIMP); //..e con l'impianto sorgente! (rompe la supersimmetria)
const TString& codnum = _mask->get(F_NUM); //accoppa i documenti con numerazione sorgente
const TString& impianto = _mask->get(F_AIMP); //..e con l'impianto destinazione
TRelation rel_doc(LF_DOC);
TRectype darec(LF_DOC), arec(LF_DOC);
TDate from(1, 1, anno - 1);
TDate to(31, 12, anno);
@ -111,8 +113,8 @@ void TPianifica_impianti::delete_old_docs()
cur_doc.freeze();
TProgind progind(items, "Eliminazione vecchi documenti in corso...", false, true);
dadata += _delays[0];
adata += _delays[lastday ];
dadata = (TDate&) _target_dates[0];
adata = (TDate&) _target_dates[lastday];
for (cur_doc = 0; cur_doc.pos() < items; ++cur_doc)
{
progind.addstatus(1);
@ -141,57 +143,16 @@ void TPianifica_impianti::delete_old_docs()
} //for(cur_doc..
}
bool TPianifica_impianti::find_my_sister_row(const TRiga_documento& source_row, const TString& a_codnum,
const TCodice_articolo& son_codartmag,
const TString& a_impianto, TRectype& sister_row,
TLog_report& log) const
{
TRelation rel_righedoc(LF_RIGHEDOC);
TString filtro;
filtro << "(CODNUM='" << a_codnum << "')&&";
filtro << "(IMPIANTO='" << a_impianto << "')&&";
filtro << "(CODARTMAG='" << son_codartmag << "')";
TCursor cur_righedoc(&rel_righedoc, filtro, 4, &source_row, &source_row);
const long items = cur_righedoc.items();
if (items != 1)
{
TString errore;
if (items == 0)
{
errore.format("Non ci sono documenti per l'articolo %s", (const char*)son_codartmag);
log.log(2, errore);
}
else
{
errore.format("Ci sono %ld documenti per l'articolo %s", items, (const char*)son_codartmag);
log.log(1, errore);
}
}
if (items > 0)
{
cur_righedoc = 0;
sister_row = cur_righedoc.curr();
}
return items > 0;
}
void TPianifica_impianti::create_new_docs(TLog_report& log)
{
const TDate dadata = _mask->get_date(F_DADATA);
const TDate adata = _mask->get_date(F_ADATA);
const int anno = dadata.year();
const TString& da_codnum = _mask->get(F_DANUM); //crea documenti con numerazioni sorgenti...
const TString& codnum = _mask->get(F_NUM); //crea documenti con numerazioni sorgenti...
const TString& da_impianto = _mask->get(F_DAIMP); //..con l'impianto sorgente! (conserva la supersimmetria)
//questi servono dopo!!!
const TString& a_codnum = _mask->get(F_ANUM);
const int ritardo = _mask->get_int(F_RITARDO);
const TString& a_impianto = _mask->get(F_AIMP);
TRelation rel_doc(LF_DOC);
TRectype darec(LF_DOC), arec(LF_DOC);
TLocalisamfile db(LF_RDIST);
TDate from(1, 1, anno - 1);
@ -199,27 +160,24 @@ void TPianifica_impianti::create_new_docs(TLog_report& log)
db.setkey(2);
darec.put(DOC_DATADOC, from);
darec.put(DOC_PROVV, "D");
darec.put(DOC_ANNO, anno);
darec.put(DOC_CODNUM, da_codnum);
darec.put(DOC_CODNUM, codnum);
arec.put(DOC_DATADOC, to);
arec.put(DOC_PROVV, "D");
arec.put(DOC_ANNO, anno);
arec.put(DOC_CODNUM, da_codnum);
arec.put(DOC_CODNUM, codnum);
TString filtro;
filtro << "CODNUM='" << da_codnum << "'";
TDistinta_tree albero;
filtro << "CODNUM='" << codnum << "'";
TCursor cur_doc (&rel_doc, filtro, 3, &darec, &arec);
const long items = cur_doc.items();
cur_doc.freeze();
TProgind progind(items, "Generazione nuovi documenti in corso...", false, true);
TDistinta_tree albero;
TRectype sister_row(LF_RIGHEDOC);
for (cur_doc = 0; cur_doc.pos() < items; ++cur_doc)
for (cur_doc = 0; cur_doc.pos() < items; ++cur_doc)
{
progind.addstatus(1);
TDocumento doc(cur_doc.curr());
@ -244,7 +202,7 @@ void TPianifica_impianti::create_new_docs(TLog_report& log)
if (ndays > 365)
continue;
datacons += _delays[ndays];
datacons = (TDate &)_target_dates[ndays];
nuovo_doc.put(DOC_DATACONS, datacons);
for (int i = 1; i <= doc.rows(); i++)
@ -252,8 +210,6 @@ void TPianifica_impianti::create_new_docs(TLog_report& log)
const TRiga_documento& source_row = doc[i]; //riga del documento sorgente
const TString80 codice(source_row.get(RDOC_CODARTMAG));
if (codice == "008BTN008033MP01")
int i = 1;
//il casino va fatto solo se la riga non e' gia' evasa, l'impianto e' quello selezionato e la riga e' riga articolo
if (source_row.get(RDOC_IMPIANTO) == da_impianto && source_row.is_articolo())
@ -265,42 +221,25 @@ void TPianifica_impianti::create_new_docs(TLog_report& log)
if (err == NOERR && codice == db.get("CODCOMP"))
{
TCodice_articolo son_codartmag;
albero.curr_code(son_codartmag); //e' risalito al codice dell'articolo figlio
//cerca la riga sua sorella, ovvero quella che viene dalla stessa riga ordine mamma originaria
if (find_my_sister_row(source_row, a_codnum, son_codartmag, a_impianto, sister_row, log))
const TCodice_articolo dest_codart = db.get("CODDIST");
TArray labors;
bool found = false;
albero.set_root(dest_codart);
for (TRiga_esplosione * l = albero.first_labor(labors); l != NULL && !found; l = albero.next_labor(labors))
{
TDate datacons = sister_row.get_date(RDOC_DATACONS);
//ignora righe con data consegna fuori dal range selezionato
if (datacons < dadata || datacons > adata)
continue;
datacons += ritardo;
const int priority = sister_row.get_int(RDOC_PRIORITY);
TLavorazione * lav = TDistinta_tree::find_labor(l);
//crea un documento...
TDocumento nuovo_doc('D', anno, a_codnum, 0);
nuovo_doc.copy_data(nuovo_doc, doc);
nuovo_doc.put(DOC_TIPODOC, a_codnum); //il tipo deve corrispondere alla numerazione!
//..e la sua riga vuota
TRiga_documento& nuova_rigadoc = nuovo_doc.new_row(source_row.get(RDOC_TIPORIGA));
//riempie la nuova riga
nuovo_doc.copy_data(nuova_rigadoc, source_row);
nuova_rigadoc.put(RDOC_PRIORITY, priority);
nuova_rigadoc.put(RDOC_DATACONS, datacons);
//..e alla fine scrive testata e riga!!
int err = nuovo_doc.write();
if (err != NOERR)
if (lav != NULL && a_impianto == lav->cod_impianto(0))
{
TString errore;
errore.format("Errore %d nella scrittura del documento %ld", err, nuovo_doc.get_long(DOC_NDOC));
log.log(2, errore);
}
const int priority = source_row.get_int(RDOC_PRIORITY);
TDate datacons = source_row.get_date(RDOC_DATACONS);
if (!datacons.ok())
datacons = h_datacons;
const int ndays = datacons - dadata;
datacons += _delays[ndays];
datacons = (TDate &)_target_dates[ndays];
if (datacons < dadata || datacons > adata)
continue;
//..e la sua riga vuota
@ -316,7 +255,7 @@ void TPianifica_impianti::create_new_docs(TLog_report& log)
datacons = source_row.get_date(RDOC_DATACONS);
if (datacons.ok())
{
datacons += _delays[ndays];
datacons = (TDate &)_target_dates[ndays];
nuova_rigadoc.put(RDOC_DATACONS, datacons);
}
nuova_rigadoc.put(RDOC_IMPIANTO, a_impianto);
@ -324,11 +263,20 @@ void TPianifica_impianti::create_new_docs(TLog_report& log)
nuova_rigadoc.put(RDOC_LINEA, linea);
found = true;
}
}
}
} //if(source_row.get...
} //for(int i...
if (nuovo_doc.physical_rows() > 0)
{
int err = nuovo_doc.write();
if (err != NOERR)
{
TString errore;
errore.format("Errore %d nella scrittura del documento %ld", err, nuovo_doc.get_long(DOC_NDOC));
log.log(2, errore);
}
}
} //for(cur_doc...
}
@ -338,26 +286,47 @@ void TPianifica_impianti::main_loop()
{
TDate dadata = _mask->get_date(F_DADATA);
TDate adata = _mask->get_date(F_ADATA);
TDate data;
TDate data, end_date;
const TString8 impianto = _mask->get(F_AIMP);
const TString8 linea = _mask->get(F_LIN);
TMRP_calendar c(linea, impianto);
int ndays = adata - dadata + 1;
const int ritardo = _mask->get_int(F_RITARDO);
_delays[0] = ritardo;
int min, max;
data = dadata;
end_date = dadata;
end_date += ritardo;
if (!data.is_holiday() && data.wday() != 6)
{
c.turni(end_date, min, max);
while (max == 0 || end_date.is_holiday() || end_date.wday() == 6)
c.turni(++end_date, min, max);
}
_target_dates.add(end_date, 0);
for (int i = 1; i < 366; i++)
{
data = dadata;
data += i;
const TDate workdate = data;
end_date = (TDate &) _target_dates[i - 1];
++end_date;
if (!data.is_holiday() && data.wday() != 6)
{
TDate end_date = data;
end_date += _delays[i - 1];
while (end_date.is_holiday() || end_date.wday() == 6)
c.turni(end_date, min, max);
while (max == 0 || end_date.is_holiday() || end_date.wday() == 6)
{
++end_date;
_delays[i] = end_date - workdate;
c.turni(end_date, min, max);
}
}
else
_delays[i] = _delays [i - 1];
if (end_date - data > ritardo)
--end_date;
_target_dates.add(end_date, i);
}
delete_old_docs(); //intanto accoppa i vecchi documenti di tipo destinazione
//poi crea i nuovi documenti di produzione
@ -369,6 +338,7 @@ void TPianifica_impianti::main_loop()
buc.add(log);
buc.preview();
}
}
bool TPianifica_impianti::create()
{

View File

@ -1,7 +1,5 @@
#define F_DANUM 101
#define F_DANUMDESC 102
#define F_ANUM 103
#define F_ANUMDESC 104
#define F_NUM 101
#define F_NUMDESC 102
#define F_DAIMP 105
#define F_DAIMPDESC 106
#define F_AIMP 107
@ -10,3 +8,5 @@
#define F_ADATA 110
#define F_RITARDO 111
#define F_PROFILO 120
#define F_LIN 121
#define F_LINDESC 122

View File

@ -1,37 +1,41 @@
#include "ps0920300a.h"
PAGE "Pianificazione impianti" -1 -1 80 14
TOOLBAR "topbar" 0 0 0 2
#include <elabar.h>
ENDPAGE
PAGE "Pianificazione impianti" -1 -1 80 16
GROUPBOX -1 78 4
BEGIN
PROMPT 1 1 "@bArea da pianificare"
PROMPT 1 1 "@bArea pianificata"
FLAGS ""
END
STRING F_DANUM 4
STRING F_NUM 4
BEGIN
PROMPT 2 2 "Numerazione "
HELP "Codice numerazione"
USE %NUM
INPUT CODTAB F_DANUM
INPUT CODTAB F_NUM
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@50" S0
OUTPUT F_DANUM CODTAB
OUTPUT F_DANUMDESC S0
OUTPUT F_NUM CODTAB
OUTPUT F_NUMDESC S0
CHECKTYPE REQUIRED
FLAGS "UPA"
WARNING "Numerazione assente"
END
STRING F_DANUMDESC 50
STRING F_NUMDESC 50
BEGIN
PROMPT 23 2 ""
HELP "Descrizione numerazione"
USE %NUM KEY 2
INPUT S0 F_DANUMDESC
INPUT S0 F_NUMDESC
DISPLAY "Descrizione@60" S0
DISPLAY "Codice" CODTAB
COPY OUTPUT F_DANUM
COPY OUTPUT F_NUM
END
STRING F_DAIMP 5
@ -58,41 +62,15 @@ STRING F_DAIMPDESC 50
COPY OUTPUT F_DAIMP
END
GROUPBOX -1 78 4
GROUPBOX -1 78 3
BEGIN
PROMPT 1 6 "@bArea pianificata"
PROMPT 1 6 "@bArea da pianificare"
FLAGS ""
END
STRING F_ANUM 4
BEGIN
PROMPT 2 7 "Numerazione "
HELP "Codice numerazione"
COPY USE F_DANUM
INPUT CODTAB F_ANUM
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@50" S0
OUTPUT F_ANUM CODTAB
OUTPUT F_ANUMDESC S0
CHECKTYPE REQUIRED
FLAG "UPA"
WARNING "Numerazione assente"
END
STRING F_ANUMDESC 50
BEGIN
PROMPT 23 7 ""
HELP "Descrizione numerazione"
USE %NUM KEY 2
INPUT S0 F_ANUMDESC
DISPLAY "Descrizione@60" S0
DISPLAY "Codice" CODTAB
COPY OUTPUT F_ANUM
END
STRING F_AIMP 5
BEGIN
PROMPT 2 8 "Impianto "
PROMPT 2 7 "Impianto "
COPY USE F_DAIMP
INPUT CODTAB F_AIMP
DISPLAY "Codice@5" CODTAB
@ -106,7 +84,7 @@ END
STRING F_AIMPDESC 50
BEGIN
PROMPT 23 8 ""
PROMPT 23 7 ""
USE IMP KEY 2
INPUT S0 F_AIMPDESC
DISPLAY "Descrizione@60" S0
@ -114,21 +92,46 @@ STRING F_AIMPDESC 50
COPY OUTPUT F_AIMP
END
STRING F_LIN 5
BEGIN
PROMPT 2 10 "Linea "
USE LNP
INPUT CODTAB F_LIN
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@60" S0
OUTPUT F_LIN CODTAB
OUTPUT F_LINDESC S0
CHECKTYPE REQUIRED
FLAGS "UZ"
WARNING "E la linea ? "
END
STRING F_LINDESC 50
BEGIN
PROMPT 23 10 ""
USE LNP KEY 2
INPUT S0 F_LINDESC
DISPLAY "Descrizione@60" S0
DISPLAY "Codice" CODTAB
OUTPUT F_LINDESC S0
OUTPUT F_LIN CODTAB
END
DATE F_DADATA
BEGIN
PROMPT 2 10 "Dalla data "
PROMPT 2 12 "Dalla data "
CHECKTYPE REQUIRED
END
DATE F_ADATA
BEGIN
PROMPT 35 10 "Alla data "
PROMPT 35 12 "Alla data "
CHECKTYPE REQUIRED
END
NUMBER F_RITARDO 2
BEGIN
PROMPT 2 11 "Giorni di ritardo "
PROMPT 2 13 "GG.Ritardo "
FLAGS "U"
END
@ -138,16 +141,6 @@ BEGIN
PSELECT
END
BUTTON DLG_OK 10 2
BEGIN
PROMPT -12 -1 ""
END
BUTTON DLG_QUIT 10 2
BEGIN
PROMPT -22 -1 ""
END
ENDPAGE
ENDMASK

View File

@ -295,7 +295,7 @@ void TRiepilogoProduzionePs0920::main_loop()
out.set("AN", "Anno");
out.set("NR", "Numero");
out.set("AR", "Articolo");
for (i = 0; i < items;i++)
for (int i = 0; i < items;i++)
{
out.set(format("Q%1d", i), cache().get("IMP", (TString &)keysimp[i], "S0"));
out.set(format("S%1d", i), "");
@ -306,7 +306,7 @@ void TRiepilogoProduzionePs0920::main_loop()
out.set("AN", "");
out.set("NR", "");
out.set("AR", "");
for (i = 0; i < items;i++)
for (int i = 0; i < items;i++)
{
out.set(format("Q%1d", i), "Quantità");
out.set(format("S%1d", i), "Scarto");
@ -323,7 +323,7 @@ void TRiepilogoProduzionePs0920::main_loop()
TProgind pi(items, "Esportazione");
for (i = 0; i < items; i++)
for (int i = 0; i < items; i++)
{
pi.addstatus(1L);
TShuttle * s = (TShuttle *) _riepilogo.objptr((TString &)keys[i]);

View File

@ -5,4 +5,3 @@
#define F_RAGSOC 104
#define F_PATH 105
#define F_NAME 106

View File

@ -2,6 +2,9 @@
PAGE "Selezione Produzione" -1 -1 80 14
TOOLBAR "topbar" 0 0 0 2
#include <elabar.h>
ENDPAGE
DATE F_DADATA
BEGIN
@ -68,16 +71,6 @@ BEGIN
GROUP 1
END
BUTTON DLG_OK 10 2
BEGIN
PROMPT -12 -1 ""
END
BUTTON DLG_QUIT 10 2
BEGIN
PROMPT -22 -1 ""
END
ENDPAGE
ENDMASK