Files correlati : Ricompilazione Demo : [ ] Commento : Riportata la versione 3.2 patch 1092 git-svn-id: svn://10.65.10.50/trunk@16293 c028cbd2-c16b-5b4b-a496-9718f37d4682
500 lines
17 KiB
C++
Executable File
500 lines
17 KiB
C++
Executable File
#ifndef __MR2201_H
|
|
#define __MR2201_H
|
|
|
|
#ifndef __SHEET_H
|
|
#include <sheet.h>
|
|
#endif
|
|
|
|
// funzioni di ricerca distinta master
|
|
bool distinta_master(const char *code, bool is_son=FALSE);
|
|
// funzione per l'uso degli alberi delle distinte
|
|
TDistinta_tree &dist_tree();
|
|
|
|
#define MASTERCODE_CHAR 'M'
|
|
|
|
//***********************
|
|
// oggetto TRiga articolo
|
|
class TMSP_constraint;
|
|
class TMSP_constraints;
|
|
|
|
class TRiga_articolo : public TToken_string
|
|
{
|
|
public:
|
|
static int order_compare(TSheet_field & s, int i1, int i2, int level);
|
|
static int order_compare( const TToken_string& r1 , const TToken_string& r2 , int level, bool ascending=TRUE);
|
|
static int compare_field(TString &str0, TString &str1,short field_no) ;
|
|
static int order_comparePCAL(TSheet_field & s, int i1, int i2);
|
|
static int order_comparePCLA(TSheet_field & s, int i1, int i2);
|
|
static int order_comparePALC(TSheet_field & s, int i1, int i2);
|
|
static int order_comparePACL(TSheet_field & s, int i1, int i2);
|
|
static int order_comparePLAC(TSheet_field & s, int i1, int i2);
|
|
static int order_comparePLCA(TSheet_field & s, int i1, int i2);
|
|
static int order_compareCAL(TSheet_field & s, int i1, int i2);
|
|
static int order_compareCLA(TSheet_field & s, int i1, int i2);
|
|
static int order_compareALC(TSheet_field & s, int i1, int i2);
|
|
static int order_compareACL(TSheet_field & s, int i1, int i2);
|
|
static int order_compareLAC(TSheet_field & s, int i1, int i2);
|
|
static int order_compareLCA(TSheet_field & s, int i1, int i2);
|
|
static int order_compareLPAC(TSheet_field & s, int i1, int i2);
|
|
static int order_comparePCA(TSheet_field & s, int i1, int i2);
|
|
static int order_comparePAC(TSheet_field & s, int i1, int i2);
|
|
static int order_compareAC(TSheet_field & s, int i1, int i2);
|
|
static int order_compareCA(TSheet_field & s, int i1, int i2);
|
|
static int find_block_constr(const TSheet_field& sf, const int riga);
|
|
static bool find_block(const TSheet_field& sf, const int riga, int &first_row, int &last_row );
|
|
|
|
int compare(const TToken_string& r, int level) const;
|
|
TRiga_articolo& operator=(TToken_string& r);
|
|
TRiga_articolo& operator+=(TRiga_articolo& r);
|
|
|
|
TRiga_articolo() : TToken_string(128) { }
|
|
TRiga_articolo(const TMSP_constraint & line);
|
|
virtual ~TRiga_articolo() { }
|
|
};
|
|
#define SORT_BY_PCAL -1 // cliente / articolo / impianto-linea
|
|
#define SORT_BY_PCLA -2 //
|
|
#define SORT_BY_PALC -3 //
|
|
#define SORT_BY_PACL -4 //
|
|
#define SORT_BY_PLAC -5 //
|
|
#define SORT_BY_PLCA -6 //
|
|
#define SORT_BY_LPAC -7 // linea / priorita / articolo / cliente
|
|
#define SORT_BY_PCA -8 // cliente / articolo
|
|
#define SORT_BY_PAC -9 //
|
|
#define SORT_BY_PRIORITY 16
|
|
#define SORT_WITHOUT_LINE 8
|
|
#define SORT_BY_CAL -17 // cliente / articolo / impianto-linea
|
|
#define SORT_BY_CLA -18 //
|
|
#define SORT_BY_ALC -19 //
|
|
#define SORT_BY_ACL -20 //
|
|
#define SORT_BY_LAC -21 //
|
|
#define SORT_BY_LCA -22 //
|
|
#define SORT_BY_CA -24 // cliente / articolo
|
|
#define SORT_BY_AC -25 //
|
|
|
|
//***********************
|
|
// form di stampa degli sheet
|
|
class TMSP_form : public TForm
|
|
{
|
|
protected:
|
|
bool validate(TForm_item &cf, TToken_string &s);
|
|
public:
|
|
TMSP_form (TIsamtempfile * rep);
|
|
};
|
|
|
|
class TCRP_form : public TForm
|
|
{
|
|
protected:
|
|
bool validate(TForm_item &cf, TToken_string &s);
|
|
public:
|
|
TCRP_form (TIsamtempfile* rep, TSheet_field& sf);
|
|
};
|
|
|
|
class TMSP_constraints : public TMRP_array
|
|
{
|
|
protected:
|
|
virtual TSortable* new_obj(const TToken_string& key) const;
|
|
|
|
public:
|
|
TMSP_constraint* find(long cliente,const TString& codart,const TString& giac,
|
|
const TString& imp, const TString& lin, const TString& mag, const TString& magc,
|
|
const TString & rdoc_key, bool create = false) ;
|
|
TMSP_constraint* find(const TToken_string& row, bool create = false);
|
|
|
|
TMSP_constraint& operator[](long n) const
|
|
{ return (TMSP_constraint&)find_obj(n); }
|
|
};
|
|
|
|
class TMSP_record : public TObject
|
|
{
|
|
int _curr_ref;
|
|
TMRP_docrefs _docrefs;
|
|
public:
|
|
bool _qta_locked;
|
|
real _qta_min;
|
|
real _qta;
|
|
real _price;
|
|
void add_rigaref(TMRP_docref *r);
|
|
void remove_rigaref();
|
|
TMRP_docref *first_rigaref();
|
|
TMRP_docref *next_rigaref();
|
|
int rigarefs() {return _docrefs.items();}
|
|
TMRP_docref* rigaref(int n);
|
|
virtual TObject* dup() const;
|
|
TMSP_record();
|
|
};
|
|
|
|
class TMaster_code : public TObject
|
|
{
|
|
TString _code;
|
|
TString _liv;
|
|
TString _um;
|
|
TString _codimp;
|
|
TString _codlin;
|
|
TString _codmag;
|
|
real _expr;
|
|
real _leadtime;
|
|
public:
|
|
const char *articolo() const {return _code;}
|
|
const char *livello() const {return _liv;}
|
|
const char *um() const {return _um;}
|
|
const real &expr() const {return _expr;}
|
|
const real &leadtime() const {return _leadtime;}
|
|
const char *codimp() const {return _codimp;}
|
|
const char *codlin() const {return _codlin;}
|
|
const char *codmagdep() const {return _codmag;}
|
|
|
|
TMaster_code(const char *code, const char *liv, const char *ummaster, const real &expr, const real &leadtime, const char *codimp, const char *codlin, const char *codmag);
|
|
TMaster_code(const char *code, const char *liv,const char *ummaster, const real &expr, int leadtime, const char *codimp, const char *codlin, const char *codmag);
|
|
virtual ~TMaster_code() {}
|
|
};
|
|
|
|
|
|
class TMSP_line2 : public TObject
|
|
{
|
|
bool _used;
|
|
TMSP_constraint *_constraint;
|
|
TArray _mastercodes;
|
|
public:
|
|
bool used() {return _used;}
|
|
void set_use(bool on) {_used=on;}
|
|
void add_mastercode (TMaster_code *);
|
|
int mastercodes() const {return _mastercodes.items();}
|
|
TMaster_code *get_mastercode (int i=0);
|
|
TMSP_constraint &constraint() {return *_constraint;}
|
|
TMSP_line2(const TMSP_constraint &c);
|
|
virtual ~TMSP_line2() {}
|
|
};
|
|
|
|
class TMSP_record_array : public TObject
|
|
{
|
|
TArray _buckets;
|
|
|
|
public:
|
|
int items() const { return _buckets.items(); }
|
|
int last() const { return _buckets.last(); }
|
|
int pred(int i) const { return _buckets.pred(i); }
|
|
|
|
virtual TMSP_record_array& operator=(const TMSP_record_array& a);
|
|
TMSP_record& operator[](int b);
|
|
};
|
|
|
|
|
|
class TMSP_constraint : public TSortable
|
|
{
|
|
long _codclifor; // cliente o fornitore
|
|
TCodice_articolo _codart; // articolo
|
|
TString16 _livgiac; // livelli di giacenza
|
|
TString8 _codmag; // magazzino/deposito
|
|
TString8 _codmag_coll; // magazzino/deposito collegato
|
|
TString80 _da_rdoc_key; // documento oprigine
|
|
TString8 _codimp, _codlin; // codici impianto e linea
|
|
TString _descr; // descrizione
|
|
long _priority; // priorita'
|
|
|
|
bool _on_sheet; // gia' sullo sheet
|
|
bool _check_master; // articolo non master, controllare se esistono Master
|
|
TArray *_lines2; // codici master per articoli NON master
|
|
TMSP_constraints *_upperlines; // vincoli dei codici di livello 1 per articoli master
|
|
|
|
TMSP_record_array _bucket_qta; // pianificazione
|
|
const TToken_string* _sheet_row;
|
|
|
|
static TString16 _substr;
|
|
static TToken_string * __userflds;
|
|
static char __sep;
|
|
|
|
protected:
|
|
virtual int compare(const TSortable& s) const;
|
|
|
|
public:
|
|
const char *um();
|
|
long codclifor() const { return _codclifor; }
|
|
const TCodice_articolo& articolo() const { return _codart; }
|
|
const TString& livgiac() const { return _livgiac; }
|
|
const TString& codimp() const { return _codimp; }
|
|
const TString& codlin() const { return _codlin; }
|
|
const TString& codmagdep() const { return _codmag; }
|
|
const TString& codmagdep_coll() const { return _codmag_coll; }
|
|
const TString& da_rdoc_key() const { return _da_rdoc_key; }
|
|
const TString& description() const { return _descr; }
|
|
void set_description(const char* str) { _descr = str; }
|
|
|
|
const TString& codmag() const { return _substr = _codmag.left(3); }
|
|
const TString& coddep() const { return _substr = _codmag.mid(3); }
|
|
const TString& codmag_coll() const { return _substr = _codmag_coll.left(3); }
|
|
const TString& coddep_coll() const { return _substr = _codmag_coll.mid(3); }
|
|
const TString& livgiac(int l) const { return _substr = _livgiac.mid(livelli_giacenza().code_start(l)-1, livelli_giacenza().code_length(l));}
|
|
|
|
TMRP_docref * first_rigaref(int buck);
|
|
TMRP_docref * next_rigaref(int buck);
|
|
int rigarefs(int buck);
|
|
TMRP_docref* rigaref(int buck, int n);
|
|
TMRP_docref* add_rigaref(int buck, TString& codnum, int annodoc, long ndoc, int nrig, const char * um, const real & qta, const real &prz);
|
|
void add_rigaref(int buck, TMRP_docref *rdr);
|
|
void remove_rigaref(int buck);
|
|
// master sched. a due livelli:
|
|
int find_distinta_master(const TMSP_constraint & constr, TString & master, TString & livmaster,TString & um,real & expr, TString & imp,TString & lin,TString & magdep, int fromindex=0);
|
|
void set_mastercode_check(bool on);
|
|
bool mastercodes2check() const ;
|
|
// mastercodes
|
|
TMSP_line2 * use_mspline2(TMSP_constraint &line);
|
|
TMSP_line2 * use_mspline2(TToken_string &row);
|
|
void discard_line2(TMSP_line2 * );
|
|
void reset_unused_line2();
|
|
TMSP_line2 * get_unused_line2();
|
|
const TArray * msplines2() const {return _lines2;}
|
|
// upperlines
|
|
const TMSP_constraints * upperlines() const {return _upperlines;}
|
|
long upperlines_items() const {return _upperlines ? upperlines()->items() : 0L;}
|
|
bool has_upperlines() const {return upperlines_items()>0;}
|
|
TMSP_constraint* add_upperline(const TMSP_constraint& constr);
|
|
TMSP_constraint* get_upperline(TMSP_constraint& constr);
|
|
TMSP_constraint* get_upperline(int r);
|
|
// buckets
|
|
int last() const { return _bucket_qta.last(); }
|
|
int pred(int i) const { return _bucket_qta.pred(i); }
|
|
bool & qta_locked(int b) { return _bucket_qta[b]._qta_locked; }
|
|
virtual real& qta_min(int b) { return _bucket_qta[b]._qta_min; }
|
|
virtual real& qta(int b) { return _bucket_qta[b]._qta; }
|
|
virtual real& price(int b) { return _bucket_qta[b]._price; }
|
|
|
|
virtual long priority() const { return _priority; }
|
|
virtual void priority(long p) { _priority = p; }
|
|
|
|
virtual void fill_sheet_row(TToken_string& row, const TMask & m, const char * descr, bool codes_only = false);
|
|
|
|
bool is_on_sheet() const { return _on_sheet; }
|
|
void set_on_sheet(bool on = TRUE) { _on_sheet = on; }
|
|
const TToken_string* sheet_row_ptr() const { return _sheet_row; }
|
|
void init();
|
|
|
|
TMSP_constraint & operator=(const TMSP_constraint & line);
|
|
|
|
TMSP_constraint(long cliente,
|
|
const TCodice_articolo& codart,
|
|
const TString& giac,
|
|
const TString& imp, const TString& lin,
|
|
const TString& mag, const TString& magc, const TString& rdoc_key);
|
|
TMSP_constraint(const TMSP_constraint & cons);
|
|
virtual ~TMSP_constraint();
|
|
};
|
|
|
|
|
|
// linee contenenti pianificazioni
|
|
class TMSP_line : public TMSP_constraint
|
|
{
|
|
public:
|
|
|
|
virtual void fill_sheet_row(TToken_string& row, const TMask & m, const char *desc, bool codes_only = false) ;
|
|
TMSP_line(long cliente, const TCodice_articolo& codart,
|
|
const TString& giac, const TString& imp, const TString& lin,
|
|
const TString& mag, const TString& magc, const TString & rdoc_key);
|
|
TMSP_line(TMSP_line & line);
|
|
TMSP_line(TMSP_constraint & cons);
|
|
virtual ~TMSP_line() { }
|
|
};
|
|
|
|
|
|
class TMSP_lines : public TMRP_array
|
|
{
|
|
protected:
|
|
virtual TSortable* new_obj(const TToken_string& key) const;
|
|
|
|
public:
|
|
TMSP_line* find(long cliente, const TString& art, const TString& gia, const TString& imp,
|
|
const TString& lin, const TString& mag, const TString& magc, const TString & rdoc_key,
|
|
bool create = false);
|
|
|
|
TMSP_line* find(const TToken_string& row, bool create=FALSE);
|
|
|
|
TMSP_line& operator[](long i) const
|
|
{ return (TMSP_line&)find_obj(i); }
|
|
};
|
|
|
|
|
|
class TCapacity_record : public TObject
|
|
{
|
|
real _machine;
|
|
real _human;
|
|
real _pieces;
|
|
real _money;
|
|
public:
|
|
void set_machine(const real &v) {_machine = v;}
|
|
void set_human (const real &v) {_human = v;}
|
|
void set_pieces (const real &v) {_pieces = v;}
|
|
void add_machine(const real &v) {_machine += v;}
|
|
void add_human (const real &v) {_human += v;}
|
|
void add_pieces (const real &v) {_pieces += v;}
|
|
void add_money (const real &v) {_money += v;}
|
|
public:
|
|
const real &machine() const {return _machine;}
|
|
const real &human () const {return _human;}
|
|
const real &pieces () const {return _pieces;}
|
|
const real &money () const {return _money;}
|
|
TCapacity_record& operator= (const TCapacity_record &c);
|
|
TCapacity_record(const TCapacity_record&c);
|
|
TCapacity_record();
|
|
TCapacity_record(const real & machine, const real & human);
|
|
};
|
|
|
|
class TCapacity_load : public TSortable
|
|
{
|
|
TCapacity_record _capacity; // Capacita'
|
|
TCapacity_record _load; // Carico
|
|
protected:
|
|
virtual int compare(const TSortable& s) const;
|
|
virtual TObject* dup() const { return new TCapacity_load(*this); }
|
|
|
|
void copy(const TCapacity_load& q);
|
|
real get_factor(const TCodice_um& um) const;
|
|
void convert(real& val, const TCodice_um& from_um, const TCodice_um& to_um) const;
|
|
|
|
public:
|
|
const TCapacity_load& operator =(const TCapacity_load& q)
|
|
{ copy(q); return *this; }
|
|
|
|
TCapacity_record &capacity() {return _capacity;}
|
|
TCapacity_record &load() {return _load;}
|
|
const real &pieces_capacity () ;
|
|
|
|
TCapacity_load ();
|
|
TCapacity_load (const TCapacity_load & q) { copy(q); }
|
|
virtual ~TCapacity_load () {}
|
|
};
|
|
|
|
|
|
class TCRP_line : public TSortable
|
|
{
|
|
TString8 _imp,_lineap;
|
|
TString _codart;
|
|
long _codcli;
|
|
TString _desc;
|
|
bool _on_sheet;
|
|
|
|
TArray _bucket;
|
|
|
|
|
|
protected:
|
|
virtual int compare(const TSortable& s) const;
|
|
TCapacity_load& bucket(int n) ;
|
|
TCapacity_load& operator[](int n)
|
|
{return bucket(n);}
|
|
|
|
public:
|
|
const TString& codimp() const { return _imp; }
|
|
const TString& codlin() const { return _lineap; }
|
|
const TString& codart() const { return _codart; }
|
|
const TString& desc() const { return _desc; }
|
|
//void set_desc(const char* str) { _desc = str; }
|
|
|
|
int last() const { return _bucket.last(); }
|
|
int pred(int i) const { return _bucket.pred(i); }
|
|
|
|
TCapacity_record& capacity(int b) { return bucket(b).capacity(); }
|
|
TCapacity_record& load(int b) { return bucket(b).load(); }
|
|
const real &pieces_capacity (int b) { return bucket(b).pieces_capacity(); }
|
|
|
|
void fill_capacity_row(TToken_string& row, char load_type, bool percent=FALSE);
|
|
void fill_load_row(TToken_string& row, char load_type, bool percent=FALSE);
|
|
|
|
bool is_on_sheet() const { return _on_sheet; }
|
|
void set_on_sheet(bool on = TRUE) { _on_sheet = on; }
|
|
|
|
TCRP_line(const TString& codimp,const TString& codlin,const TString &codart, long codcli);
|
|
virtual ~TCRP_line() { }
|
|
};
|
|
|
|
|
|
class TCRP_lines : public TMRP_array
|
|
{
|
|
protected:
|
|
virtual TSortable* new_obj(const TToken_string& key) const;
|
|
|
|
public:
|
|
TCRP_line* find(const TLinea_prod& linea_prod,
|
|
const char * codart="", long codcli=0L, bool create=FALSE);
|
|
TCRP_line* find(const char * codimp="", const char * codlin="",
|
|
const char * codart="", long codcli=0L, bool create=FALSE);
|
|
TCRP_line& operator[](long n) const
|
|
{ return (TCRP_line&)find_obj(n); }
|
|
};
|
|
|
|
class TPlan_docs : public TMRP_array
|
|
{
|
|
TString16 _num, _doc, _rig;
|
|
|
|
protected:
|
|
virtual TSortable* new_obj(const TToken_string& key) const;
|
|
|
|
public:
|
|
TDocumento& find(const TMRP_docref* riga);
|
|
TRiga_documento* find_row(const TMRP_docref* rdr);
|
|
TRiga_documento& add_to_row(TMRP_docref * rdr, const real& qta);
|
|
long flush(const TDate& data, const char * codart);
|
|
|
|
TPlan_docs(const char* num, const char* tip, const char* rig);
|
|
virtual ~TPlan_docs() { }
|
|
};
|
|
|
|
|
|
class TLista_dettagli : public TSheet
|
|
{
|
|
TDate _from;
|
|
int _bucksize;
|
|
int _curr_bucket;
|
|
|
|
protected:
|
|
static bool bucket_handler(TMask_field & f, KEY key);
|
|
virtual long get_items(int b) const {return 0L;}
|
|
virtual long get_items() const {return get_items(_curr_bucket);}
|
|
|
|
public:
|
|
bool reset_bucket_field();
|
|
int curr_bucket() const {return _curr_bucket;}
|
|
void set_bucket(int b);
|
|
void init(const char * title, const TDate& fromdate, int bucketsize);
|
|
TLista_dettagli(const char * title, const TDate& fromdate, int bucketsize, const char * head);
|
|
~TLista_dettagli() {}
|
|
};
|
|
|
|
|
|
class TLista_docref : public TLista_dettagli
|
|
{
|
|
TRelation *_r;
|
|
TMSP_constraint * _line;
|
|
static const char *header();
|
|
protected:
|
|
virtual void get_row(long r, TToken_string& row);
|
|
virtual long get_items(int b) const;
|
|
public:
|
|
bool edit_checked();
|
|
TLista_docref(TMSP_constraint * l, const char * title, TDate fromdate, int bucketsize);
|
|
~TLista_docref();
|
|
};
|
|
|
|
|
|
class TLista_mastercodes : public TLista_dettagli
|
|
{
|
|
TMSP_line2 *_line_art;
|
|
static const char *header();
|
|
protected:
|
|
virtual void get_row(long r, TToken_string& row);
|
|
virtual long get_items(int b) const;
|
|
public:
|
|
TLista_mastercodes(TMSP_constraint *c, TToken_string &l, TDate fromdate, int bucketsize);
|
|
~TLista_mastercodes() {}
|
|
};
|
|
|
|
class TLista_upperlines : public TLista_dettagli
|
|
{
|
|
TMSP_constraint *_line;
|
|
static const char *header();
|
|
protected:
|
|
virtual void get_row(long r, TToken_string& row);
|
|
virtual long get_items(int b) const;
|
|
public:
|
|
TLista_upperlines(TMSP_constraint *l, TDate fromdate, int bucketsize);
|
|
~TLista_upperlines() {}
|
|
};
|
|
#endif // __MR2201_H
|