Prvni verze
This commit is contained in:
15
_custom/GatemaSD/info.txt
Normal file
15
_custom/GatemaSD/info.txt
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
|
||||
|
||||
Gatema_SDDoklady
|
||||
***********************
|
||||
TypDokladu - 510 - kontrola prijmu / 540 - prijem
|
||||
IDDokZbo - zdrojovy doklad (napr. pri kontrole prijmu)
|
||||
|
||||
|
||||
|
||||
|
||||
Gatema_SDScanData
|
||||
***********************
|
||||
IDPohZbo - ID zdrojoveho pohybu OZ (napr. pri kontrole prijmu)
|
||||
|
||||
313
_custom/GatemaSD/uCtrlCustomSDG.pas
Normal file
313
_custom/GatemaSD/uCtrlCustomSDG.pas
Normal file
@ -0,0 +1,313 @@
|
||||
unit uCtrlCustomSDG;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
MVCframework,
|
||||
MVCframework.Commons,
|
||||
MVCframework.Serializer.Commons,
|
||||
// MVCframework.Serializer.Intf,
|
||||
System.Generics.Collections, // kvuli TDictionary
|
||||
System.RegularExpressions,
|
||||
// JsonDataObjects,
|
||||
uCommons, // kvuli EServiceException
|
||||
uCtrlBase,
|
||||
// uSvc_Base,
|
||||
uHeoObj_Base,
|
||||
// uHeOObj_Custom,
|
||||
uSvcCustomSDG,
|
||||
uHeOObj_CustomSDG,
|
||||
MVCFramework.Swagger.Commons; // kvuli dokumentaci
|
||||
|
||||
type
|
||||
|
||||
[MVCPath('/sdserver/doklad')]
|
||||
TGatemaSDDokladController = class(TBaseController)
|
||||
strict private
|
||||
FSelfSvc: TGatemaSDDokladService;
|
||||
strict protected
|
||||
function GetGatemaSDDokladService: TGatemaSDDokladService;
|
||||
public
|
||||
destructor Destroy; override;
|
||||
|
||||
[MVCPath('')]
|
||||
[MVCHTTPMethod([httpGET])]
|
||||
[MVCSwagSummary('GatemaSD_Doklad', 'Vrací hlavičku dokladů SD Serveru', 'GatemaSDDokladyGetAll')]
|
||||
[MVCSwagParam(plQuery, 'od', 'Datum od ve formátu RRRRMMDD', ptString, false)]
|
||||
procedure GetAll([MVCFromQueryString('od', '')] odDatum: string=''
|
||||
);
|
||||
|
||||
[MVCPath('/meta')]
|
||||
[MVCHTTPMethod([httpGET])]
|
||||
[MVCSwagSummary('GatemaSD_Doklad', 'Vrací metadata', 'GatemaSDDokladyGetMeta')]
|
||||
procedure GetMeta;
|
||||
|
||||
[MVCPath('/($id)')]
|
||||
[MVCHTTPMethod([httpGET])]
|
||||
[MVCSwagSummary('GatemaSD_Doklad', 'Vrací data dokladu SD Serveru', 'GatemaSDDokladyGetByID')]
|
||||
[MVCSwagParam(plPath, 'id', 'ID dokladu', ptString, false)]
|
||||
[MVCSwagParam(plQuery, 'typdokl', 'Typ dokladu', ptString, false)]
|
||||
[MVCSwagParam(plQuery, 'druhpohybu', 'Druh pohybu zboží', ptString, false)]
|
||||
[MVCSwagParam(plQuery, 'sklad', 'Sklad', ptString, false)]
|
||||
[MVCSwagParam(plQuery, 'format', 'Formát (1=dokladOZ)', ptString, false)]
|
||||
[MVCSwagParam(plQuery, 'od', 'Datum od ve formátu RRRRMMDD', ptString, false)]
|
||||
[MVCSwagParam(plQuery, 'do', 'Datum do ve formátu RRRRMMDD', ptString, false)]
|
||||
[MVCSwagParam(plQuery, 'seznam', '1=jen seznam se základními údaji', ptString, false)]
|
||||
[MVCSwagResponses(200, 'Success', TGatemaSDDoklad, true)]
|
||||
procedure GetByID (id: string='';
|
||||
[MVCFromQueryString('typdokl', '')] typDokl: string='';
|
||||
[MVCFromQueryString('druhpohybu', '')] druhPohybu: string='';
|
||||
[MVCFromQueryString('sklad', '')] sklad: string='';
|
||||
[MVCFromQueryString('format', '')] formatX: string='';
|
||||
[MVCFromQueryString('od', '')] odDatum: string='';
|
||||
[MVCFromQueryString('do', '')] doDatum: string='';
|
||||
[MVCFromQueryString('seznam', '')] jenSeznam: string='0'
|
||||
);
|
||||
|
||||
end;
|
||||
|
||||
|
||||
|
||||
[MVCPath('/sdserver/scandata')]
|
||||
TGatemaSDScanDataController = class(TBaseController)
|
||||
strict private
|
||||
FSelfSvc: TGatemaSDScanDataService;
|
||||
strict protected
|
||||
function GetGatemaSDScanDataService: TGatemaSDScanDataService;
|
||||
public
|
||||
destructor Destroy; override;
|
||||
|
||||
[MVCPath('/meta')]
|
||||
[MVCHTTPMethod([httpGET])]
|
||||
[MVCSwagSummary('GatemaSD_ScanData', 'Vrací metadata', 'GatemaSDScanDataGetMeta')]
|
||||
procedure GetMeta;
|
||||
|
||||
[MVCPath('/($id)')]
|
||||
[MVCHTTPMethod([httpGET])]
|
||||
[MVCSwagSummary('GatemaSD_ScanData', 'Vrací naskenovaná data', 'GatemaSDScanDataGetByID')]
|
||||
[MVCSwagParam(plPath, 'id', 'ID scan data', ptString, false)]
|
||||
[MVCSwagParam(plQuery, 'iddoklad', 'ID dokladu SD', ptString, false)]
|
||||
[MVCSwagResponses(200, 'Success', TGatemaSDScanData, true)]
|
||||
procedure GetByID(id: string='';
|
||||
[MVCFromQueryString('iddoklad', '')] iddoklad: string=''
|
||||
);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
implementation
|
||||
uses
|
||||
FireDAC.Stan.Option,
|
||||
FireDAC.Comp.Client,
|
||||
FireDAC.Stan.Param,
|
||||
MVCFramework.FireDAC.Utils,
|
||||
MVCFramework.DataSet.Utils,
|
||||
System.StrUtils,
|
||||
System.SysUtils,
|
||||
uDataMod;
|
||||
|
||||
const
|
||||
selSloupce = '';
|
||||
|
||||
|
||||
|
||||
{ TGatemaSDDokladController }
|
||||
|
||||
destructor TGatemaSDDokladController.Destroy;
|
||||
begin
|
||||
FSelfSvc.Free;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
|
||||
function TGatemaSDDokladController.GetGatemaSDDokladService: TGatemaSDDokladService;
|
||||
begin
|
||||
inherited;
|
||||
if not Assigned(FSelfSvc) then
|
||||
FSelfSvc:= TGatemaSDDokladService.Create(datMod);
|
||||
result:= FSelfSvc;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
procedure TGatemaSDDokladController.GetAll(odDatum: string='');
|
||||
var params: TDictionary<string, string>;
|
||||
// odDatum: string;
|
||||
begin
|
||||
params:= TDictionary<string, string>.Create;
|
||||
odDatum:= sanitizeSQLString(odDatum);
|
||||
if (odDatum<>'') then
|
||||
params.Add('odDatum', odDatum);
|
||||
|
||||
try
|
||||
try
|
||||
Render(ObjectDict().Add('data', GetGatemaSDDokladService.GetByParams(params))); // viz uSvcCustom.pas
|
||||
except
|
||||
on E: EServiceException do
|
||||
begin
|
||||
raise EMVCException.Create(E.Message, '', 0, 404);
|
||||
end;
|
||||
on E:Exception do
|
||||
begin
|
||||
raise EMVCException.Create(E.Message, '', 0, 404);
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
params.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
procedure TGatemaSDDokladController.GetByID(id: string=''; typDokl: string=''; druhPohybu: string=''; sklad: string=''; formatX: string=''; odDatum: string=''; doDatum: string='';
|
||||
jenSeznam: string='0');
|
||||
var iId: integer;
|
||||
params: TDictionary<string, string>;
|
||||
begin
|
||||
params:= TDictionary<string, string>.Create;
|
||||
|
||||
iId:= 0;
|
||||
id:= sanitizeSQLString(id);
|
||||
if (id<>'') then
|
||||
if not(TryStrToInt(id, iId)) then
|
||||
iId:= 0;
|
||||
if (iId>0) then
|
||||
params.Add('id', iId.ToString);
|
||||
|
||||
typDokl:= sanitizeSQLString(sklad);
|
||||
if (typDokl<>'') then
|
||||
params.Add('typDokladu', typDokl);
|
||||
|
||||
druhPohybu:= sanitizeSQLString(sklad);
|
||||
if (druhPohybu<>'') then
|
||||
params.Add('druhPohybu', druhPohybu);
|
||||
|
||||
formatX:= sanitizeSQLString(formatX); // pro zobrazeni jako DokladOZ
|
||||
if (formatX<>'') then
|
||||
if (formatX='1') then
|
||||
params.Add('format', formatX);
|
||||
|
||||
sklad:= sanitizeSQLString(sklad);
|
||||
if (sklad<>'') then
|
||||
params.Add('sklad', sklad);
|
||||
|
||||
odDatum:= sanitizeSQLString(odDatum);
|
||||
if (odDatum<>'') then
|
||||
params.Add('odDatum', odDatum);
|
||||
|
||||
doDatum:= sanitizeSQLString(doDatum);
|
||||
if (doDatum<>'') then
|
||||
params.Add('doDatum', doDatum);
|
||||
|
||||
jenSeznam:= sanitizeSQLString(jenSeznam);
|
||||
if (jenSeznam='1') then
|
||||
params.Add('seznam', '1');
|
||||
|
||||
try
|
||||
try
|
||||
Render(ObjectDict().Add('data', GetGatemaSDDokladService.GetByParams(params))); // viz uSvcCustom.pas
|
||||
except
|
||||
on E: EServiceException do
|
||||
begin
|
||||
raise EMVCException.Create(E.Message, '', 0, 404);
|
||||
end;
|
||||
on E:Exception do
|
||||
begin
|
||||
raise EMVCException.Create(E.Message, '', 0, 404);
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
params.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
procedure TGatemaSDDokladController.GetMeta;
|
||||
begin
|
||||
try
|
||||
Render(ObjectDict().Add('data', GetGatemaSDDokladService.GetMeta));
|
||||
except
|
||||
on E: EServiceException do
|
||||
begin
|
||||
raise EMVCException.Create(E.Message, '', 0, 404);
|
||||
end;
|
||||
on E:Exception do
|
||||
begin
|
||||
raise EMVCException.Create(E.Message, '', 0, 404);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{ TGatemaSDScanDataController }
|
||||
|
||||
destructor TGatemaSDScanDataController.Destroy;
|
||||
begin
|
||||
FSelfSvc.Free;
|
||||
end;
|
||||
|
||||
function TGatemaSDScanDataController.GetGatemaSDScanDataService: TGatemaSDScanDataService;
|
||||
begin
|
||||
inherited Create;
|
||||
if not Assigned(FSelfSvc) then
|
||||
FSelfSvc:= TGatemaSDScanDataService.Create(datMod);
|
||||
result:= FSelfSvc;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
procedure TGatemaSDScanDataController.GetByID(id: string=''; iddoklad: string='');
|
||||
var iId: integer;
|
||||
params: TDictionary<string, string>;
|
||||
begin
|
||||
params:= TDictionary<string, string>.Create;
|
||||
|
||||
iId:= 0;
|
||||
id:= sanitizeSQLString(id);
|
||||
if (id<>'') then
|
||||
if not(TryStrToInt(id, iId)) then
|
||||
iId:= 0;
|
||||
if (iId>0) then
|
||||
params.Add('id', iId.ToString);
|
||||
|
||||
try
|
||||
Render(ObjectDict().Add('data', GetGatemaSDScanDataService.GetByParams(params))); // viz uSvcCustom.pas
|
||||
except
|
||||
on E: EServiceException do
|
||||
begin
|
||||
raise EMVCException.Create(E.Message, '', 0, 404);
|
||||
end;
|
||||
on E:Exception do
|
||||
begin
|
||||
raise EMVCException.Create(E.Message, '', 0, 404);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
procedure TGatemaSDScanDataController.GetMeta;
|
||||
begin
|
||||
try
|
||||
Render(ObjectDict().Add('data', GetGatemaSDScanDataService.GetMeta));
|
||||
except
|
||||
on E: EServiceException do
|
||||
begin
|
||||
raise EMVCException.Create(E.Message, '', 0, 404);
|
||||
end;
|
||||
on E:Exception do
|
||||
begin
|
||||
raise EMVCException.Create(E.Message, '', 0, 404);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
267
_custom/GatemaSD/uHeOObj_CustomSDG.pas
Normal file
267
_custom/GatemaSD/uHeOObj_CustomSDG.pas
Normal file
@ -0,0 +1,267 @@
|
||||
unit uHeOObj_CustomSDG;
|
||||
{$RTTI EXPLICIT METHODS([vcPublic, vcPublished]) FIELDS([vcPrivate, vcProtected, vcPublic, vcPublished]) PROPERTIES([vcPublic, vcPublished])}
|
||||
|
||||
|
||||
interface
|
||||
{$I 'GlobalDefs.inc'}
|
||||
|
||||
uses
|
||||
System.Generics.Collections,
|
||||
MVCFramework.Serializer.Commons,
|
||||
MVCFramework.ActiveRecord,
|
||||
MVCFramework.Nullables,
|
||||
{$IFDEF SWAGGER}
|
||||
MVCFramework.Swagger.Commons,
|
||||
{$ENDIF}
|
||||
helTabsBIDs,
|
||||
uHeoObj_Base;
|
||||
|
||||
const
|
||||
tblGSDDoklady = '[dbo].[Gatema_SDDoklady]';
|
||||
tblGSDScanData = '[dbo].[Gatema_SDScanData]';
|
||||
|
||||
|
||||
type
|
||||
[MVCNameCase(ncLowerCase)]
|
||||
TGatemaSDScanData = class(THeliosObjekty)
|
||||
private
|
||||
FIDDokladSD: integer;
|
||||
FIDZdrojSD: NullableInt32;
|
||||
FIDPolozky: NullableInt32;
|
||||
FIDPrikaz: NullableInt32;
|
||||
FDokladPrKV: NullableInt32;
|
||||
FDokladPrVPV: NullableInt32;
|
||||
FIDPohZbo: NullableInt32;
|
||||
FIDVyrCS_Obj: NullableInt32;
|
||||
FIDInvItem: NullableInt32;
|
||||
FIDPohZbo_New: NullableInt32;
|
||||
FIDKmenZbozi: NullableInt32;
|
||||
FIDStavSkladu: NullableInt32;
|
||||
FVyrCislo: NullableString;
|
||||
FPopisSarze: NullableString;
|
||||
FMnozstvi: Single;
|
||||
FMnozstviEvidence: Single;
|
||||
FMJ: NullableString;
|
||||
FMJEvidence: NullableString;
|
||||
FBarCode: NullableString;
|
||||
FDatumExpirace: NullableTDateTime;
|
||||
FKodBaleni: NullableString;
|
||||
FDatPorizeni: TDateTime;
|
||||
FGenerovat: NullableBoolean;
|
||||
FJedinecneCislo: NullableString;
|
||||
public
|
||||
{
|
||||
[MVCTableField('ID', [foPrimaryKey, foReadOnly])]
|
||||
[MVCColumn('ID')]
|
||||
[MVCSwagJsonSchemaField(stInteger, 'ID', 'ID výrobní operace', true, false)] // typ, sysName, nazev, required, nullable, minLength, maxLength
|
||||
property ID: integer read FID write FID;
|
||||
}
|
||||
[MVCColumn('IDDokladSD', false)]
|
||||
[MVCSwagJsonSchemaField(stInteger, 'IDDokladSD', 'ID dokladu SD', true, false)]
|
||||
property IDDokladSD: integer read FIDDokladSD write FIDDokladSD;
|
||||
|
||||
[MVCColumn('IDZdrojSD', false)]
|
||||
[MVCSwagJsonSchemaField(stInteger, 'IDZdrojSD', 'ID zdorj SD', false, true)]
|
||||
property IDZdrojSD: NullableInt32 read FIDZdrojSD write FIDZdrojSD;
|
||||
|
||||
[MVCColumn('IDPolozky', false)]
|
||||
[MVCSwagJsonSchemaField(stInteger, 'IDPolozky', 'ID položky', false, true)]
|
||||
property IDPolozky: NullableInt32 read FIDPolozky write FIDPolozky;
|
||||
|
||||
[MVCColumn('IDPrikaz', false)]
|
||||
[MVCSwagJsonSchemaField(stInteger, 'IDPrikaz', 'ID výrobního příkazu', false, true)]
|
||||
property IDPrikaz: NullableInt32 read FIDPrikaz write FIDPrikaz;
|
||||
|
||||
[MVCColumn('VyrCislo', false)]
|
||||
[MVCSwagJsonSchemaField(stString, 'VyrCislo', 'Výrobní číslo', true, false, 1, 100)]
|
||||
property VyrCislo: NullableString read FVyrCislo write FVyrCislo;
|
||||
|
||||
[MVCColumn('PopisSarze', false)]
|
||||
[MVCSwagJsonSchemaField(stString, 'PopisSarze', 'Popis šarže', true, false, 1, 100)]
|
||||
property PopisSarze: NullableString read FPopisSarze write FPopisSarze;
|
||||
|
||||
[MVCColumn('Mnozstvi')]
|
||||
[MVCSwagJsonSchemaField('Mnozstvi', 'Množství', true, false)]
|
||||
property Mnozstvi: Single read FMnozstvi write FMnozstvi;
|
||||
|
||||
[MVCColumn('MnozstviEvidence')]
|
||||
[MVCSwagJsonSchemaField('MnozstviEvidence', 'Množství v evidenční jednotce', true, false)]
|
||||
property MnozstviEvidence: Single read FMnozstviEvidence write FMnozstviEvidence;
|
||||
|
||||
[MVCColumn('DatumExpirace')]
|
||||
[MVCSwagJsonSchemaField('DatumExpirace', 'Datum expirace', false, true)]
|
||||
property DatumExpirace: NullableTDatetime read FDatumExpirace write FDatumExpirace;
|
||||
|
||||
[MVCColumn('DatPorizeni')]
|
||||
[MVCSwagJsonSchemaField('DatPorizeni', 'Datum pořízení', true, false)]
|
||||
property DatPorizeni: TDatetime read FDatPorizeni write FDatPorizeni;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[MVCNameCase(ncLowerCase)]
|
||||
TGatemaSDZdrojData = class(THeliosObjekty)
|
||||
private
|
||||
FIDDokladSD: integer;
|
||||
FIDDokZbo: NullableInt32;
|
||||
FIDPrikaz: NullableInt32;
|
||||
FGUIDDokladu: NullableTGUID;
|
||||
public
|
||||
[MVCColumn('IDDokladSD', false)]
|
||||
[MVCSwagJsonSchemaField(stInteger, 'IDDokladSD', 'ID dokladu SD', true, false)]
|
||||
property IDDokladSD: integer read FIDDokladSD write FIDDokladSD;
|
||||
|
||||
[MVCColumn('IDDokZbo', false)]
|
||||
[MVCSwagJsonSchemaField(stInteger, 'FIDDokZbo', 'ID dokladu OZ', false, true)]
|
||||
property IDDokZbo: NullableInt32 read FIDDokZbo write FIDDokZbo;
|
||||
|
||||
[MVCColumn('IDPrikaz', false)]
|
||||
[MVCSwagJsonSchemaField(stInteger, 'IDPrikaz', 'ID výrobního příkazu', false, true)]
|
||||
property IDPrikaz: NullableInt32 read FIDPrikaz write FIDPrikaz;
|
||||
|
||||
[MVCColumn('GUIDDokladu', false)]
|
||||
[MVCSwagJsonSchemaField(stGuid, 'GUIDDokladu', 'GUID dokladu', false, true)]
|
||||
property GUIDDokladu: NullableTGUID read FGUIDDokladu write FGUIDDokladu;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
[MVCNameCase(ncLowerCase)]
|
||||
TGatemaSDDoklad = class(THeliosObjekty)
|
||||
private
|
||||
FTypDokladu: integer;
|
||||
FPodtypDokladu: NullableInt32;
|
||||
FRadaDokladu: NullableString;
|
||||
FDruhPohybuZbo: NullableInt32;
|
||||
FSklad: NullableString;
|
||||
FSkladCil: NullableString;
|
||||
FIDPrikaz: NullableInt32;
|
||||
FIDDokZbo: NullableInt32;
|
||||
FIDDokZbo_New: NullableInt32;
|
||||
FGUIDDokZbo: NullableTGUID;
|
||||
FGUIDDokZbo_New: NullableTGUID;
|
||||
FIDInvHead: NullableInt32;
|
||||
FIDOrg: NullableInt32;
|
||||
FCisloOrg: NullableInt32;
|
||||
FDatumPripadu: NullableTDateTime;
|
||||
FDatPorizeni: TDateTime;
|
||||
FDatGenerovani: NullableTDateTime;
|
||||
FScanData: TObjectList<TGatemaSDScanData>;
|
||||
procedure SetSDScanData (const Value: TObjectList<TGatemaSDScanData>);
|
||||
public
|
||||
constructor Create; virtual;
|
||||
destructor Destroy; override;
|
||||
{
|
||||
[MVCTableField('ID', [foPrimaryKey, foReadOnly])]
|
||||
[MVCColumn('ID')]
|
||||
[MVCSwagJsonSchemaField(stInteger, 'ID', 'ID výrobní operace', true, false)] // typ, sysName, nazev, required, nullable, minLength, maxLength
|
||||
property ID: integer read FID write FID;
|
||||
}
|
||||
[MVCColumn('TypDokladu', false)]
|
||||
[MVCSwagJsonSchemaField(stInteger, 'TypDokladu', 'Typ dokladu', true, false)]
|
||||
property TypDokladu: integer read FTypDokladu write FTypDokladu;
|
||||
|
||||
[MVCColumn('PodtypDokladu', false)]
|
||||
[MVCSwagJsonSchemaField(stInteger, 'PodtypDokladu', 'Podtyp dokladu', false, true)]
|
||||
property PodtypDokladu: NullableInt32 read FPodtypDokladu write FPodtypDokladu;
|
||||
|
||||
[MVCColumn('RadaDokladu', false)]
|
||||
[MVCSwagJsonSchemaField(stString, 'RadaDokladu', 'Řada dokladu', false, true)]
|
||||
property RadaDokladu: NullableString read FRadaDokladu write FRadaDokladu;
|
||||
|
||||
[MVCColumn('DruhPohybuZbo', false)]
|
||||
[MVCSwagJsonSchemaField(stInteger, 'DruhPohybuZbo', 'Druh pohybu zboží', false, true)]
|
||||
property DruhPohybuZbo: NullableInt32 read FDruhPohybuZbo write FDruhPohybuZbo;
|
||||
|
||||
[MVCColumn('Sklad', false)]
|
||||
[MVCSwagJsonSchemaField(stString, 'Sklad', 'Sklad', false, true)]
|
||||
property Sklad: NullableString read FSklad write FSklad;
|
||||
|
||||
[MVCColumn('SkladCil', false)]
|
||||
[MVCSwagJsonSchemaField(stString, 'SkladCil', 'Cílový sklad', false, true)]
|
||||
property SkladCil: NullableString read FSkladCil write FSkladCil;
|
||||
|
||||
[MVCColumn('IDPrikaz', false)]
|
||||
[MVCSwagJsonSchemaField(stInteger, 'IDPrikaz', 'ID výrobního příkazu', false, true)]
|
||||
property IDPrikaz: NullableInt32 read FIDPrikaz write FIDPrikaz;
|
||||
|
||||
[MVCColumn('IDDokZbo', false)]
|
||||
[MVCSwagJsonSchemaField(stInteger, 'IDDokZbo', 'ID dokladu OZ', false, true)]
|
||||
property IDDokZbo: NullableInt32 read FIDDokZbo write FIDDokZbo;
|
||||
|
||||
[MVCColumn('IDDokZbo_New', false)]
|
||||
[MVCSwagJsonSchemaField(stInteger, 'IDDokZbo_New', 'ID nového dokladu OZ', false, true)]
|
||||
property IDDokZbo_New: NullableInt32 read FIDDokZbo_New write FIDDokZbo_New;
|
||||
|
||||
[MVCColumn('IDInvHead', false)]
|
||||
[MVCSwagJsonSchemaField(stInteger, 'IDInvHead', 'ID dokladu inventury', false, true)]
|
||||
property IDInvHead: NullableInt32 read FIDInvHead write FIDInvHead;
|
||||
|
||||
[MVCColumn('IDOrg', false)]
|
||||
[MVCSwagJsonSchemaField(stInteger, 'IDOrg', 'ID organizace', false, true)]
|
||||
property IDOrg: NullableInt32 read FIDOrg write FIDOrg;
|
||||
|
||||
[MVCColumn('CisloOrg', false)]
|
||||
[MVCSwagJsonSchemaField(stInteger, 'CisloOrg', 'Číslo organizace', false, true)]
|
||||
property CisloOrg: NullableInt32 read FCisloOrg write FCisloOrg;
|
||||
|
||||
[MVCColumn('DatumPripadu')]
|
||||
[MVCSwagJsonSchemaField('DatumPripadu', 'Datum případu', false, true)]
|
||||
property DatumPripadu: NullableTDatetime read FDatumPripadu write FDatumPripadu;
|
||||
|
||||
[MVCColumn('DatPorizeni')]
|
||||
[MVCSwagJsonSchemaField('DatPorizeni', 'Datum pořízení', true, false)]
|
||||
property DatPorizeni: TDatetime read FDatPorizeni write FDatPorizeni;
|
||||
|
||||
[MVCColumn('DatGenerovani')]
|
||||
[MVCSwagJsonSchemaField('DatGenerovani', 'Datum generování dokladu OZ', false, true)]
|
||||
property DatGenerovani: NullableTDatetime read FDatGenerovani write FDatGenerovani;
|
||||
|
||||
[MVCListOfAttribute(TGatemaSDScanData)]
|
||||
property ScanData: TObjectList<TGatemaSDScanData> read FScanData write SetSDScanData;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
System.SysUtils,
|
||||
System.StrUtils,
|
||||
System.RegularExpressions;
|
||||
|
||||
|
||||
|
||||
{ TGatemaSDDoklad }
|
||||
|
||||
constructor TGatemaSDDoklad.Create;
|
||||
begin
|
||||
inherited;
|
||||
FScanData:= TObjectList<TGatemaSDScanData>.Create;
|
||||
end;
|
||||
|
||||
|
||||
destructor TGatemaSDDoklad.Destroy;
|
||||
begin
|
||||
// if (FPohybyOZ<>nil) then
|
||||
// FPohybyOZ.Free;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
|
||||
procedure TGatemaSDDoklad.SetSDScanData(const Value: TObjectList<TGatemaSDScanData>);
|
||||
begin
|
||||
if (Value<>FScanData) then
|
||||
begin
|
||||
FScanData.Free;
|
||||
FScanData:= Value;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
404
_custom/GatemaSD/uSvcCustomSDG.pas
Normal file
404
_custom/GatemaSD/uSvcCustomSDG.pas
Normal file
@ -0,0 +1,404 @@
|
||||
unit uSvcCustomSDG;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
System.Generics.Collections,
|
||||
System.DateUtils,
|
||||
System.SysUtils,
|
||||
JsonDataObjects,
|
||||
uSvc_Base,
|
||||
uSvc_ObehZbozi,
|
||||
uCommons, // kvuli EServiceException
|
||||
helTabsBIDs,
|
||||
uHeOObj_Base,
|
||||
uHeOObj_CustomSDG;
|
||||
|
||||
|
||||
const
|
||||
{$I globalConsts.inc}
|
||||
selSpecDoklSD = '(SELECT CisloOrg FROM ' + tblCOrg + ' WHERE ID=main.IDOrg) AS CisloOrg';
|
||||
|
||||
|
||||
type
|
||||
|
||||
TGatemaSDDokladService = class(TServiceBase)
|
||||
public
|
||||
function GetAll: TObjectList<TGatemaSDDoklad>;
|
||||
function GetByParams (params: TDictionary<string, string>): TObjectList<TGatemaSDDoklad>;
|
||||
function GetByID (const AID: integer; const bezPolozek: boolean=false): TGatemaSDDoklad;
|
||||
function GetMeta: TJSONObject;
|
||||
end;
|
||||
|
||||
|
||||
TGatemaSDScanDataService = class(TServiceBase)
|
||||
public
|
||||
function GetByParams (params: TDictionary<string, string>): TObjectList<TGatemaSDScanData>;
|
||||
function GetByID (const AID: integer): TGatemaSDScanData;
|
||||
function GetMeta: TJSONObject;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
TSDGPolozkaOZService = class(TPolozkaOZService)
|
||||
function GetByID (const AID: integer): TPohybOZ;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
System.StrUtils,
|
||||
FireDAC.Stan.Option,
|
||||
FireDAC.Comp.Client,
|
||||
FireDAC.Stan.Param,
|
||||
MVCFramework.FireDAC.Utils,
|
||||
MVCFramework.DataSet.Utils,
|
||||
MVCFramework.Serializer.Commons;
|
||||
|
||||
|
||||
{ TGatemaSDDokladService }
|
||||
|
||||
function TGatemaSDDokladService.GetAll:TObjectList<TGatemaSDDoklad>;
|
||||
var lSQL: string;
|
||||
begin
|
||||
lSQL:= 'SELECT ' + GetTabCols('dbo', tblGSDDoklady) + ' FROM ' + tblGSDDoklady + ' ORDER BY ID';
|
||||
FDM.sqlQry1.Open(lSQL, []);
|
||||
result:= FDM.sqlQry1.AsObjectList<TGatemaSDDoklad>;
|
||||
FDM.sqlQry1.Close;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
function TGatemaSDDokladService.GetByParams(params: TDictionary<string, string>): TObjectList<TGatemaSDDoklad>;
|
||||
var lSQL, where, odDatum, doDatum, sklad, formatX, druhPohybuZbo, strTemp: string;
|
||||
lQry: TFDQuery;
|
||||
datOd, datDo: TDateTime;
|
||||
id, iDZ, cnt, rNo: integer;
|
||||
jenSeznam: Boolean;
|
||||
d: TGatemaSDDoklad;
|
||||
dList: TObjectList<TGatemaSDDoklad>;
|
||||
begin
|
||||
jenSeznam:= false;
|
||||
if (params.ContainsKey('seznam')) then
|
||||
jenSeznam:= true;
|
||||
|
||||
formatX:= '';
|
||||
if (params.ContainsKey('format')) then
|
||||
formatX:= params.Items['format'];
|
||||
if (formatX<>'') then
|
||||
begin
|
||||
end
|
||||
else
|
||||
begin
|
||||
if not(jenSeznam) then
|
||||
lSQL:= 'SELECT ' + GetTabCols('dbo', tblGSDDoklady, 'main', false) + IfThen(selSpecDoklSD<>'', ',' + selSpecDoklSD, '') + ' FROM ' + tblGSDDoklady + ' main'
|
||||
else
|
||||
lSQL:= 'SELECT main.ID, main.TypDokladu, main.PodtypDokladu, main.RadaDokladu, main.Sklad, main.RadaDokladuCil, main.SkladCil, main.IDDokZbo, main.IDDokZbo_New'
|
||||
+ ', main.IDOrg' + IfThen(selSpecDoklSD<>'', ',' + selSpecDoklSD, '') + ', main.DatPorizeni, main.DatGenerovani, main.DatumPripadu, main.PopisDodavky'
|
||||
+ ' FROM ' + tblGSDDoklady + ' main';
|
||||
end;
|
||||
|
||||
where:= '';
|
||||
|
||||
id:= 0;
|
||||
if (params.ContainsKey('id')) then
|
||||
if (params.Items['id']<>'') then
|
||||
if (params.Items['id']<>'0') then
|
||||
begin
|
||||
id:= params.Items['id'].ToInteger;
|
||||
where:= where + 'main.ID=' + id.ToString;
|
||||
end;
|
||||
|
||||
if (params.ContainsKey('typDokladu')) then
|
||||
if (params.Items['typDokladu']<>'') then
|
||||
where:= where + IfThen(where<>'', ' AND ', '') + 'main.TypDokladu=N' + params.Items['typDokladu'];
|
||||
|
||||
if (params.ContainsKey('druhPohybu')) then
|
||||
if (params.Items['druhPohybu']<>'') then
|
||||
where:= where + IfThen(where<>'', ' AND ', '') + 'main.DruhPohybuZbo=N' + params.Items['druhPohybu'];
|
||||
|
||||
if (params.ContainsKey('sklad')) then
|
||||
if (params.Items['sklad']<>'') then
|
||||
where:= where + IfThen(where<>'', ' AND ', '') + 'main.Sklad=N' + params.Items['sklad'].QuotedString;
|
||||
|
||||
|
||||
if (params.ContainsKey('odDatum')) then
|
||||
if (params.Items['odDatum']<>'') then
|
||||
odDatum:= params.Items['odDatum'];
|
||||
if (odDatum<>'') then
|
||||
begin
|
||||
if (Length(odDatum)=8) then
|
||||
odDatum:= odDatum + '000000';
|
||||
if (Length(odDatum)=10) then
|
||||
odDatum:= odDatum + '00';
|
||||
odDatum:= MidStr(odDatum, 7, 2) + '.' + MidStr(odDatum, 5, 2) + '.' + LeftStr(odDatum, 4) + ' ' + MidStr(odDatum, 9, 2) + ':' + MidStr(odDatum, 11, 2) + ':' + MidStr(odDatum, 13, 2);
|
||||
if not(TryStrToDateTime(odDatum, datOd)) then
|
||||
datOd:= IncDay(Now, -180)
|
||||
end
|
||||
else
|
||||
datOd:= IncDay(Now, -180);
|
||||
|
||||
if (params.ContainsKey('doDatum')) then
|
||||
if (params.Items['doDatum']<>'') then
|
||||
odDatum:= params.Items['doDatum'];
|
||||
if (doDatum<>'') then
|
||||
begin
|
||||
if (Length(doDatum)=8) then
|
||||
doDatum:= doDatum + '235959';
|
||||
if (Length(doDatum)=10) then
|
||||
doDatum:= doDatum + '59';
|
||||
doDatum:= MidStr(doDatum, 7, 2) + '.' + MidStr(doDatum, 5, 2) + '.' + LeftStr(doDatum, 4) + ' ' + MidStr(doDatum, 9, 2) + ':' + MidStr(doDatum, 11, 2) + ':' + MidStr(doDatum, 13, 2);
|
||||
if not(TryStrToDateTime(doDatum, datDo)) then
|
||||
datDo:= Now
|
||||
end
|
||||
else
|
||||
datDo:= Now;
|
||||
|
||||
|
||||
strTemp:= '';
|
||||
if (odDatum<>'') then
|
||||
strTemp:= 'CONVERT(datetime, N' + FormatDateTime('dd.mm.yyyy', datOd).QuotedString + ',104)'
|
||||
else
|
||||
strTemp:= 'DATEADD(day, -1, GETDATE())';
|
||||
|
||||
where:= where + IfThen(where<>'', ' AND ', '') + 'main.DatPorizeni>=' + strTemp;
|
||||
|
||||
if (doDatum<>'') then
|
||||
begin
|
||||
strTemp:= 'CONVERT(datetime, N' + FormatDateTime('dd.mm.yyyy', datDo).QuotedString + ',104)';
|
||||
where:= where + IfThen(where<>'', ' AND ', '') + 'main.DatPorizeni<=' + strTemp;
|
||||
end;
|
||||
|
||||
|
||||
if (where<>'') then
|
||||
lSQL:= lSQL + ' WHERE ' + IfThen(id>0, 'main.ID=' + id.ToString, where);
|
||||
lSQL:= lSQL + ' ORDER BY main.ID';
|
||||
|
||||
lSQL:= lSQL.Replace('Gatema_SDDoklady.', 'main.');
|
||||
|
||||
|
||||
|
||||
lQry:= TFDQuery.Create(nil);
|
||||
try
|
||||
lQry.Connection:= FDM.sqlConn;
|
||||
lQry.FetchOptions.AutoClose:= false;
|
||||
lQry.FetchOptions.Mode:= fmAll;
|
||||
lQry.Open(lSQL);
|
||||
|
||||
cnt:= lQry.RecordCount;
|
||||
if (cnt>0) then
|
||||
begin
|
||||
d:= TGatemaSDDoklad.Create;
|
||||
dList:= TObjectList<TGatemaSDDoklad>.Create;
|
||||
try
|
||||
rNo:= 1;
|
||||
lQry.First;
|
||||
while (rNo<=cnt) do // nouzove reseni, lQry se po nacteni GetbyID sama uzavre !!
|
||||
begin
|
||||
lQry.RecNo:= rNo;
|
||||
iDZ:= lQry.FieldByName('ID').AsInteger;
|
||||
d:= self.GetByID(iDZ, jenSeznam);
|
||||
dList.Add(d);
|
||||
if not(lQry.Active) then
|
||||
lQry.Open;
|
||||
Inc(rNo);
|
||||
end;
|
||||
result:= dList;
|
||||
except on E:Exception do
|
||||
raise EServiceException.Create('Chyba načítání dokladu: ' + E.Message);
|
||||
end;
|
||||
end
|
||||
else
|
||||
raise EServiceException.Create('Vybraným podmínkám neodpovídá žádný naskenovaný doklad');
|
||||
finally
|
||||
FreeAndNil(lQry);
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
|
||||
|
||||
function TGatemaSDDokladService.GetByID (const AID: integer; const bezPolozek: boolean=false): TGatemaSDDoklad;
|
||||
var lSQL: string;
|
||||
p: TDictionary<string, string>;
|
||||
ps: TGatemaSDScanDataService;
|
||||
lQry: TFDQuery;
|
||||
sqlConnX: TFDConnection;
|
||||
begin
|
||||
|
||||
ps:= TGatemaSDScanDataService.Create(self.FDM);
|
||||
p:= TDictionary<string, string>.Create;
|
||||
p.Add('iddoklad', AID.ToString);
|
||||
|
||||
sqlConnX:= TFDConnection.Create(nil);
|
||||
sqlConnX.ConnectionDefName:= sqlPoolName;
|
||||
|
||||
lSQL:= 'SELECT ' + GetTabCols('dbo', tblGSDDoklady, 'main', false) + IfThen(selSpecDoklSD<>'', ',' + selSpecDoklSD, '') + ' FROM ' + tblGSDDoklady + ' main WHERE main.ID=:ID';
|
||||
lQry:= TFDQuery.Create(nil);
|
||||
try
|
||||
lQry.Connection:= sqlConnX;
|
||||
lQry.Open (lSQL, [AID]);
|
||||
lQry.First;
|
||||
if not(lQry.EOF) then
|
||||
begin
|
||||
result:= lQry.AsObject<TGatemaSDDoklad>;
|
||||
if not(bezPolozek) then
|
||||
result.ScanData:= ps.GetByParams(p);
|
||||
end
|
||||
else
|
||||
raise EServiceException.Create('Naskenovaný doklad s ID ' + AID.ToString + ' nebyl nalezen.');
|
||||
finally
|
||||
p.Free;
|
||||
ps.Free;
|
||||
FreeAndNil(lQry);
|
||||
end;
|
||||
|
||||
sqlConnX.Close;
|
||||
sqlConnX.Free;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
function TGatemaSDDokladService.GetMeta: TJSONObject;
|
||||
var lSQL: string;
|
||||
lQry: TFDQuery;
|
||||
begin
|
||||
lSQL:= 'SELECT ' + GetTabCols('dbo', tblGSDDoklady, 'main', false) + IfThen(selSpecDoklSD<>'', ',' + selSpecDoklSD, '') + ' FROM ' + tblGSDDoklady + ' main WHERE 1=0';
|
||||
lQry:= TFDQuery.Create(nil);
|
||||
// lQry.FetchOptions.AutoClose:= false;
|
||||
// lQry.FetchOptions.Mode:= fmAll;
|
||||
try
|
||||
lQry.Connection:= FDM.sqlConn;
|
||||
lQry.Open(lSQL);
|
||||
Result:= lQry.MetadataAsJSONObject();
|
||||
finally
|
||||
lQry.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{ TGatemaSDScanDataService }
|
||||
|
||||
function TGatemaSDScanDataService.GetByID (const AID: integer): TGatemaSDScanData;
|
||||
var lSQL: string;
|
||||
lQry: TFDQuery;
|
||||
begin
|
||||
lSQL:= 'SELECT ' + GetTabCols('dbo', tblGSDScanData) + ' FROM ' + tblGSDScanData + ' WHERE ID=:ID';
|
||||
|
||||
lQry:= TFDQuery.Create(nil);
|
||||
try
|
||||
lQry.Connection:= FDM.sqlConn;
|
||||
lQry.Open(lSQL, [AID]);
|
||||
lQry.First;
|
||||
if not(lQry.EOF) then
|
||||
result:= lQry.AsObject<TGatemaSDScanData>
|
||||
else
|
||||
raise EServiceException.Create('Naskenovaná položka s ID ' + AID.ToString + ' nebyla nalezena.');
|
||||
finally
|
||||
lQry.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
function TGatemaSDScanDataService.GetMeta: TJSONObject;
|
||||
var lSQL: string;
|
||||
lQry: TFDQuery;
|
||||
begin
|
||||
lSQL:= 'SELECT ' + GetTabCols('dbo', tblGSDScanData) + ' FROM ' + tblGSDScanData + ' WHERE 1=0';
|
||||
lQry:= TFDQuery.Create(nil);
|
||||
lQry.Connection:= FDM.sqlConn;
|
||||
lQry.FetchOptions.AutoClose:= false;
|
||||
lQry.FetchOptions.Mode:= fmAll;
|
||||
try
|
||||
lQry.Open(lSQL);
|
||||
Result:= lQry.MetadataAsJSONObject();
|
||||
finally
|
||||
lQry.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
function TGatemaSDScanDataService.GetByParams(params: TDictionary<string, string>): TObjectList<TGatemaSDScanData>;
|
||||
var lSQL, where: string;
|
||||
id,idPZ, cnt, rNo: integer;
|
||||
lQry: TFDQuery;
|
||||
pList: TObjectList<TGatemaSDScanData>;
|
||||
p: TGatemaSDScanData;
|
||||
begin
|
||||
p:= TGatemaSDScanData.Create;
|
||||
pList:= TObjectList<TGatemaSDScanData>.Create;
|
||||
|
||||
lSQL:= 'SELECT ' + GetTabCols('dbo', tblGSDScanData, '', false) + ' FROM ' + tblGSDScanData;
|
||||
|
||||
where:= '';
|
||||
|
||||
id:= 0;
|
||||
if (params.ContainsKey('id')) then
|
||||
if (params.Items['id']<>'') then
|
||||
if (params.Items['id']<>'0') then
|
||||
begin
|
||||
id:= params.Items['id'].ToInteger;
|
||||
where:= where + 'ID=' + id.ToString;
|
||||
end;
|
||||
|
||||
if (params.ContainsKey('iddoklad')) then
|
||||
if (params.Items['iddoklad']<>'') then
|
||||
where:= where + IfThen(where<>'', ' AND ', '') + 'IDDokladSD=' + params.Items['iddoklad'];
|
||||
|
||||
if (where<>'') then
|
||||
lSQL:= lSQL + ' WHERE ' + IfThen(id>0, 'ID=' + id.ToString, where);
|
||||
lSQL:= lSQL + ' ORDER BY IDDokladSD, ID';
|
||||
|
||||
// lSQL:= lSQL.Replace('TabPohybyZbozi.', 'main.');
|
||||
|
||||
|
||||
lQry:= TFDQuery.Create(nil);
|
||||
lQry.Connection:= FDM.sqlConn;
|
||||
lQry.FetchOptions.AutoClose:= false;
|
||||
lQry.FetchOptions.Mode:= fmAll;
|
||||
lQry.Open(lSQL);
|
||||
try
|
||||
cnt:= lQry.RecordCount;
|
||||
pList:= TObjectList<TGatemaSDScanData>.Create;
|
||||
try
|
||||
lQry.First;
|
||||
rNo:= 1;
|
||||
while (rNo<=cnt) do
|
||||
begin
|
||||
lQry.RecNo:= rNo;
|
||||
idPZ:= lQry.FieldByName('ID').AsInteger;
|
||||
p:= self.GetByID (idPZ);
|
||||
pList.Add(p);
|
||||
if not(lQry.Active) then
|
||||
lQry.Open;
|
||||
Inc(rNo);
|
||||
end;
|
||||
result:= pList;
|
||||
except on E:Exception do
|
||||
raise EServiceException.Create('Chyba načítání naskenované položky/položek dokladu: ' + E.Message);
|
||||
end;
|
||||
finally
|
||||
FreeAndNil(lQry);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{ TSDGPolozkaOZService }
|
||||
|
||||
function TSDGPolozkaOZService.GetByID (const AID: Integer): TPohybOZ;
|
||||
begin
|
||||
result:= nil;
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
2
_custom/GatemaSD/uWebModCustomSDG.inc
Normal file
2
_custom/GatemaSD/uWebModCustomSDG.inc
Normal file
@ -0,0 +1,2 @@
|
||||
FEngine.AddController (TGatemaSDDokladController);
|
||||
FEngine.AddController (TGatemaSDScanDataController);
|
||||
Reference in New Issue
Block a user