Zacatek uprav Ramcovy plan
This commit is contained in:
@ -6,7 +6,7 @@ uses
|
||||
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
|
||||
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Mask, Vcl.ExtCtrls,
|
||||
IdHTTP, IdSSLOpenSSL, REST.Json, JsonDataObjects,
|
||||
ddPlugin_TLB, frmPekarna, frmTiskyNahledy;
|
||||
ddPlugin_TLB, frmPekarna, frmTiskyNahledy, uPing;
|
||||
|
||||
{$I iConsts.inc}
|
||||
|
||||
@ -71,6 +71,7 @@ type
|
||||
Helios: IHelios;
|
||||
idPrikaz: integer;
|
||||
idStroj: integer;
|
||||
idPaleta: integer;
|
||||
datVyroba: TDateTime;
|
||||
f: TformPekarna;
|
||||
f2: TformTiskyNahledy;
|
||||
@ -85,6 +86,7 @@ var
|
||||
m1, m2: integer;
|
||||
mn, mnSum, mn2: integer;
|
||||
idFormPL, idFormPS, idFormKA: integer;
|
||||
idFormKL: integer; // Kartonový štítek (Zebra)
|
||||
|
||||
|
||||
implementation
|
||||
@ -359,7 +361,7 @@ uses System.DateUtils, System.StrUtils, System.Math,
|
||||
procedure TformZahajeniPalety.btnTiskStitkuClick (Sender: TObject);
|
||||
var lSQL, podm, a, errMsg, rc, nazev1, nazevOp, strojNazev, sarze: string;
|
||||
n1, n2, n3: integer;
|
||||
bid, idF: integer;
|
||||
bidPL, bidKA, idF, idFormNastav: integer;
|
||||
d: integer;
|
||||
operace: TArray<TOperace>;
|
||||
jsemPeceni: boolean;
|
||||
@ -367,6 +369,7 @@ uses System.DateUtils, System.StrUtils, System.Math,
|
||||
mjDilce, szDilce: string;
|
||||
ksVKA: integer;
|
||||
mnozPec, mnozBal, mnoz, sumaMnoz, koefPec: extended;
|
||||
iPing: integer;
|
||||
|
||||
// cPal, typPal: string;
|
||||
i, ii, i2, ii2, id, idx, idVCPrikaz, idPalety, idEROp: integer;
|
||||
@ -378,7 +381,7 @@ uses System.DateUtils, System.StrUtils, System.Math,
|
||||
lHTTP: TIdHTTP;
|
||||
ssl: TIdSSLIOHandlerSocketOpenSSL;
|
||||
lParamList, respStream: TStringStream;
|
||||
resp: string;
|
||||
resp, resp2: string;
|
||||
joOut, joIn, itemsObj: TJSONObject;
|
||||
begin
|
||||
// Tento výrobek nemá štítek, vytisknu pouze paletový
|
||||
@ -399,11 +402,11 @@ uses System.DateUtils, System.StrUtils, System.Math,
|
||||
|
||||
|
||||
if not(TryStrToInt(edtPocetStitku.Text.Trim, n1)) then
|
||||
n1:= 0; // pocet kartonu
|
||||
n1:= 0; // pocet kartonovych stitku
|
||||
if not(TryStrToInt(edtPocetPL.Text.Trim, n2)) then
|
||||
n2:= 0; // pocetPalet
|
||||
if not(TryStrToInt(edtPocetStitkuMax.Text.Trim, n3)) then
|
||||
n3:= 0; // pocet kartonu max
|
||||
n3:= 0; // pocet kartonovych stitku max
|
||||
|
||||
ksVKA:= helUtils.getHeliosIntVal (Helios, 0, 'SELECT dbo.ef_Kmen_VratPocetKsVKartonu (' + idKmen.ToString + ')');
|
||||
|
||||
@ -448,7 +451,19 @@ uses System.DateUtils, System.StrUtils, System.Math,
|
||||
lSQL:= lSQL + ' ,' + idVCPrikaz.ToString + ', ' + idKmen.ToString + ', CONVERT(datetime, N' + edtDatSpotreby.Text.QuotedString + ', 104)' + CRLF + ' SET @i=SCOPE_IDENTITY()' + CRLF + ' END' + CRLF;
|
||||
lSQL:= lSQL + CRLF + 'SELECT @i';
|
||||
idPalety:= helUtils.getHeliosIntVal (Helios, 0, lSQL);
|
||||
Helios.ExecSQL(lSQL);
|
||||
|
||||
if (f<>nil) and (idPalety>0) then
|
||||
begin
|
||||
try
|
||||
f.grdStroje.DataSource.DataSet.Edit;
|
||||
f.grdStroje.DataSource.DataSet.FieldByName('fIDPaleta').AsInteger:= idPalety;
|
||||
f.grdStroje.DataSource.DataSet.Post;
|
||||
except
|
||||
f.grdStroje.DataSource.DataSet.Cancel;
|
||||
end;
|
||||
end;
|
||||
|
||||
// Helios.ExecSQL(lSQL);
|
||||
except on E:Exception do
|
||||
begin
|
||||
Helios.Error (#1'Chyba založení palety ' + pl.ToString + #1 + CRLF + E.Message);
|
||||
@ -458,6 +473,15 @@ uses System.DateUtils, System.StrUtils, System.Math,
|
||||
end;
|
||||
|
||||
|
||||
|
||||
if (opakTisky) and (idPaleta>0) then
|
||||
idPalety:= idPaleta;
|
||||
|
||||
lSQL:= 'UPDATE ' + tblPalety + ' SET TiskDatExpirace=' + IfThen(rbTiskSpotrebaAno.Checked, '1', '0') + ', TiskSarze=' + IfThen(rbTiskSarzeAno.Checked, '1', '0')
|
||||
+ ' WHERE ID=' + idPalety.ToString;
|
||||
Helios.ExecSQL (lSQL);
|
||||
|
||||
|
||||
if (canCont) and not(opakTisky) then // jen pokud neni opakovany tisk (z Nahledu tisku)
|
||||
begin
|
||||
|
||||
@ -564,7 +588,7 @@ uses System.DateUtils, System.StrUtils, System.Math,
|
||||
// posli JSON o vyrobene palete
|
||||
try
|
||||
resp:= GenerujJSON (idPrikaz, idVCPrikaz, idEROp, n1).ToJSON (true).Replace(#10,'').Replace(#9,'').Replace('''','');
|
||||
{$IFNDEF DEBUG}
|
||||
|
||||
if (resp<>'') and (idPalety>0) and (datMod.phServer<>'') then
|
||||
begin
|
||||
resp:= TJson.JsonEncode(resp);
|
||||
@ -573,27 +597,30 @@ uses System.DateUtils, System.StrUtils, System.Math,
|
||||
try
|
||||
lParamList:= TStringStream.Create('');
|
||||
lParamList.WriteString (resp);
|
||||
// http klient je stejny
|
||||
lHTTP:= TIdHTTP.Create;
|
||||
if (datMod.phServer.Contains('https')) then
|
||||
begin
|
||||
ssl:= TIdSSLIOHandlerSocketOpenSSL.Create(nil);
|
||||
ssl.SSLOptions.Method:= sslvTLSv1_2;
|
||||
ssl.SSLOptions.Mode:= sslmUnassigned;
|
||||
lHTTP.IOHandler:= ssl;
|
||||
end;
|
||||
lHTTP.HTTPOptions:= [hoKeepOrigProtocol, hoForceEncodeParams, hoNoProtocolErrorException, hoWantProtocolErrorContent];
|
||||
lHTTP.Request.ContentType := 'application/ld+json';
|
||||
lHTTP.Request.Accept := 'application/ld+json, text/javascript, */*; q=0.01';
|
||||
|
||||
respStream:= TStringStream.Create('');
|
||||
resp:= '';
|
||||
if (helUtils.PingHost (helUtils.NetGetHostName(datMod.phServer))) then
|
||||
begin
|
||||
|
||||
iPing:= uPing.Ping (datMod.phServer, resp);
|
||||
// if (iPing=0) then
|
||||
// begin
|
||||
// http klient je stejny
|
||||
lHTTP:= TIdHTTP.Create;
|
||||
if (datMod.phServer.Contains('https')) then
|
||||
begin
|
||||
ssl:= TIdSSLIOHandlerSocketOpenSSL.Create(nil);
|
||||
ssl.SSLOptions.Method:= sslvTLSv1_2;
|
||||
ssl.SSLOptions.Mode:= sslmUnassigned;
|
||||
lHTTP.IOHandler:= ssl;
|
||||
end;
|
||||
lHTTP.HTTPOptions:= [hoKeepOrigProtocol, hoForceEncodeParams, hoNoProtocolErrorException, hoWantProtocolErrorContent];
|
||||
lHTTP.Request.ContentType := 'application/ld+json';
|
||||
lHTTP.Request.Accept := 'application/ld+json, text/javascript, */*; q=0.01';
|
||||
|
||||
resp:= '';
|
||||
lHTTP.Post (datMod.phServer + IfThen(datMod.phServer.EndsWith('/'), '', '/') + 'prikaz', lParamList, respStream);
|
||||
resp:= respStream.DataString.Replace('\/', '/');
|
||||
Helios.ExecSQL('UPDATE ' + tblPalety + ' SET JSONStartResp=N' + resp.QuotedString + ' WHERE ID=' + idPalety.ToString);
|
||||
end;
|
||||
// end;
|
||||
|
||||
finally
|
||||
respStream.Free;
|
||||
lParamList.Free;
|
||||
@ -602,7 +629,6 @@ uses System.DateUtils, System.StrUtils, System.Math,
|
||||
lHTTP.Free;
|
||||
end;
|
||||
end;
|
||||
{$ENDIF}
|
||||
except
|
||||
end;
|
||||
end; // jen pokud neni opakovany tisk (z Nahledu tisku)
|
||||
@ -610,41 +636,61 @@ uses System.DateUtils, System.StrUtils, System.Math,
|
||||
|
||||
if (canCont) then
|
||||
begin
|
||||
bid:= helUtils.getHeliosIntVal (Helios, 0, 'SELECT DPBID FROM ' + tblObecPrehled + ' WHERE NazevSys=N''hvw_Vyroba_Palety''');
|
||||
bidPL:= helUtils.getHeliosIntVal (Helios, 0, 'SELECT DPBID FROM ' + tblObecPrehled + ' WHERE NazevSys=N''hvw_Vyroba_Palety''');
|
||||
|
||||
// idF:= helUtils.getHeliosIntVal(Helios, 0, 'SELECT ID FROM ' + tblFormDef + ' WHERE Nazev2=N''PEK-2''');
|
||||
if (bid>100000) then
|
||||
if (bidPL>100000) then
|
||||
begin
|
||||
if (idFormKA>0) then
|
||||
|
||||
if (idFormKA>0) then // Kartonový štítek (Zebra)
|
||||
begin
|
||||
lSQL:= 'SELECT TOP(1) ID FROM ' + tblTiskDef + ' WHERE FormDefID=' + idFormKA.ToString + ' AND LoginName IS NULL ORDER BY Prednastaveno DESC';
|
||||
idFormNastav:= helUtils.getHeliosIntVal (Helios, 0, lSQL);
|
||||
if (idFormNastav=0) then
|
||||
begin
|
||||
lSQL:= 'INSERT ' + tblTiskDef + ' (FormDefID, Nazev, Prednastaveno, Implicitni, LevyOkraj, HorniOkraj, TiskFronta) SELECT ' + idFormKA.ToString
|
||||
+ ', N''Tisk Zebra'', 1, 0, 0, 0, N''Zebra''' + CRLF + 'SELECT SCOPE_IDENTITY()';
|
||||
idFormNastav:= helUtils.getHeliosIntVal (Helios, 0, lSQL);
|
||||
end;
|
||||
Helios.ExecSQL('UPDATE ' + tblTiskDef + ' SET PocetKopii=' + n1.ToString + ' WHERE ID=' + idFormNastav.ToString);
|
||||
|
||||
if (rbTiskNaObraz.Checked) then
|
||||
begin
|
||||
podm:= 'hvw_Vyroba_Palety.CisloPalety=N' + pl.ToString.QuotedString;
|
||||
Helios.RunAction2 (bid, podm, 'ActionPrint');
|
||||
if (idFormNastav>0) then
|
||||
Helios.ExecSQL ('UPDATE ' + tblTiskDef + ' SET ZobrazNahled=1 WHERE ID=' + idFormNastav.ToString);
|
||||
// Helios.RunAction2 (bid, podm, 'ActionPrint');
|
||||
end
|
||||
else
|
||||
if (idKmen>0) and (1=0) then
|
||||
begin
|
||||
podm:= 'TabKmenZbozi.ID=' + idKmen.ToString;
|
||||
for i:=1 to n1 do
|
||||
Helios.PrintForm3 (bidKZ, idFormKA, podm); // kartonovy stitek
|
||||
if (idFormNastav>0) then
|
||||
Helios.ExecSQL ('UPDATE ' + tblTiskDef + ' SET ZobrazNahled=0 WHERE ID=' + idFormNastav.ToString);
|
||||
end;
|
||||
|
||||
podm:= 'hvw_Vyroba_Palety.CisloPalety=N' + pl.ToString.QuotedString;
|
||||
// for i:=1 to n1 do
|
||||
Helios.PrintForm3 (bidPL, idFormKA, podm);
|
||||
end;
|
||||
|
||||
if (idFormPL>0) then
|
||||
|
||||
// paletovy list
|
||||
if (bidPL>100000) and (idFormPL>0) then
|
||||
begin
|
||||
podm:= 'hvw_Vyroba_Palety.CisloPalety=N' + pl.ToString.QuotedString;
|
||||
if (rbTiskNaObraz.Checked) and (1=0) then
|
||||
Helios.RunAction2 (bid, podm, 'ActionPrint')
|
||||
// Helios.RunAction2 (bid, podm, 'ActionPrint')
|
||||
else
|
||||
for i:=1 to n2 do
|
||||
Helios.PrintForm3 (bid, idFormPL, podm); // paletovy list
|
||||
Helios.PrintForm3 (bidPL, idFormPL, podm); // paletovy list
|
||||
end;
|
||||
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
dm.NactiStrojeAPraci (f);
|
||||
if not(opakTisky) then
|
||||
dm.NactiStrojeAPraci (f);
|
||||
Close;
|
||||
end;
|
||||
|
||||
@ -652,7 +698,7 @@ uses System.DateUtils, System.StrUtils, System.Math,
|
||||
|
||||
|
||||
procedure TformZahajeniPalety.FormShow (Sender: TObject);
|
||||
var lSQL : string;
|
||||
var lSQL, dat : string;
|
||||
mx: integer;
|
||||
begin
|
||||
if (datVyroba=0) then
|
||||
@ -683,7 +729,7 @@ uses System.DateUtils, System.StrUtils, System.Math,
|
||||
edtPocetPL.Text:= '2'; // tiskne se jeden nebo dva paletove listy
|
||||
|
||||
|
||||
idFormKA:= 0;
|
||||
idFormKA:= 0; // Kartonový štítek (Zebra)
|
||||
idFormPS:= 0;
|
||||
idFormPL:= 0;
|
||||
|
||||
@ -699,6 +745,22 @@ uses System.DateUtils, System.StrUtils, System.Math,
|
||||
if not(TryStrToInt(VarToStr(FieldByNameValues('_PLKK')), idFormPL)) then
|
||||
idFormPL:= 0;
|
||||
end;
|
||||
|
||||
lblWarnStitekKA.Visible:= (idFormKA=0);
|
||||
lblWarnStitekPL.Visible:= (idFormPL=0);
|
||||
|
||||
edtBarvaStitku.Text:= '';
|
||||
edtTypStitku.Text:= '';
|
||||
edtVelkostStitku.Text:= '';
|
||||
|
||||
with Helios.OpenSQL ('SELECT * FROM ' + tblKZe + ' WHERE ID=' + idKmen.ToString) do
|
||||
begin
|
||||
edtBarvaStitku.Text:= VarToStr(FieldByNameValues('_ASOL_BarvaStitku'));
|
||||
// edtTypStitku.Text:= VarToStr(FieldByNameValues('_ASOL_BarvaStitku'));
|
||||
edtVelkostStitku.Text:= VarToStr(FieldByNameValues('_RozmerStitku'));
|
||||
end;
|
||||
|
||||
|
||||
{
|
||||
lSQL:= 'SELECT ke._KL FROM ' + tblVPr + ' vp INNER JOIN ' + tblKZ + ' k ON (k.ID=vp.IdTabKmen) INNER JOIN ' + tblKZe + ' ke ON (ke.ID=k.ID) WHERE vp.ID=' + idPrikaz.ToString;
|
||||
idFormKA:= helUtils.getHeliosIntVal (Helios, 0, lSQL);
|
||||
@ -738,17 +800,38 @@ uses System.DateUtils, System.StrUtils, System.Math,
|
||||
// typ palety je nove jen jeden, neurcuje se dle kmene !!!
|
||||
|
||||
cPal:= '';
|
||||
lSQL:= 'SELECT COUNT(ID) FROM ' + tblPrikazVC + ' WHERE IDPrikaz=' + idPrikaz.ToString + ' AND (Mnozstvi-Odvedeno-Zmetky)>0'
|
||||
if not(opakTisky) then
|
||||
begin
|
||||
lSQL:= 'SELECT COUNT(ID) FROM ' + tblPrikazVC + ' WHERE IDPrikaz=' + idPrikaz.ToString + ' AND (Mnozstvi-Odvedeno-Zmetky)>0'
|
||||
+ ' AND ID NOT IN (SELECT r.IDVyrCis FROM ' + tblRozpracOperR + ' r INNER JOIN ' + tblRozpracOper + ' h ON (h.ID=r.IDEvidRozpracOper) WHERE r.IDVyrCis IS NOT NULL)';
|
||||
mx:= helUtils.getHeliosIntVal (Helios, 0, lSQL);
|
||||
mx:= helUtils.getHeliosIntVal (Helios, 0, lSQL);
|
||||
|
||||
if (mx>0) then
|
||||
begin
|
||||
lSQL:= lSQL.Replace('COUNT(ID) ', 'TOP(1) VyrCislo ') + ' ORDER BY VyrCislo';
|
||||
cPal:= helUtils.getHeliosStrVal (Helios, '', lSQL);
|
||||
end;
|
||||
if (cPal='') then
|
||||
cPal:= helUtils.getHeliosStrVal(Helios, '', 'SELECT dbo.ef_Vyroba_VratNovyPaletovyList (3,NULL,NULL,NULL)');
|
||||
end
|
||||
else
|
||||
if (idPaleta>0) then // pri opakovanem tisku znam ID z dbo._TabVyroba_Palety
|
||||
begin
|
||||
with Helios.OpenSQL ('SELECT * FROM ' + tblPalety + ' WHERE ID=' + idPaleta.ToString + ' AND IDPrikaz=' + idPrikaz.ToString) do
|
||||
begin
|
||||
if (RecordCount=1) then
|
||||
begin
|
||||
cPal:= VarToStr(FieldByNameValues('CisloPalety'));
|
||||
edtSarze.Text:= VarToStr(FieldByNameValues('Sarze'));
|
||||
dat:= VarToStr(FieldByNameValues('DatZahajeni'));
|
||||
if (dat.IndexOf(' ')>-1) then
|
||||
dat:= LeftStr(dat, dat.IndexOf(' ')).Trim;
|
||||
edtDatVyroby.Text:= dat;
|
||||
edtDatSpotreby.Text:= VarToStr(FieldByNameValues('DatExpirace'));
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
if (mx>0) then
|
||||
begin
|
||||
lSQL:= lSQL.Replace('COUNT(ID) ', 'TOP(1) VyrCislo ') + ' ORDER BY VyrCislo';
|
||||
cPal:= helUtils.getHeliosStrVal (Helios, '', lSQL);
|
||||
end;
|
||||
if (cPal='') then
|
||||
cPal:= helUtils.getHeliosStrVal(Helios, '', 'SELECT dbo.ef_Vyroba_VratNovyPaletovyList (3,NULL,NULL,NULL)');
|
||||
|
||||
edtPL.Text:= cPal;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user