1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
| //
// CU02 : Vérif code déposant + verif si cmd en cours de chargement
//
procedure VerifDep(x_AdIp : string; x_User :string; x_dep : string; x_Mod : string; x_Action : string; os_Session : TOracleSession; ss_Sock : TServerSocket; n_idConnect : integer; m_TraceServeur : TMemo);
var
oq_Tcd8, oq_Tcd3, oq_CmdACharger, oq_NbPal,oq_NbPal1, oq_NbPalLues,oq_NbPalLues1, oq_NbCmdCharge : TOracleQuery;
x_cmd, x_tournee, x_listCharge, x_aEnvoyer, x_lec, x_typeEnvoi, x_chg, x_tcd : string;
b_RecupDonnees, b_RecupList, b_GenerationList, b_RecupNbCmd : boolean;
n_nbPal, n_nbPalLues, n_CmdEnCours : integer;
begin
x_cmd := '';
x_tournee := '';
x_listCharge := '';
x_cmd := '';
x_aEnvoyer := '';
x_listCharge := '';
x_typeEnvoi := '';
n_nbPal := 0;
n_nbPalLues := 0;
n_CmdEnCours := 0;
b_RecupDonnees := False;
b_RecupList := False;
b_GenerationList := False;
b_RecupNbCmd := False;
oq_Tcd8:=TOracleQuery.Create(Nil); oq_Tcd8.Session := os_Session;
oq_Tcd3:=TOracleQuery.Create(Nil); oq_Tcd3.Session := os_Session;
oq_CmdACharger:=TOracleQuery.Create(Nil); oq_CmdACharger.Session := os_Session;
oq_NbPal:=TOracleQuery.Create(Nil); oq_NbPal.Session := os_Session;
oq_NbPal1:=TOracleQuery.Create(Nil); oq_NbPal1.Session := os_Session;
oq_NbPalLues:=TOracleQuery.Create(Nil); oq_NbPalLues.Session := os_Session;
oq_NbPalLues1:=TOracleQuery.Create(Nil); oq_NbPalLues1.Session := os_Session;
oq_NbCmdCharge:=TOracleQuery.Create(Nil); oq_NbCmdCharge.Session := os_Session;
zx_dejaPasse := 'N';
x_lec := RetourneNomScan(x_AdIp, os_Session);
Try
// On recherche les commandes dont le TCD est à 8 :
oq_Tcd8.Close; oq_Tcd8.SQL.Clear;
oq_Tcd8.SQL.Add('Select CDEXENT, DEPXENT, NUMXENT, CHGXENT, TCDXENT from ENTXRES where DEPXENT ='''+x_dep+'''and CHGXENT=''P''');
oq_Tcd8.SQL.Add('and TCDXENT=''8'' and LDCXENT=''Y'' group by CDEXENT, DEPXENT, NUMXENT, CHGXENT, TCDXENT');
TestRequete1(oq_Tcd8, 'OPENREQ', 'Echec sélection TCD8 (UnitChgtML - 001)', os_Session);
// On recherche toutes les commandes dont le TCD = 3
oq_Tcd3.Close; oq_Tcd3.SQL.Clear;
oq_Tcd3.SQL.Add('Select CDEXENT, DEPXENT, NUMXENT, CHGXENT, TCDXENT from ENTXRES where DEPXENT ='''+x_dep+''' and TCDXENT=''3''');
oq_Tcd3.SQL.Add('and CHGXENT <> ''Y'' and LDCXENT=''Y'' ORDER BY CHGXENT DESC');
TestRequete1(oq_Tcd3, 'OPENREQ', 'Echec sélection TCD3 (UnitChgtML - 002)', os_Session);
if not oq_Tcd8.Eof then
begin
x_cmd := oq_Tcd8.FieldasString('CDEXENT');
x_chg := oq_Tcd8.FieldasString('CHGXENT');
x_tcd := oq_Tcd8.FieldasString('TCDXENT');
if (x_chg = 'S') or (x_chg = 'P') then
begin
x_cmd := '';
b_RecupList := True; // Ne prend que celui-ci pq ?
b_GenerationList := False; // prend celui ci aussi
b_RecupNbCmd := True;
b_RecupDonnees := True;
end
else
begin
b_RecupList := True
b_GenerationList := False;
b_RecupNbCmd := False;
b_RecupDonnees := False;
end;
end;
If not oq_Tcd3.Eof then
begin
x_cmd := oq_Tcd3.FieldasString('CDEXENT');
x_chg := oq_Tcd3.FieldasString('CHGXENT');
x_tcd := oq_Tcd3.FieldasString('TCDXENT');
if oq_Tcd3.FieldAsString('CHGXENT') = 'S' then
begin
b_RecupDonnees := True;
b_RecupList := True;
b_RecupNbCmd := True;
end
else if x_chg = 'P' then
begin
b_RecupDonnees := True;
b_GenerationList := True;
b_RecupNbCmd := True;
end
else if x_chg = 'N' then
begin
x_cmd := '';
b_GenerationList := True;
// JA : 24/10/13 : Rajout des 3 affectations suivantes, pour ne pas passer dans des conditions inutiles
b_RecupDonnees := False;
b_RecupList := False;
b_RecupNbCmd := False;
end
else
begin
b_RecupList := False;
b_GenerationList := False;
b_RecupNbCmd := False;
b_RecupDonnees := False;
envoiMsgSocket(n_idConnect, x_dep, uppercase('NOCMDCHARGE'), ss_Sock, m_TraceServeur);
maj_raoxres(x_User, x_lec, x_Mod, x_Action, '', '', '', x_dep,'' , 'CHGT ML - Pas de commande à charger pour ce déposant', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 'Y', 'N', 'N', 'A', os_Session);
exit;
end;
end
else
begin
envoiMsgSocket(n_idConnect, x_dep, uppercase('NOCMDCHARGE'), ss_Sock, m_TraceServeur);
maj_raoxres(x_User, x_lec, x_Mod, x_Action, '', '', '', x_dep,'' , 'CHGT ML - Pas de commande à charger pour ce déposant', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 'Y', 'N', 'N', 'A', os_Session);
exit;
end;
if b_RecupNbCmd then
begin
oq_NbCmdCharge.Close; oq_NbCmdCharge.SQL.Clear;
oq_NbCmdCharge.SQL.Add('Select count(*) as TOTAL from ENTXRES where DEPXENT ='''+x_dep+'''and CHGXENT='''+x_chg+''' and TCDXENT='''+x_tcd+''' and ');
oq_NbCmdCharge.SQL.Add('LDCXENT=''Y''');
TestRequete1(oq_NbCmdCharge, 'OPENREQ', 'Echec calcul cmd en cours de chgt(UnitChgtML - 026)', os_Session);
if not oq_NbCmdCharge.Eof then
n_CmdEnCours := oq_NbCmdCharge.FieldAsInteger('TOTAL')
else // plus besoin ?
n_CmdEnCours := 0;
end;
oq_CmdACharger.Close; oq_CmdACharger.SQL.Clear;
oq_CmdACharger.SQL.Add('select TOUXCHG, CDEXCHG, LISXCHG, ACTXCHG from CHGXRES where CDEXCHG='''+x_cmd+'''');
oq_CmdACharger.SQL.Add('and DEPXCHG='''+x_dep+'''');
TestRequete1(oq_CmdACharger, 'OPENREQ', 'Echec récupération données(UnitChgtML - 003)', os_Session);
if not oq_CmdACharger.Eof then // if rajoutée par JA le 21/06/2013
begin
if b_RecupList then
begin
if x_aEnvoyer = '' then
begin
x_aEnvoyer := oq_CmdACharger.FieldAsString('LISXCHG');
x_typeEnvoi := 'A';
end
else
x_aEnvoyer := x_aEnvoyer +TAB+ oq_CmdACharger.FieldAsString('LISXCHG'); //récup liste chgt
end;
end;
if b_RecupDonnees then
begin
{*oq_NbPal.Close;
oq_NbPal.SQL.Clear;
// JA : 23/04/13 : Modif suite ajouts champs LNUXUCM, LLIXUCM, LORXUCM dans UCMXRES
oq_NbPal.SQL.Add('select count(distinct(CUMXUCM)) as TOT from UCMXRES where LNUXUCM='''+oq_Tcd3.FieldAsString('NUMXENT')+''' and ETAXUCM=''380''');
if TestRequete1(oq_NbPal, 'OPENREQ', 'Echec calcul nb palettes à charger(UnitChgtML - 004)', os_Session) then
n_nbPal := oq_NbPal.FieldAsInteger('TOT')
else
n_nbPal := 0;
oq_NbPalLues.Close;
oq_NbPalLues.SQL.Clear;
oq_NbPalLues.SQL.Add('select count(distinct(CUMXUCM)) as TOT from UCMXRES where LNUXUCM='''+oq_Tcd3.FieldAsString('NUMXENT')+''' and ETAXUCM=''400''');
if TestRequete1(oq_NbPalLues, 'OPENREQ', 'Echec calcul nb pal lues (UnitChgtML - 005)', os_Session) then
n_nbPalLues := oq_NbPalLues.FieldAsInteger('TOT')
else
n_nbPalLues := 0; *}
//JA 05/11/2013 : Modification calcul nb pal lues et nb pal à charger pour que les UMS soient pris en compte
//Récupération du nombre de palette UM à charger pour la commande
oq_NbPal.Close; oq_NbPal.SQL.Clear;
oq_NbPal.SQL.Add('Select Count(distinct(CUMXUCM)) NBUM from UCMXRES where LNUXUCM ='''+oq_Tcd3.FieldAsString('NUMXENT')+''' and ETAXUCM=''380'' and CUMXUCM<>''0''');
if TestRequete1(oq_NbPal, 'OPENREQ', 'Echec calcul nb palettes à charger(UnitChgtML - 004)', os_Session) then
n_nbPal := oq_NbPal.FieldAsInteger('NBUM')
else
n_nbPal := 0;
//Récupération du nombre de palettes UMS à charger pour la commande
oq_NbPal1.Close; oq_NbPal1.SQL.Clear;
oq_NbPal1.SQL.Add('Select Count(distinct(CUCXUCM)) NBUMS from UCMXRES where LNUXUCM ='''+oq_Tcd3.FieldAsString('NUMXENT')+''' and ETAXUCM=''380'' and CUMXUCM=''0''');
if TestRequete1(oq_NbPal, 'OPENREQ', 'Echec calcul nb palettes à charger(UnitChgtML - 004(2))', os_Session) then
n_nbPal := n_nbPal + oq_NbPal1.FieldAsInteger('NBUMS');
//Récupération du nombre de palettes déjà chargées pour la commande
oq_NbPalLues.Close; oq_NbPalLues.SQL.Clear;
oq_NbPalLues.SQL.Add('Select Count(distinct(CUMXUCM)) NBPALLUUM from UCMXRES where LNUXUCM ='''+oq_Tcd3.FieldAsString('NUMXENT')+''' and ETAXUCM=''400'' and CUMXUCM<>''0''');
if TestRequete1(oq_NbPalLues, 'OPENREQ', 'Echec calcul nb pal lues (UnitChgtML - 005(2))', os_Session) then
n_nbPalLues := oq_NbPalLues.FieldAsInteger('NBPALLUUM')
else
n_nbPalLues := 0;
//Récupération du nombre de palettes UMS déjà chargées pour la commande
oq_NbPalLues1.Close; oq_NbPalLues1.SQL.Clear;
oq_NbPalLues1.SQL.Add('Select Count(distinct(CUCXUCM)) NBPALLUUMS from UCMXRES where LNUXUCM ='''+oq_Tcd3.FieldAsString('NUMXENT')+''' and ETAXUCM=''400'' and CUMXUCM=''0''');
if TestRequete1(oq_NbPal, 'OPENREQ', 'Echec calcul nb pal lues(UnitChgtML - 005)', os_Session) then
n_nbPalLues := n_nbPalLues + oq_NbPalLues1.FieldAsInteger('NBPALLUUMS');
if x_aEnvoyer = '' then
begin
n_nbPalLues := 0; // BI 26-27-28/03/2013
x_aEnvoyer := oq_CmdACharger.FieldAsString('CDEXCHG') +TAB+ oq_CmdACharger.FieldAsString('TOUXCHG') +TAB+ oq_CmdACharger.FieldAsString('ACTXCHG') +TAB+ IntToStr(n_nbPal) +TAB+ IntToStr(n_nbPalLues);
x_typeEnvoi := 'C';
end
else
begin
x_aEnvoyer := x_aEnvoyer +TAB+ oq_CmdACharger.FieldAsString('CDEXCHG') +TAB+ oq_CmdACharger.FieldAsString('TOUXCHG') +TAB+ oq_CmdACharger.FieldAsString('ACTXCHG') +TAB+ IntToStr(n_nbPal) +TAB+ IntToStr(n_nbPalLues);
x_typeEnvoi := 'B';
end;
end;
if b_GenerationList then
begin
x_listCharge := GenerationList(x_user, x_AdIp, '1', x_mod, x_action, os_session, ss_sock, n_idConnect, m_TraceServeur);
if x_aEnvoyer = '' then
begin
x_aEnvoyer := x_listCharge;
x_typeEnvoi := 'D';
end
else
begin
x_aEnvoyer := x_aEnvoyer +TAB+ x_listCharge;
x_typeEnvoi := 'C';
end;
end;
maj_raoxres(x_User, x_lec, x_Mod, x_Action, x_cmd, '', '', x_dep,'' , 'CHGT ML - Renvoi des infos OK', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 'N', 'N', 'N', 'A', os_Session);
envoiMsgSocket(n_idConnect, x_dep, x_typeEnvoi + TAB+ IntToStr(n_CmdEnCours) +TAB+ x_aEnvoyer, ss_Sock, m_TraceServeur);
Finally
oq_Tcd8.Close; oq_Tcd8.Free;
oq_Tcd3.Close; oq_Tcd3.Free;
oq_CmdACharger.Close; oq_CmdACharger.Free;
oq_NbPal.Close; oq_NbPal.Free;
oq_NbPal1.Close; oq_NbPal1.Free;
oq_NbPalLues.Close; oq_NbPalLues.Free;
oq_NbPalLues1.Close; oq_NbPalLues1.Free;
oq_NbCmdCharge.Close; oq_NbCmdCharge.Free;
End;
end; |
Partager