Patch level : 12.0
Files correlati : Commento : Sistemato Campo/Compass! - Rifatta query O01C, a causa di un errore delle query di Campo adesso verrà fatta 3 volte la query per esportare con l'anno in chiave. Con questo metodo sono più che raddoppiati i record esportati, come mai? git-svn-id: svn://10.65.10.50/branches/R_10_00@23936 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
8d64ad8819
commit
df6e74ca09
@ -222,7 +222,6 @@ TString TCampass_app::esporta(const TString& DSN, const TString& usr, const TStr
|
||||
|
||||
if(m->get_bool(B_EXPORT))
|
||||
{
|
||||
|
||||
// INIZIO O03
|
||||
logFile << getTime() << " - Inizio esportazione O03:\n";
|
||||
|
||||
@ -249,7 +248,6 @@ TString TCampass_app::esporta(const TString& DSN, const TString& usr, const TStr
|
||||
|
||||
logFile << getTime() << " - Fine esportazione P02!\n";
|
||||
|
||||
|
||||
// INIZIO P01
|
||||
|
||||
logFile << getTime() << " - Inizio esportazione P01:\n";
|
||||
@ -320,7 +318,6 @@ TString TCampass_app::esporta(const TString& DSN, const TString& usr, const TStr
|
||||
|
||||
logFile << getTime() << " - Fine esportazione O01!\n";
|
||||
|
||||
|
||||
// INIZIO A01
|
||||
|
||||
logFile << getTime() << " - Inizio esportazione A01:\n";
|
||||
@ -334,7 +331,6 @@ TString TCampass_app::esporta(const TString& DSN, const TString& usr, const TStr
|
||||
endExport(a01);
|
||||
|
||||
logFile << getTime() << " - Fine esportazione A01!\n";
|
||||
|
||||
}
|
||||
|
||||
if(m->get_bool(B_IMPORT))
|
||||
@ -593,66 +589,50 @@ bool TCampass_app::o01c(const TString id) const
|
||||
|
||||
TRelation rdist(LF_RDIST),rdoc(LF_RIGHEDOC), filtro(LF_RIGHEDOC);
|
||||
int items;
|
||||
TString msg("Esportazione tabella "); msg << "O01C";
|
||||
|
||||
// Cursore RDOC
|
||||
TRectype filtroRDoc(rdoc.curr()); filtroRDoc.put("CODNUM", "ORP1");
|
||||
TSorted_cursor curRDoc(&rdoc, "CODART", "", 1, &filtroRDoc, &filtroRDoc);
|
||||
|
||||
// Cursore RDIST
|
||||
TSorted_cursor curRDist(&rdist, "CODDIST", "TIPO==\"A\"");
|
||||
|
||||
items = curRDoc.items();
|
||||
curRDist.items();
|
||||
TProgress_monitor p(items, msg);
|
||||
|
||||
curRDoc = 0, curRDist = 0;
|
||||
TRectype rowRDoc = curRDoc.curr(), rowRDist = curRDist.curr();
|
||||
for (; curRDoc.pos() < items && curRDist.pos() < curRDist.items() && !p.is_cancelled(); ++curRDoc)
|
||||
for(int year = TDate(TODAY).year() - 2; year <= TDate(TODAY).year(); year++)
|
||||
{
|
||||
// Aggiorno il Progress Monitor
|
||||
if (!p.add_status())
|
||||
break;
|
||||
TString msg("Esportazione tabella "); msg << "O01C Anno: " << year;
|
||||
// I long non danno errori in creazione
|
||||
TString campoQuery = "USE RDIST\n";
|
||||
campoQuery << "SELECT (113.TIPO=\"A\")&&(34.RIGAEVASA!=\"X\")\n";
|
||||
campoQuery << "JOIN RDOC KEY 5 INTO CODART==CODDIST ANNO==" << year << " CODNUM=='ORP1'\n";
|
||||
//campoQuery << "BY 113.CODDIST";
|
||||
|
||||
rowRDoc = curRDoc.curr();
|
||||
rowRDist = curRDist.curr();
|
||||
TISAM_recordset curDist(campoQuery);
|
||||
items = curDist.items();
|
||||
|
||||
while (rowRDoc.get("CODART") != rowRDist.get("CODDIST"))
|
||||
{
|
||||
while(rowRDoc.get("CODART") < rowRDist.get("CODDIST"))
|
||||
{
|
||||
++curRDoc;
|
||||
rowRDoc = curRDoc.curr();
|
||||
}
|
||||
while(rowRDoc.get("CODART") > rowRDist.get("CODDIST"))
|
||||
{
|
||||
++curRDist;
|
||||
rowRDist = curRDist.curr();
|
||||
}
|
||||
}
|
||||
|
||||
// Filtro aggiuntivo
|
||||
if(rowRDist.get("TIPO") == "A" && !rowRDoc.get_bool("RIGAEVASA"))
|
||||
TProgress_monitor p(items, msg);
|
||||
|
||||
for (bool ok = curDist.move_first(); ok && !p.is_cancelled(); ok = curDist.move_next())
|
||||
{
|
||||
// Aggiorno il Progress Monitor
|
||||
if (!p.add_status())
|
||||
break;
|
||||
|
||||
if(curDist.get("34.RIGAEVASA").as_bool())
|
||||
bool tolla = true;
|
||||
|
||||
// Vado a prendere la riga di riferimento
|
||||
TRectype filtroFiltro(filtro.curr());
|
||||
if(rowRDoc.get("DACODNUM") == "ORC" || rowRDoc.get("DACODNUM") == "PRC")
|
||||
if(curDist.get("34.DACODNUM").as_string() == "ORC" || curDist.get("34.DACODNUM").as_string() == "PRC")
|
||||
{
|
||||
filtroFiltro.put("CODNUM", rowRDoc.get("DACODNUM"));
|
||||
filtroFiltro.put("ANNO", rowRDoc.get("DAANNO"));
|
||||
filtroFiltro.put("PROVV", rowRDoc.get("DAPROVV"));
|
||||
filtroFiltro.put("NDOC", rowRDoc.get("DANDOC"));
|
||||
filtroFiltro.put("CODNUM", curDist.get("34.DACODNUM").as_string());
|
||||
filtroFiltro.put("ANNO", curDist.get("34.DAANNO").as_string());
|
||||
filtroFiltro.put("PROVV", curDist.get("34.DAPROVV").as_string());
|
||||
filtroFiltro.put("NDOC", curDist.get("34.DANDOC").as_string());
|
||||
|
||||
TCursor curFiltro(&rdoc, "", 1, &filtroFiltro, &filtroFiltro);
|
||||
if(curFiltro.items() > 1)
|
||||
bool tolla2 = true;
|
||||
for (curFiltro = 0; curFiltro.pos() < curFiltro.items() && !p.is_cancelled(); ++curFiltro)
|
||||
{
|
||||
// Filtro aggiuntivo
|
||||
if(curFiltro.curr().get_int("IDRIGA") != rowRDoc.get_int("DAIDRIGA") || curFiltro.curr().get_bool("RIGAEVASA")) continue;
|
||||
if(curFiltro.curr().get_int("IDRIGA") != curDist.get("34.DAIDRIGA").as_int() || curFiltro.curr().get_bool("RIGAEVASA")) continue;
|
||||
TString sqlQuery;
|
||||
sqlQuery << "INSERT INTO O01C ( IKRUNIMP, CStr, CPRD, CARTFIL, CUDM, QIMP, QBASE, XTCALC, NSEQ ) \
|
||||
VALUES('" << id << "','DBS','" << zeroFill(rowRDoc.get("NDOC")) << "." << rowRDoc.get("IDRIGA") << "','" << rowRDist.get("CODCOMP") << "','"
|
||||
<< rowRDist.get("UM") << "','" << rowRDist.get("EXPR") << "','1','0','" << rowRDist.get("NRIG") << "');";
|
||||
sqlQuery << "INSERT INTO O01C ( IKRUNIMP, CStr, CPRD, CARTFIL, CUDM, QIMP, QBASE, XTCALC, NSEQ )";
|
||||
sqlQuery << "VALUES('" << id << "','DBS','" << zeroFill(curDist.get("34.NDOC").as_string()) << ".";
|
||||
sqlQuery << curDist.get("34.IDRIGA").as_string() << "','" << curDist.get("113.CODCOMP").as_string() << "','";
|
||||
sqlQuery << curDist.get("113.UM").as_string() << "','" << curDist.get("113.EXPR").as_string() << "','1','0','" << curDist.get("113.NRIG").as_string() << "');";
|
||||
if(sqlset.exec(sqlQuery) != 1)
|
||||
{
|
||||
message_box(sqlQuery);
|
||||
@ -660,9 +640,7 @@ bool TCampass_app::o01c(const TString id) const
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return sqlset.commit() == -1 ? false : true;
|
||||
}
|
||||
@ -1108,7 +1086,7 @@ bool TCampass_app::p01c(const TString id) const
|
||||
return false;
|
||||
|
||||
int items;
|
||||
TString msg("Esportazione tabella "); msg << "P02A";
|
||||
TString msg("Esportazione tabella "); msg << "P01C";
|
||||
TRelation anamag(LF_ANAMAG);
|
||||
TCursor curAna(&anamag);
|
||||
items = curAna.items();
|
||||
@ -1160,7 +1138,7 @@ bool TCampass_app::c09a() const
|
||||
TODBC_recordset sqlset("", true);
|
||||
if (!sqlset.connect(DSN, usr, psw))
|
||||
return false;
|
||||
TString sqlQuery = "SELECT * \
|
||||
TString sqlQuery = "SELECT TOP 1 * \
|
||||
FROM C09A JOIN RUNEXP ON C09A.IKRUNEXP = RUNEXP.IDRUNEXP \
|
||||
WHERE RUNEXP.DWEND IS NOT NULL AND RUNEXP.DRINI IS NULL;";
|
||||
if(sqlset.exec(sqlQuery) <= 0)
|
||||
@ -1172,11 +1150,19 @@ bool TCampass_app::c09a() const
|
||||
// Flaggo tutti i record con l'ora di inizio, sarebbe meglio farli dopo ma chissene
|
||||
TString driniQuery = "UPDATE [dbo].[RUNEXP] SET [DRINI] = CURRENT_TIMESTAMP WHERE [DRINI] IS NULL AND [CFLUSSO] = 'C09';";
|
||||
TODBC_recordset sqlDrini("", true);
|
||||
if(!sqlDrini.connect(DSN, usr, psw) || sqlDrini.exec(driniQuery) != 1)
|
||||
|
||||
if(!sqlDrini.connect(DSN, usr, psw) || sqlDrini.exec(driniQuery) < 0)
|
||||
{
|
||||
message_box(driniQuery);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Facendo l'UPDATE "perdo" la SELECT, quindi la rifaccio leggermente modificata
|
||||
sqlQuery = "SELECT * \
|
||||
FROM C09A JOIN RUNEXP ON C09A.IKRUNEXP = RUNEXP.IDRUNEXP \
|
||||
WHERE RUNEXP.DWEND IS NOT NULL AND RUNEXP.DREND IS NULL;";
|
||||
|
||||
sqlset.exec(sqlQuery);
|
||||
|
||||
// Importo tutto quello che ho trovato
|
||||
TLocalisamfile tabMod(LF_TABMOD);
|
||||
|
Loading…
x
Reference in New Issue
Block a user