Programma di ricezione ABI e CAB
git-svn-id: svn://10.65.10.50/trunk@5545 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
b7c91986b6
commit
4168e18326
255
ba/ba5300.cpp
Executable file
255
ba/ba5300.cpp
Executable file
@ -0,0 +1,255 @@
|
||||
#include <applicat.h>
|
||||
#include <filetext.h>
|
||||
#include <comuni.h>
|
||||
#include "ba5300.h"
|
||||
|
||||
#define TABBAN_INDIR "S2"
|
||||
#define TABBAN_NCIVICO "S7"
|
||||
#define TABBAN_CODCOM "S5"
|
||||
#define TABBAN_CAP "S3"
|
||||
|
||||
const char* cap2comune(const TString& field, const TString& denom);
|
||||
const char* denom2comune(const TString& field, const char * stato=NULL);
|
||||
const char* denom2com_alt(const TString& dencom, const char * stato=NULL);
|
||||
bool confr_nomicomune(const TString & com1, const TString & com2);
|
||||
|
||||
class TABICAB_file : public TFile_text
|
||||
{
|
||||
int spezza_indirizzo(TString & indir,TString & ncivico);
|
||||
protected:
|
||||
// virtual void validate(TCursor& cur, TRecord_text &rec, TToken_string &val, TString& str)
|
||||
virtual void preformat_field(const TFieldref&field,TString &str,TRelation& rel,const TString & tipo_tr);
|
||||
virtual bool pre_writerel(TRelation& rel,const TRecord_text& rec);
|
||||
public:
|
||||
TABICAB_file(const char * path);
|
||||
virtual ~TABICAB_file() {}
|
||||
};
|
||||
|
||||
TABICAB_file::TABICAB_file(const char * path):
|
||||
TFile_text(path, "ba5300.ini")
|
||||
{
|
||||
}
|
||||
|
||||
void TABICAB_file::preformat_field(const TFieldref&field,TString &str,TRelation& rel,const TString & tipo_tr)
|
||||
{
|
||||
if ((tipo_tr==TRACCIATO_ABI && field.name()=="S0") ||
|
||||
(tipo_tr==TRACCIATO_DENCAB && field.name()=="S0")||
|
||||
(tipo_tr==TRACCIATO_CAB && field.name()=="S3")
|
||||
)
|
||||
// ho già composto la chiave; cerco il record
|
||||
rel.read();
|
||||
}
|
||||
|
||||
bool TABICAB_file::pre_writerel(TRelation& rel,const TRecord_text& rec)
|
||||
{
|
||||
bool can_write=TRUE;
|
||||
TRectype & curr_rec=rel.lfile().curr();
|
||||
if (rec.type()==TRACCIATO_CAB)
|
||||
{
|
||||
// ***** check indirizzo/Ncivico
|
||||
TString indir(rec.row(TXTCAB_INDIRIZZO));
|
||||
TString nciv;
|
||||
spezza_indirizzo(indir,nciv);
|
||||
|
||||
curr_rec.put(TABBAN_INDIR,indir);
|
||||
curr_rec.put(TABBAN_NCIVICO,nciv);
|
||||
// ***** check codice comune
|
||||
TString codcomune(cap2comune(rec.row(TXTCAB_CAP),rec.row(TXTCAB_COMUNE)));
|
||||
if (codcomune.empty())
|
||||
codcomune=denom2comune(rec.row(TXTCAB_COMUNE) );
|
||||
curr_rec.put(TABBAN_CODCOM, codcomune);
|
||||
|
||||
}
|
||||
return can_write;
|
||||
}
|
||||
|
||||
int TABICAB_file::spezza_indirizzo(TString & indir,TString & ncivico)
|
||||
{
|
||||
int last_c=indir.len();
|
||||
//while (last_c && indir[last_c]>='0' && )
|
||||
return last_c;
|
||||
}
|
||||
|
||||
static TString16 tmp_cod_com;
|
||||
|
||||
// Cerca il cap e se lo trova controlla i primi caratteri della denominazione
|
||||
const char* cap2comune(const TString& val_cap, const TString& dencom )
|
||||
{
|
||||
TString cap = val_cap;
|
||||
if (!cap.empty())
|
||||
{
|
||||
TLocalisamfile comuni (LF_COMUNI);
|
||||
|
||||
bool trovato = FALSE;
|
||||
bool prima_volta = TRUE;
|
||||
|
||||
tmp_cod_com = "";
|
||||
|
||||
// correzione CAP
|
||||
if (cap.sub(2,3) == "1")
|
||||
{
|
||||
cap = cap.sub(0,3);
|
||||
cap << "00";
|
||||
}
|
||||
|
||||
comuni.setkey(3);
|
||||
comuni.zero();
|
||||
comuni.put(COM_CAPCOM, cap);
|
||||
|
||||
TRectype com (comuni.curr());
|
||||
|
||||
for (comuni.read(_isgteq); !comuni.eof(); comuni.next())
|
||||
{
|
||||
if (comuni.curr() != com) break;
|
||||
|
||||
TString d (comuni.get(COM_DENCOM));
|
||||
if (prima_volta)
|
||||
{
|
||||
tmp_cod_com = comuni.get(COM_COM);
|
||||
prima_volta = FALSE;
|
||||
}
|
||||
|
||||
trovato = TRUE;
|
||||
for (int i = 0; d[i]>='a' && d[i]<='z' || d[i]>='A' && d[i]<='Z' ; i++)
|
||||
{
|
||||
if (dencom[i] != d[i])
|
||||
{
|
||||
trovato = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (trovato)
|
||||
{
|
||||
tmp_cod_com = comuni.get(COM_COM);
|
||||
break;
|
||||
}
|
||||
else
|
||||
continue;
|
||||
}
|
||||
if (!trovato)
|
||||
tmp_cod_com.cut(0);
|
||||
}
|
||||
return tmp_cod_com;
|
||||
}
|
||||
|
||||
const char* denom2comune(const TString& dencom, const char * stato)
|
||||
{
|
||||
tmp_cod_com.cut(0);
|
||||
if (!dencom.empty())
|
||||
{
|
||||
TLocalisamfile comuni (LF_COMUNI);
|
||||
|
||||
comuni.setkey(2);
|
||||
comuni.zero();
|
||||
comuni.put(COM_DENCOM, dencom);
|
||||
if (comuni.read()==NOERR
|
||||
&& !((stato && comuni.get(COM_STATO)!=stato) || comuni.get(COM_STATO)!="") )
|
||||
tmp_cod_com = comuni.get(COM_COM);
|
||||
}
|
||||
return tmp_cod_com;
|
||||
}
|
||||
|
||||
// denominazioni di comuni alternative
|
||||
const char* denom2com_alt(const TString& dencom, const char * stato)
|
||||
{
|
||||
tmp_cod_com.cut(0);
|
||||
if (!dencom.empty())
|
||||
{
|
||||
bool prima_volta = TRUE;
|
||||
|
||||
TLocalisamfile comuni (LF_COMUNI);
|
||||
|
||||
comuni.setkey(2);
|
||||
comuni.zero();
|
||||
comuni.put(COM_DENCOM, dencom);
|
||||
for (comuni.read(_isgteq); !comuni.eof(); comuni.next())
|
||||
{
|
||||
if (prima_volta)
|
||||
{
|
||||
|
||||
prima_volta=FALSE;
|
||||
}
|
||||
if (confr_nomicomune(comuni.get(COM_DENCOM),dencom)
|
||||
&& !((stato && comuni.get(COM_STATO)!=stato) || comuni.get(COM_STATO)!=""))
|
||||
tmp_cod_com = comuni.get(COM_COM);
|
||||
}
|
||||
}
|
||||
return tmp_cod_com;
|
||||
}
|
||||
|
||||
bool confr_nomicomune(const TString & com1, const TString & com2)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
class TRicezioneABICAB : public TSkeleton_application
|
||||
{
|
||||
void ricevi(const char *, bool abi, bool cab, bool cab_futuri, const char * filtro_reg);
|
||||
protected:
|
||||
virtual void main_loop();
|
||||
virtual bool create();
|
||||
virtual bool destroy();
|
||||
public:
|
||||
TRicezioneABICAB()
|
||||
{}
|
||||
virtual ~TRicezioneABICAB()
|
||||
{}
|
||||
};
|
||||
|
||||
bool TRicezioneABICAB::create()
|
||||
{
|
||||
return TSkeleton_application::create();
|
||||
}
|
||||
|
||||
bool TRicezioneABICAB::destroy()
|
||||
{
|
||||
return TSkeleton_application::destroy();
|
||||
}
|
||||
|
||||
void TRicezioneABICAB::main_loop()
|
||||
{
|
||||
// open mask and get parameters
|
||||
|
||||
// receive
|
||||
ricevi("c:\\piazze", TRUE, TRUE, TRUE,"RE");
|
||||
}
|
||||
|
||||
void TRicezioneABICAB::ricevi(const char * path, bool abi, bool cab, bool cab_futuri, const char * filtro_prov)
|
||||
{
|
||||
TABICAB_file abicab(path);
|
||||
TRecord_text txtrec;
|
||||
abicab.open();
|
||||
abicab.set_curr(txtrec);
|
||||
|
||||
while (abicab.read()==NOERR)
|
||||
{
|
||||
if (abicab.curr().type()==TRACCIATO_ABI && abi ||
|
||||
(abicab.curr().type()==TRACCIATO_CAB || abicab.curr().type()==TRACCIATO_DENCAB) && cab
|
||||
)
|
||||
if (abicab.curr().type()==TRACCIATO_CAB && abi)
|
||||
{
|
||||
// filtro i CAB della provincia
|
||||
if (filtro_prov && *filtro_prov
|
||||
&& abicab.curr().row(TXTCAB_PROV)!=filtro_prov)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// filtro i CAB di prossima apertura
|
||||
if (!cab_futuri && abicab.curr().row(TXTCAB_EFFICIENZA)==E_PROSS_AP)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
abicab.autosave(LF_TABCOM);
|
||||
}
|
||||
abicab.close();
|
||||
}
|
||||
|
||||
|
||||
int ba5300(int argc, char* argv[])
|
||||
{
|
||||
TRicezioneABICAB app;
|
||||
app.run(argc,argv,"Ricezione ABI e CAB");
|
||||
return 0;
|
||||
}
|
23
ba/ba5300.h
Executable file
23
ba/ba5300.h
Executable file
@ -0,0 +1,23 @@
|
||||
#define TRACCIATO_ABI "11"
|
||||
#define TXTABI_ABI 1
|
||||
#define TXTABI_RAGSOC 4
|
||||
|
||||
#define TRACCIATO_CAB "21"
|
||||
#define TXTCAB_ABI 1
|
||||
#define TXTCAB_CAB 2
|
||||
#define TXTCAB_CABLOC 4
|
||||
#define TXTCAB_EFFICIENZA 6
|
||||
#define E_ATTIVO "0"
|
||||
#define E_PROSS_AP "1"
|
||||
#define TXTCAB_INDIRIZZO 7
|
||||
#define TXTCAB_LOCALITA 8
|
||||
#define TXTCAB_COMUNE 9
|
||||
#define TXTCAB_CAP 3
|
||||
#define TXTCAB_PROV 11
|
||||
|
||||
#define TRACCIATO_DENCAB "31"
|
||||
#define TXTDENCAB_ABI 1
|
||||
#define TXTDENCAB_CAB 2
|
||||
#define TXTDENCAB_DENOMIN 3
|
||||
|
||||
#define TRACCIATO_DENCABALT "32"
|
167
ba/ba5300.ini
Executable file
167
ba/ba5300.ini
Executable file
@ -0,0 +1,167 @@
|
||||
[MAIN]
|
||||
TYPEFIELD = 0
|
||||
DECSEP =
|
||||
RECORDSEP =
|
||||
RECORDSIZE = 0
|
||||
FIELDSEP =
|
||||
|
||||
[TYPE STRINGA_R]
|
||||
PICTURE =
|
||||
FILLER =
|
||||
DECIMAL = 0
|
||||
ALIGN = R
|
||||
LENGTH = 0
|
||||
|
||||
[TYPE STRINGA_L]
|
||||
PICTURE =
|
||||
FILLER =
|
||||
DECIMAL = 0
|
||||
ALIGN = L
|
||||
LENGTH = 0
|
||||
|
||||
[TYPE NUMERO]
|
||||
PICTURE =
|
||||
FILLER =
|
||||
DECIMAL = 0
|
||||
ALIGN =
|
||||
LENGTH = 5
|
||||
|
||||
[TYPE BOOLEANO]
|
||||
PICTURE =
|
||||
FILLER =
|
||||
DECIAML = 0
|
||||
DECIMAL = 0
|
||||
ALIGN = R
|
||||
LENGTH = 1
|
||||
|
||||
[TYPE TIPO_TRACCIATO]
|
||||
PICTURE =
|
||||
FILLER =
|
||||
DECIMAL = 0
|
||||
ALIGN =
|
||||
LENGTH = 2
|
||||
|
||||
[RECORD 11]
|
||||
USE=%BA8
|
||||
|
||||
NAME(0)="11"
|
||||
TYPE(0)=TIPO_TRACCIATO
|
||||
POSITION(0)=0
|
||||
|
||||
NAME(1)=CODICE_ABI
|
||||
TYPE(1)=STRINGA_L
|
||||
POSITION(1)=2
|
||||
LENGHT(1)=5
|
||||
FIELD(1)=CODTAB[1,5]
|
||||
|
||||
NAME(2)=FILLER
|
||||
POSITION(2)=7
|
||||
LENGHT(2)=5
|
||||
|
||||
NAME(3)=CIN ABI
|
||||
POSITION(3)=12
|
||||
LENGHT(3)=1
|
||||
|
||||
NAME(4)=RAG_SOCIALE_BANCA
|
||||
TYPE(4)=STRINGA_L
|
||||
POSITION(4)=13
|
||||
LENGHT(4)=80
|
||||
FIELD(4)=S0
|
||||
|
||||
NAME(5)=TIPOBANCA
|
||||
POSITION(5)=93
|
||||
LENGHT(5)=1
|
||||
|
||||
NAME(6)=ABI_BANCA_SEGUITO
|
||||
POSITION(6)=94
|
||||
LENGHT(6)=5
|
||||
|
||||
NAME(7)=CIN_ABI_BANCA_SEGUITO
|
||||
POSITION(7)=99
|
||||
LENGHT(7)=1
|
||||
|
||||
[RECORD 21]
|
||||
USE=%BA8
|
||||
|
||||
NAME(0)="21"
|
||||
TYPE(0)=TIPO_TRACCIATO
|
||||
POSITION(0)=0
|
||||
|
||||
NAME(1)=CODICE_ABI
|
||||
TYPE(1)=STRINGA_L
|
||||
POSITION(1)=2
|
||||
LENGHT(1)=5
|
||||
FIELD(1)=CODTAB[1,5]
|
||||
|
||||
NAME(2)=CODICE_CAB
|
||||
TYPE(2)=STRINGA_L
|
||||
POSITION(2)=7
|
||||
LENGHT(2)=5
|
||||
FIELD(2)=CODTAB[6,10]
|
||||
|
||||
NAME(10)=CIN ABICAB
|
||||
POSITION(10)=12
|
||||
LENGHT(10)=1
|
||||
|
||||
NAME(4)=CAB_LOCALITA
|
||||
POSITION(4)=13
|
||||
LENGHT(4)=5
|
||||
|
||||
NAME(5)=CIN_CAB_LOCALITA
|
||||
POSITION(5)=18
|
||||
LENGHT(5)=1
|
||||
|
||||
NAME(6)=EFFICIENZA
|
||||
POSITION(6)=19
|
||||
LENGHT(6)=1
|
||||
|
||||
NAME(7)=INDIRIZZO
|
||||
POSITION(7)=20
|
||||
LENGHT(7)=80
|
||||
|
||||
NAME(8)=LOCALITA
|
||||
POSITION(8)=100
|
||||
LENGHT(8)=40
|
||||
FIELD(8)=S1
|
||||
|
||||
NAME(3)=CAP
|
||||
TYPE(3)=STRINGA_L
|
||||
POSITION(3)=180
|
||||
LENGHT(3)=5
|
||||
FIELD(3)=S3
|
||||
|
||||
NAME(9)=COMUNE
|
||||
POSITION(9)=140
|
||||
LENGHT(9)=40
|
||||
|
||||
NAME(11)=PROV
|
||||
POSITION(11)=185
|
||||
LENGHT(11)=2
|
||||
|
||||
[RECORD 31]
|
||||
USE=%BA8
|
||||
|
||||
NAME(0)=Denominazione_cab
|
||||
TYPE(0)=TIPO_TRACCIATO
|
||||
POSITION(0)=0
|
||||
|
||||
NAME(1)=CODICE_ABI
|
||||
TYPE(1)=STRINGA_L
|
||||
POSITION(1)=2
|
||||
LENGHT(1)=5
|
||||
FIELD(1)=CODTAB[1,5]
|
||||
|
||||
NAME(2)=CODICE_CAB
|
||||
TYPE(2)=STRINGA_L
|
||||
POSITION(2)=7
|
||||
LENGHT(2)=5
|
||||
FIELD(2)=CODTAB[6,10]
|
||||
|
||||
NAME(3)=DENOMINAZIONE
|
||||
TYPE(3)=STRINGA_L
|
||||
POSITION(3)=12
|
||||
LENGHT(3)=40
|
||||
FIELD(3)=S0
|
||||
|
||||
[RECORD 32]
|
||||
|
Loading…
x
Reference in New Issue
Block a user