Correzioni per DBService: creazione righe vuote indesiderate

git-svn-id: svn://10.65.10.50/branches/R_10_00@22962 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2014-06-24 12:42:42 +00:00
parent 94d1f9bf28
commit 0b7472f1db
4 changed files with 146 additions and 136 deletions

View File

@ -849,10 +849,10 @@ TMSP_constraint* TPlanning_mask::find_constraint(const TMSP_line& l, bool force_
}
}
TString da_rdoc_key(l.da_rdoc_key());
const TString da_rdoc_key = l.da_rdoc_key();
// cerca il vincolo con - stesso magazzino , impianto e linea
TMSP_constraint* c = _constraints.find(codcli, l.articolo(), l.livgiac(), codimp, codlin, codmag, EMPTY_STRING, da_rdoc_key);
TMSP_constraint* c = _constraints.find(codcli, l.articolo(), l.livgiac(), codimp, codlin, codmag, EMPTY_STRING, da_rdoc_key);
if (c == NULL )
{
long try_cli = codcli;
@ -1153,7 +1153,7 @@ bool TPlanning_mask::remove_propose(bool verbose)
bool remove_all = false;
bool some = _proposed_articles.items() > 0L; // proposte attuali
if (some)
remove = (!verbose || yesno_box(TR("Vuoi annullare le nuove proposte?")));
remove = (!verbose || yesno_box(TR("Si desiderano annullare le nuove proposte?")));
if (!some && verbose)
{
if (load_MRP_lines(_actual_plan))
@ -1161,8 +1161,8 @@ bool TPlanning_mask::remove_propose(bool verbose)
some = _mrp_articles.items() > 0L;
if (some)
{
remove = (noyes_box(TR("Vuoi annullare tutte le pianificazioni non confermate?")));
if (remove && get_bool(F_RESCHEDULING) && noyes_box(TR("Vuoi annullare anche le pianificazioni confermate?")))
remove = (delete_box(TR("Si desiderano annullare tutte le pianificazioni non confermate?")));
if (remove && get_bool(F_RESCHEDULING) && delete_box(TR("Vuoi annullare anche le pianificazioni confermate?")))
remove_all = true;
}
if (!remove)
@ -1211,11 +1211,11 @@ void TPlanning_mask::add_or_sub_propose(char sign, bool scheduled)
TSheet_field& sf = sfield(F_ARTICOLI);
for (long new_row=0; new_row < new_rows; new_row++)
{
const TMRP_line & a=_proposed_articles[new_row];
const TMRP_line& a = _proposed_articles[new_row];
TMSP_line line(a.codclifor(), a.articolo(), a.livgiac(), a.codimp(), a.codlin(), a.codmagdep(), a.codmagdep_coll(), a.da_rdoc_key());
bool line_found = false;
TMSP_constraint* constraint = find_constraint(line, false);
TMSP_constraint* constraint = find_constraint(line, false);
if (constraint == NULL)
{
if (sign < 0)
@ -1247,12 +1247,15 @@ void TPlanning_mask::add_or_sub_propose(char sign, bool scheduled)
if (!sf.cell_disabled(art_row, F_BUCKET1-FIRST_FIELD))
{
line_found=(a.codclifor()==codcli && a.articolo()==codart && a.livgiac()==liv
&& a.codimp()==codimp && a.codlin()==codlin && a.codmagdep()==mag && a.da_rdoc_key() == da_rdoc_key);
line_found=(a.codclifor()==codcli && a.articolo()==codart && a.livgiac()==liv &&
a.codimp()==codimp && a.codlin()==codlin && a.codmagdep()==mag &&
(a.da_rdoc_key() == da_rdoc_key) || (a.da_rdoc_key().blank() && da_rdoc_key.blank()));
if (line_found)
break;
} else {
TMSP_constraint* currcons=_constraints.find(codcli, codart, liv, codimp, codlin, mag, magc, da_rdoc_key);
}
else
{
TMSP_constraint* currcons = _constraints.find(codcli, codart, liv, codimp, codlin, mag, magc, da_rdoc_key);
if (constraint == currcons)
break;
}
@ -1485,7 +1488,8 @@ void TPlanning_mask::propose_1stJIT(TMSP_logic logic, bool check_machine, bool c
TDate dbuck(starting_date());
dbuck +=buck*days_per_bucket();
round_date(dbuck);
message_box(FR("Quantita' proposte a partire dal %s (colonna %d)"), (const char *)dbuck.string(),buck);
message_box(FR("Quantità proposte a partire dal %s (colonna %d)"),
(const char *)dbuck.string(),buck);
}
else
message_box(TR("Nessuna nuova proposta"));
@ -1501,132 +1505,136 @@ void TPlanning_mask::propose_1stJIT(TMSP_logic logic, bool check_machine, bool c
}
void TPlanning_mask::review_cell(long mrp_row, int bucket, bool check_machine, bool check_human, bool useextralines, bool useextrahours,bool lotsizing, bool no_outcapacity, int anticipomin,int anticipomax, TMSP_mode mode, TMSP_logic logic, const char * msg, bool firstfitxbucket)
void TPlanning_mask::review_cell(long mrp_row, int bucket, bool check_machine, bool check_human, bool useextralines, bool useextrahours,
bool lotsizing, bool no_outcapacity, int anticipomin,int anticipomax,
TMSP_mode mode, TMSP_logic logic, const char * msg, bool firstfitxbucket)
{
const bool ignore_mag = get_bool(F_NOMAG_IN);
const bool ignore_imp = get_bool(F_NOIMP_IN);
const bool ignore_lin = get_bool(F_NOLIN_IN);
TMRP_line &mrpline = _mrp_articles[mrp_row];
TToken_string * row = mrpline.sheet_row();
TDate data_buck(starting_date());
data_buck += days_per_bucket()*(bucket-1);
round_date(data_buck);
const TMRP_time mrp_time(data_buck, 0, "","");
TMRP_record & mrp_rec= mrpline.record(mrp_time);
real art_per_buck = mrp_rec.net_requirement(); // quantità da produrre nel bucket
TMRP_line &mrpline = _mrp_articles[mrp_row];
TToken_string * row = mrpline.sheet_row();
TDate data_buck(starting_date());
data_buck += days_per_bucket()*(bucket-1);
round_date(data_buck);
const TMRP_time mrp_time(data_buck, 0, "","");
TMRP_record & mrp_rec= mrpline.record(mrp_time);
real art_per_buck = mrp_rec.net_requirement(); // quantità da produrre nel bucket
if (art_per_buck > ZERO)
{
real pieces, curr_arts;
if (art_per_buck > ZERO)
{
real pieces, curr_arts;
int lastbuck = mrpline.last_bucket();
TString16 livello_di_giacenza(mrpline.livgiac());
TString8 codlin(mrpline.codlin());
TString8 codimp(mrpline.codimp());
if (row != NULL)
{
codlin = row->get(F_CODLIN-FIRST_FIELD);
codimp = row->get(F_CODIMP-FIRST_FIELD);
}
dist_tree().set_global("_LIVELLO",livello_di_giacenza);
dist_tree().set_global("_IMPIANTO",codimp);
dist_tree().set_global("_LINEA",codlin);
dist_tree().set_global("_MAGDEP",mrpline.codmagdep());
bool no_limits=(logic == _uniform_logic && !check_machine)
|| !dist_tree().set_root(mrpline.articolo());
int lastbuck = mrpline.last_bucket();
TString16 livello_di_giacenza(mrpline.livgiac());
TString8 codlin(mrpline.codlin());
TString8 codimp(mrpline.codimp());
if (row != NULL)
{
codlin = row->get(F_CODLIN-FIRST_FIELD);
codimp = row->get(F_CODIMP-FIRST_FIELD);
}
dist_tree().set_global("_LIVELLO",livello_di_giacenza);
dist_tree().set_global("_IMPIANTO",codimp);
dist_tree().set_global("_LINEA",codlin);
dist_tree().set_global("_MAGDEP",mrpline.codmagdep());
bool no_limits=(logic == _uniform_logic && !check_machine)
|| !dist_tree().set_root(mrpline.articolo());
if (!no_limits)
{
TArray labors;
TRiga_esplosione * l=dist_tree().first_critical_labor(labors);
no_limits = (l == NULL);
bool first_buck = true;
if (!no_limits)
{
TArray labors;
TRiga_esplosione * l=dist_tree().first_critical_labor(labors);
no_limits = (l == NULL);
bool first_buck = true;
if (!no_limits)
{
TLavorazione *curr_labor = TDistinta_tree::find_labor(l);
// cerca le linee sulle quali e' possibile eseguire questa lavorazione
// e la carica con la lavorazione relativa all'articolo corrente
const int lineestd = curr_labor->linee_standard();
const int maxlinee = useextralines ? curr_labor->linee() : lineestd;
const real perc_min_lav = curr_labor->percentuale_minima();
TCRP_line *crpline_art,*crpline_lin,*crpline_imp,*crpline_firm;
TLavorazione *curr_labor = TDistinta_tree::find_labor(l);
// cerca le linee sulle quali e' possibile eseguire questa lavorazione
// e la carica con la lavorazione relativa all'articolo corrente
const int lineestd = curr_labor->linee_standard();
const int maxlinee = useextralines ? curr_labor->linee() : lineestd;
const real perc_min_lav = curr_labor->percentuale_minima();
TCRP_line *crpline_art,*crpline_lin,*crpline_imp,*crpline_firm;
real load, capacity, unit_load, hload, hcapacity, unit_hload ; // carichi di linea
int nbucket, lower_buck, upper_buck;
int attemp=1; // primo tentativo: rimane entro i vincoli di minimo e massimo anticipo utilizando solo le linee STD
// secondo tentativo: rimane entro i vincoli di minimo e massimo anticipo utilizando anche le linee non STD
// terzo tentativo: supera i vincoli di minimo e massimo anticipo utilizando anche le linee non STD
art_per_buck.round(5);
//if (nbucket>bucket)
if (art_per_buck > mrpline.net_requirement(lastbuck) && mode != _actual_plan)
real load, capacity, unit_load, hload, hcapacity, unit_hload ; // carichi di linea
int nbucket, lower_buck, upper_buck;
int attemp=1; // primo tentativo: rimane entro i vincoli di minimo e massimo anticipo utilizando solo le linee STD
// secondo tentativo: rimane entro i vincoli di minimo e massimo anticipo utilizando anche le linee non STD
// terzo tentativo: supera i vincoli di minimo e massimo anticipo utilizando anche le linee non STD
art_per_buck.round(5);
//if (nbucket>bucket)
if (art_per_buck > mrpline.net_requirement(lastbuck) && mode != _actual_plan)
{
// il sotto stock si propagherebbe fino alla fine ?
art_per_buck = mrpline.net_requirement(lastbuck) ;
mrpline.set_net_req(bucket,art_per_buck);
}
int max_attempts = 3;
// non anticipare articoli che potrebbero avere figli non anticipati automaticamente
if (!no_limits && get_bool(F_NOANTICIPI_MSP))
max_attempts = 2;
while (art_per_buck > ZERO && attemp <= max_attempts)
{
if (logic == _JIT_logic)
{
// il sotto stock si propagherebbe fino alla fine ?
art_per_buck = mrpline.net_requirement(lastbuck) ;
mrpline.set_net_req(bucket,art_per_buck);
}
int max_attempts = 3;
// non anticipare articoli che potrebbero avere figli non anticipati automaticamente
if (!no_limits && get_bool(F_NOANTICIPI_MSP))
max_attempts = 2;
while (art_per_buck > ZERO && attemp <= max_attempts)
{
if (logic == _JIT_logic)
{
lower_buck = (attemp <= 2 ? bucket-anticipomax/days_per_bucket() : 1);
upper_buck = bucket - anticipomin/days_per_bucket();
lower_buck = (attemp <= 2 ? bucket-anticipomax/days_per_bucket() : 1);
upper_buck = bucket - anticipomin/days_per_bucket();
}
else
{
lower_buck = bucket - anticipomax/days_per_bucket();
if (firstfitxbucket)
upper_buck = LAST_BUCKET;
else
upper_buck = (attemp <= 2 ? bucket-anticipomin/days_per_bucket(): LAST_BUCKET);
}
if (lower_buck<1)
lower_buck=1;
if (!firstfitxbucket && upper_buck>bucket)
upper_buck=bucket;
nbucket= (logic == _JIT_logic) ? upper_buck : lower_buck;
lower_buck = bucket - anticipomax/days_per_bucket();
if (firstfitxbucket)
upper_buck = LAST_BUCKET;
else
upper_buck = (attemp <= 2 ? bucket-anticipomin/days_per_bucket(): LAST_BUCKET);
}
if (lower_buck<1)
lower_buck=1;
if (!firstfitxbucket && upper_buck>bucket)
upper_buck=bucket;
nbucket= (logic == _JIT_logic) ? upper_buck : lower_buck;
int nlinea = -1, numlinee;
int nlinea = -1, numlinee;
if (ignore_lin || codlin.blank() )
{
if (codlin.blank())
{
nlinea=(attemp == 2 ? lineestd : 0 ) ;
numlinee=(attemp == 1 ? lineestd : maxlinee ) ;
}
else // l'utente ha fissato la linea
{
if (attemp == 1)
{
nlinea = curr_labor->find_linea(codlin);
numlinee = nlinea + 1;
}
if (nlinea < 0)
{
nlinea = 0;
numlinee = (attemp < 3 ? lineestd : maxlinee ) ;
}
}
if (ignore_lin || codlin.blank() )
{
if (codlin.blank())
{
nlinea=(attemp == 2 ? lineestd : 0 ) ;
numlinee=(attemp == 1 ? lineestd : maxlinee ) ;
}
else // l'utente ha fissato la linea
{
if (attemp == 1)
{
nlinea = curr_labor->find_linea(codlin);
numlinee = nlinea + 1;
}
if (nlinea < 0)
{
nlinea = 0;
numlinee = (attemp < 3 ? lineestd : maxlinee ) ;
}
}
} else {
nlinea= curr_labor->find_linea(codlin);
if (nlinea<0)
{
error_box(FR("La linea %s non e' in grado di produrre l'articolo %s"), (const char * )codlin, (const char *) _mrp_articles[mrp_row].articolo());
break;
}
numlinee=nlinea+1;
}
}
else
{
nlinea= curr_labor->find_linea(codlin);
if (nlinea<0)
{
error_box(FR("La linea %s non e' in grado di produrre l'articolo %s"), (const char * )codlin, (const char *) _mrp_articles[mrp_row].articolo());
break;
}
numlinee=nlinea+1;
}
while (art_per_buck > ZERO // ho un sotto-stock da risolvere
&& nlinea >= 0 && nlinea<numlinee && nbucket>=lower_buck && nbucket <= upper_buck) // sono entro il range definito
{
@ -1906,8 +1914,7 @@ bool TPlanning_mask::general_review(bool check_machine, bool check_human, bool u
pi.addstatus(1);
for (long mrp_row=0; mrp_row < max_mrp_rows; mrp_row++)
{
pi.addstatus(1);
if (pi.iscancelled())
if (!pi.addstatus(1))
return false;
review_cell(mrp_row, bucket, check_machine, check_human, useextralines, useextrahours, lotsizing, no_outcapacity, anticipomin, anticipomax, mode, logic, msg, false);
}
@ -2062,12 +2069,15 @@ void TPlanning_mask::msprow2codes(TToken_string &row,long &clifor, TCodice_artic
lin = row.get(F_CODLIN-FIRST_FIELD); lin.trim();
um = row.get(F_UM-FIRST_FIELD); um.trim();
const TString val = row.get(F_DESCART-FIRST_FIELD);
const TFixed_string val = row.get(F_DESCART-FIRST_FIELD);
const int pos = val.find('¦');
if (pos >= 0)
{
da_rdoc_key = val.mid(pos+1);
da_rdoc_key.trim();
}
else
da_rdoc_key = EMPTY_STRING;
da_rdoc_key.cut(0);
}
void TPlanning_mask::crprow2codes(TToken_string &row, TString & imp, TString & lin, long &clifor, TCodice_articolo &art ,
@ -3560,9 +3570,7 @@ bool TPlanning_mask::on_field_event(TOperable_field& o, TField_event e, long jol
break;
case F_CANCEL_MSP:
if (e == fe_button)
{
remove_propose(true);
}
break;
case F_RECALC_MSP:
if (e == fe_button && check_fields())

View File

@ -3,7 +3,6 @@
#include <applicat.h>
#include <colmask.h>
#include "mrplib.h"
#include "mr2100.h"
#include "mr2201.h"
@ -147,7 +146,7 @@ public:
bool sortMSPsheet();
bool sortCRPsheet();
virtual bool is_acq_planning() { return FALSE;}
virtual bool is_acq_planning() { return false;}
TSelect_color_mask & sel() { return _sel_color; }
TPlanning_mask();
virtual ~TPlanning_mask() { }
@ -162,12 +161,11 @@ protected:
void openfiles() ;
virtual TPlanning_mask& mask() {return *_m;}
virtual void main_loop();
virtual bool firm_change_enabled() const { return FALSE; }
virtual bool firm_change_enabled() const { return false; }
virtual bool TPlanning_app::menu(MENU_TAG mt);
public:
TPlanning_app() : _m(NULL) {}
};
#endif // __MR2200_H
#endif // __MR2200_H

View File

@ -486,7 +486,7 @@ END
LIST F_RECALC_TYPE 35
BEGIN
PROMPT 2 1 "Logica propositiva "
PROMPT 2 1 "Logica proposte "
#ifndef _IS_ACQ
ITEM "1|FirstFit "
MESSAGE ENABLE,G_FINITE@
@ -525,12 +525,12 @@ END
BOOL F_FFBUCKET_MSP
BEGIN
PROMPT 60 1 "First Fit sui bucket"
PROMPT 58 1 "Bucket First Fit"
END
STRING F_PRIORITY 60
BEGIN
PROMPT 2 2 "Priorita' "
PROMPT 2 2 "Prioritŕ "
END
BOOL F_LOTSIZING
@ -779,7 +779,7 @@ END
BOOL F_MSP_SORT_PRILIN
BEGIN
PROMPT 52 3 "Prioritŕ di linea"
PROMPT 55 3 "Prioritŕ di linea"
END
BUTTON F_MSP_RESORT 9

View File

@ -1219,6 +1219,7 @@ void TMSP_constraint::init()
__userflds = new TToken_string(c.get("USERFLDS"));
__sep = c.get_char("FLDSEP", NULL, -1, ';');
}
_da_rdoc_key.trim();
}
TMSP_constraint::TMSP_constraint(long cliente,
@ -1347,7 +1348,10 @@ TMSP_constraint* TMSP_constraints::find(const TToken_string& row, bool create)
const int pos = str.find('¦');
if (pos >= 0)
{
_key.add(str.mid(pos +1));
_key.rtrim();
}
else
_key.add("");