Входные параметры
Параметр | Тип | Описание |
---|---|---|
ADATEBEGIN |
DATE |
|
ADATEEND |
DATE |
|
AOPERATION |
INTEGER |
|
SHOWRETURNED |
INTEGER |
|
Выходные параметры
Параметр | Тип | Описание |
---|---|---|
GROSS |
INTEGER |
|
WEIGHT |
INTEGER |
|
SILAGES |
VARCHAR(30) |
|
SAMPLERQUALITYNUMBER |
VARCHAR(30) |
|
LABQUALITYNUMBER |
INTEGER |
|
LABQUALITYID |
INTEGER |
|
PROVIDERNAME |
VARCHAR(60) |
|
CROPNAME |
VARCHAR(300) |
|
CROPID |
INTEGER |
|
CLASSID |
INTEGER |
|
PROVIDERID |
INTEGER |
|
TRANSPORTNUMBER |
VARCHAR(60) |
|
INVENTORYID |
INTEGER |
|
RDATE |
DATE |
|
SAMPLERQUALITYID |
INTEGER |
|
CROPSORTID |
INTEGER |
|
INVOICEID |
INTEGER |
|
OPERATIONID |
INTEGER |
|
TRANSPORTTYPEID |
INTEGER |
|
UNDERWORKQUALITYID |
INTEGER |
|
STORINGID |
INTEGER |
|
UWORDERID |
INTEGER |
|
GROUPTYPE |
INTEGER |
|
SILAGEID |
INTEGER |
|
SENDERQUALITYID |
INTEGER |
|
OWNERNAME |
VARCHAR(30) |
|
CHECKPOINTOUTTIME |
TIMESTAMP |
|
RELATIONID |
INTEGER |
|
STORAGEID |
INTEGER |
|
WEIGHTNUMBER |
INTEGER |
|
HUMIDITYSTATE |
INTEGER |
|
DIRTSTATE |
INTEGER |
|
STATIONNAME |
VARCHAR(30) |
|
SENDERID |
INTEGER |
|
WEIGHTSESSION |
INTEGER |
|
INVOICENUMBER |
VARCHAR(31) |
|
REGISTERID |
INTEGER |
|
INVENTORYSTATE |
INTEGER |
|
STORAGENAME |
VARCHAR(31) |
|
BARCODE |
VARCHAR(31) |
|
SAMPLEROUTDATE |
DATE |
|
MANUFACTURERID |
INTEGER |
|
SAMPLERINTIME |
TIMESTAMP |
|
SENDERNAME |
VARCHAR(30) |
|
SILAGECHECK |
INTEGER |
|
DEVIATONSTATE |
SMALLINT |
|
INVOICEDATE |
DATE |
|
OWNERID |
INTEGER |
|
Описание
(Нет описания для процедуры LABORATORY_JOURNAL)
Определение
CREATE PROCEDURE LABORATORY_JOURNAL(
ADATEBEGIN DATE,
ADATEEND DATE,
AOPERATION INTEGER,
SHOWRETURNED INTEGER)
RETURNS (
GROSS INTEGER,
WEIGHT INTEGER,
SILAGES VARCHAR(30),
SAMPLERQUALITYNUMBER VARCHAR(30),
LABQUALITYNUMBER INTEGER,
LABQUALITYID INTEGER,
PROVIDERNAME VARCHAR(60),
CROPNAME VARCHAR(300),
CROPID INTEGER,
CLASSID INTEGER,
PROVIDERID INTEGER,
TRANSPORTNUMBER VARCHAR(60),
INVENTORYID INTEGER,
RDATE DATE,
SAMPLERQUALITYID INTEGER,
CROPSORTID INTEGER,
INVOICEID INTEGER,
OPERATIONID INTEGER,
TRANSPORTTYPEID INTEGER,
UNDERWORKQUALITYID INTEGER,
STORINGID INTEGER,
UWORDERID INTEGER,
GROUPTYPE INTEGER,
SILAGEID INTEGER,
SENDERQUALITYID INTEGER,
OWNERNAME VARCHAR(30),
CHECKPOINTOUTTIME TIMESTAMP,
RELATIONID INTEGER,
STORAGEID INTEGER,
WEIGHTNUMBER INTEGER,
HUMIDITYSTATE INTEGER,
DIRTSTATE INTEGER,
STATIONNAME VARCHAR(30),
SENDERID INTEGER,
WEIGHTSESSION INTEGER,
INVOICENUMBER VARCHAR(31),
REGISTERID INTEGER,
INVENTORYSTATE INTEGER,
STORAGENAME VARCHAR(31),
BARCODE VARCHAR(31),
SAMPLEROUTDATE DATE,
MANUFACTURERID INTEGER,
SAMPLERINTIME TIMESTAMP,
SENDERNAME VARCHAR(30),
SILAGECHECK INTEGER,
DEVIATONSTATE SMALLINT,
INVOICEDATE DATE,
OWNERID INTEGER)
AS
declare variable ASILAGEONE varchar(30);
declare variable ANUMBERANALYSIS integer;
declare variable MILLNAME varchar(20);
declare variable RECIPEN varchar(20);
declare variable ROUTEID integer;
declare variable ALABANALYSISNUMBER varchar(255);
declare variable ACROPNAME varchar(300);
declare variable ASUPLIERNAME varchar(30);
declare variable ACROPID integer;
declare variable APROVIDERID integer;
declare variable ALABANALYSISID integer;
declare variable ASAMPLERQUALITYID integer;
declare variable AWEIGHT integer;
declare variable AINVOICEID integer;
declare variable FOPERATIONID_IT integer;
declare variable ASTORINGID integer;
declare variable AUWORDERID integer;
declare variable G_PROVIDERID integer;
declare variable G_CLASSID integer;
declare variable G_SORTID integer;
declare variable G_DATE date;
declare variable IS_PROVIDER_OR_OWNER integer;
declare variable A_HUMIDITYSTATE integer;
declare variable A_DIRTSTATE integer;
declare variable ADATE date;
declare variable NOTSILAGECHECK integer;
begin
select bin_and(ENVIRONMENTOPTIONS.CHANGEDATE, 16)
from ENVIRONMENTOPTIONS
into :NOTSILAGECHECK;
IS_PROVIDER_OR_OWNER = 1; -- (0 - PROVIDER, 1 - OWNER)
OPERATIONID = :AOPERATION;
RDATE = :ADATEBEGIN;
GROUPTYPE = 0;
G_CLASSID = 0;
G_DATE = '1.1.1';
G_PROVIDERID = 0;
G_SORTID = 0;
HUMIDITYSTATE = 0;
DIRTSTATE = 0;
if (:AOPERATION not in (7,29)) then begin -- in (1,5,10,12,22,30,31,54)
for
select
ITMAIN.REGDATE,
case
when ((:IS_PROVIDER_OR_OWNER = 0) and (:AOPERATION in (1,5))) then
ITMAIN.PROVIDERID
else ITMAIN.OWNERID
end,
ITMAIN.GROSS, ITMAIN.NET, ITMAIN.LABQUALITYID,
coalesce(MANUFACTURER.CLIENTNAME,PROVIDER.CLIENTNAME),
OWNER.CLIENTNAME, SENDER.CLIENTNAME,
SAMPLERQUALITY.SORTID, SAMPLERQUALITY.CROPID, SAMPLERQUALITY.CLASSID,
case
when (ITTRANSPORT.TRANSPORTTYPEID = 3) then
upper(QUALITY_CROPFULLNAME.CROPFULLNAME)
-- else QUALITY_CROPFULLNAME.CROPFULLNAME
else
case
when (SAMPLERQUALITY.CROPID = 9) then
QUALITY_CROPFULLNAME_FORAGE.CROPFULLNAME
else QUALITY_CROPFULLNAME.CROPFULLNAME
end
end,
SILAGE.NAME,
case
when (ITMAIN.OPERATIONID = 70) then
cast((select ITT.TRANSPORTNUMBER
from ITTRANSPORT ITT
where (ITT.INVENTORYID = ITMAIN.PARENTID))
as varchar(25))
else
case
-- when ((ITMAIN.STATE = -100) and (ITTRANSPORT.TRANSPORTTYPEID = 3)) then
when (ITTRANSPORT.TRANSPORTTYPEID = 3) then
cast((select SHIPS.SHIPNAME
from SHIPS
where (SHIPS.SHIPID = (select RELATIONID
from IT
where (INVENTORYID = ITMAIN.RELATIONID)
)
)
) as varchar(25))
else ITTRANSPORT.TRANSPORTNUMBER
end
end,
LABQUALITYDATA.QUALITYNUMBER, SAMPLERQUALITYDATA.QUALITYNUMBER, ITMAIN.SAMPLERQUALITYID,
ITMAIN.INVOICEID, ITMAIN.INVENTORYID, ITTRANSPORT.TRANSPORTTYPEID, UWOUTACTS.BEFOREQUALITYID,
ITMAIN.OPERATIONID, ITMAIN.ROUTEID, ITMAIN.STORINGID, ITMAIN.UWORDERID, ITMAIN.SILAGEID,
ITTRANSPORT.SENDERQUALITYID, ITTRANSPORT.CHECKPOINTOUTTIME, ITMAIN.RELATIONID,
ITMAIN.REGISTERID, ITMAIN.STORAGEID, ITMAIN.WEIGHTNUMBER, ITMAIN.OWNERID, ITMAIN.STATE,
SAMPLERQUALITYDATA.STATEHUMIDITY, SAMPLERQUALITYDATA.STATEDIRT,
case
when (ITTRANSPORT.TRANSPORTTYPEID < 3) then
STATIONS.STATIONNAME
else
cast((select STATIONS.STATIONNAME
from STATIONS
where(STATIONS.STATIONID = (select INVOICES.STATIONID
from INVOICES
where (INVOICES.INVOICEID = (select IT.INVOICEID
from IT
where (IT.INVENTORYID = :RELATIONID)
)
)
)
)
) as varchar(30))
end STATIONNAME,
INVOICES.SENDERID, INVOICES.MANUFACTURERID, ITTRANSPORT.WEIGHTSESSION,
INVOICES.INVOICENUMBER, INVOICES.INVOICEDATE,
STORAGE.STORAGESHORTNAME, ITTRANSPORT.BARCODE, ITTRANSPORT.SAMPLEROUTDATE,
cast(ITTRANSPORT.SAMPLERINDATE + ITTRANSPORT.SAMPLERINTIME as timestamp) SAMPLERINTIME,
case
when (bin_and(OWNER.DEVIATIONCONTROL, 65536) = 65536) then
(select DEVIATION.DEVIATIONSTATE
from DEVIATION
where (DEVIATION.INVOICEID = :INVOICEID) and (DEVIATION.DEVIATIONTYPEID = 2)
)
else -1
end
from IT ITMAIN
left join QUALITY SAMPLERQUALITY on (SAMPLERQUALITY.QUALITYID = ITMAIN.SAMPLERQUALITYID)
left join QUALITY_SELECT(ITMAIN.SAMPLERQUALITYID) SAMPLERQUALITYDATA on (0=0)
left join QUALITY LABQUALITY on (ITMAIN.LABQUALITYID = LABQUALITY.QUALITYID)
left join QUALITY_SELECT(ITMAIN.LABQUALITYID) LABQUALITYDATA on (0=0)
left join INVOICES on (INVOICES.INVOICEID = ITMAIN.INVOICEID)
left join CLIENTS PROVIDER on (PROVIDER.CLIENTID = ITMAIN.PROVIDERID)
left join CLIENTS OWNER on (OWNER.CLIENTID = ITMAIN.OWNERID)
left join CLIENTS SENDER on (SENDER.CLIENTID = INVOICES.SENDERID)
left join CLIENTS MANUFACTURER on (MANUFACTURER.CLIENTID = INVOICES.MANUFACTURERID)
left join QUALITY_CROPFULLNAME(SAMPLERQUALITY.CROPID, SAMPLERQUALITY.CLASSID, SAMPLERQUALITY.SORTID, 0) on (0=0)
left join QUALITY_CROPFULLNAME_FORAGE(SAMPLERQUALITY.CROPID, SAMPLERQUALITY.CLASSID, SAMPLERQUALITY.SORTID, SAMPLERQUALITYDATA.FORAGECROPID, SAMPLERQUALITYDATA.FORAGECLASSID, 0) on (0=0)
left join SILAGE on (SILAGE.SILAGEID = ITMAIN.SILAGEID)
left join USERS on (USERS.USERID = LABQUALITY.USERID)
left join UWOUTACTS on (UWOUTACTS.INVOICEID = ITMAIN.INVOICEID)
left join ITTRANSPORT on (ITTRANSPORT.INVENTORYID = ITMAIN.INVENTORYID)
left join STATIONS on (STATIONS.STATIONID = INVOICES.STATIONID)
left join STORAGE on (STORAGE.STORAGEID = ITMAIN.STORAGEID)
-- where (coalesce(ITMAIN.REGDATE,ITTRANSPORT.SAMPLERINDATE) between :ADATEBEGIN and :ADATEEND)
where ((ITMAIN.REGDATE between :ADATEBEGIN and :ADATEEND)
or ((ITMAIN.REGDATE between (:ADATEEND - 7) and :ADATEEND)
and (((:NOTSILAGECHECK = 0) and (:AOPERATION = 1) and (ITMAIN.SILAGEID is null))
or ((select sum(IT.NET)
from IT
where (IT.INVOICEID = ITMAIN.INVOICEID)
) is null
)
)
and ((ITMAIN.STATE >= 0) or (ITMAIN.STATE = -104))
)
)
and (ITMAIN.OPERATIONID = :AOPERATION)
and ((ITMAIN.STATE > -1)
or ((ITMAIN.STATE in (-3,-2)) and (:SHOWRETURNED = -3))
or ((ITMAIN.STATE = -100) and (ITMAIN.OPERATIONID not in (1)))
or (ITMAIN.STATE = -104)
)
and (((ITMAIN.PARENTID <= 0) and (ITMAIN.OPERATIONID <> 70))
or ((ITMAIN.PARENTID > 0) and (ITMAIN.OPERATIONID = 70))
)
order by 1, 2, SAMPLERQUALITY.CLASSID, SAMPLERQUALITY.SORTID, SAMPLERQUALITYDATA.STATEHUMIDITY,
SAMPLERQUALITYDATA.STATEDIRT, ITMAIN.INVOICEID, ITTRANSPORT.TRANSPORTTYPEID,
SAMPLERQUALITYDATA.QUALITYNUMBER
into :RDATE, :PROVIDERID, :GROSS, :WEIGHT, :LABQUALITYID, :PROVIDERNAME, :OWNERNAME,
:SENDERNAME, :CROPSORTID, :CROPID, :CLASSID, :CROPNAME, :SILAGES, :TRANSPORTNUMBER,
:LABQUALITYNUMBER, :SAMPLERQUALITYNUMBER, :SAMPLERQUALITYID, :INVOICEID,
:INVENTORYID, :TRANSPORTTYPEID, :UNDERWORKQUALITYID, :FOPERATIONID_IT,
:ROUTEID, :STORINGID, :UWORDERID, :SILAGEID, :SENDERQUALITYID, :CHECKPOINTOUTTIME,
:RELATIONID, :REGISTERID, :STORAGEID, :WEIGHTNUMBER, :OWNERID, :INVENTORYSTATE,
:A_HUMIDITYSTATE, :A_DIRTSTATE, :STATIONNAME, :SENDERID, :MANUFACTURERID,
:WEIGHTSESSION, :INVOICENUMBER, :INVOICEDATE, :STORAGENAME, :BARCODE,
:SAMPLEROUTDATE, :SAMPLERINTIME, :DEVIATONSTATE
do begin
-- if (:AOPERATION <> 31) then SAMPLERQUALITYNUMBER = '№ транс ' || :TRANSPORTNUMBER;
if (:AOPERATION = 12) then begin
select SILAGEPACKS.NAME
from SILAGEPACKS
where (SILAGEPACKS.SILAGEPACKID = :ROUTEID)
into :PROVIDERNAME;
PROVIDERNAME = 'из ' || :PROVIDERNAME;
end
if (:AOPERATION = 30) then begin
select SILAGEPACKS.NAME
from SILAGEPACKS
where (SILAGEPACKS.SILAGEPACKID = :ROUTEID)
into :PROVIDERNAME;
PROVIDERNAME = 'из ' || :PROVIDERNAME;
SILAGES = '';
select STORAGE.STORAGENAME
from CLIENTS
left join STORAGE on (STORAGE.STORAGEID = CLIENTS.STORAGEID)
where (CLIENTS.CLIENTID = :PROVIDERID)
into :SILAGES;
SILAGES = 'на ' || :SILAGES;
end
if (:AOPERATION in (31,36)) then begin
select SILAGEPACKS.NAME
from SILAGEPACKS
where (SILAGEPACKS.SILAGEPACKID = :ROUTEID)
into :PROVIDERNAME;
PROVIDERNAME = 'из ' || :PROVIDERNAME;
-- suplierNAME = 'из cушилки';
end
-- а тут подвох
if ((:AOPERATION = 5) and (:SILAGES is null) and (:ROUTEID is not null)) then begin
SILAGES = '';
for
select SILAGE.NAME
from ROUTESILAGECHEMA
left join SILAGE on (SILAGE.SILAGEID = ROUTESILAGECHEMA.SILAGEID)
where (ROUTESILAGECHEMA.ROUTECHEMAID = :ROUTEID)
into :ASILAGEONE
do begin
if (SILAGES = '') then
SILAGES = :ASILAGEONE;
else SILAGES = :SILAGES || ',' || :ASILAGEONE;
end
end
if (:OPERATIONID in (31,12,54)) then
PROVIDERID = :SILAGEID;
if ((:G_DATE <> :RDATE) or (:G_PROVIDERID <> :PROVIDERID)
or (coalesce(:G_CLASSID, -1) <> coalesce(:CLASSID, -1))
or (coalesce(:G_SORTID, -1) <> coalesce(:CROPSORTID, -1))
or (coalesce(:DIRTSTATE, -1) <> coalesce(:A_DIRTSTATE, -1))
or (coalesce(:HUMIDITYSTATE, -1) <> coalesce(:A_HUMIDITYSTATE, -1))) then
GROUPTYPE = 1 - :GROUPTYPE;
G_CLASSID = :CLASSID;
G_DATE = :RDATE;
G_PROVIDERID = :PROVIDERID;
G_SORTID = :CROPSORTID;
DIRTSTATE = :A_DIRTSTATE;
HUMIDITYSTATE = :A_HUMIDITYSTATE;
suspend;
end
end
--------- Внутрение перемещения
if (:AOPERATION = 29) then begin
for
select
IT.REGDATE,
case
when ((:IS_PROVIDER_OR_OWNER = 0) and (:AOPERATION in (1,5))) then
IT.PROVIDERID
else IT.OWNERID
end,
IT.NET, IT.LABQUALITYID, PROVIDER.CLIENTNAME, OWNER.CLIENTNAME,
SAMPLERQUALITY.SORTID, SAMPLERQUALITY.CROPID, SAMPLERQUALITY.CLASSID,
QUALITY_CROPFULLNAME.CROPFULLNAME, SILAGE.NAME, ITTRANSPORT.TRANSPORTNUMBER,
cast(LABQUALITYDATA.QUALITYVALUE as integer) QUALITYNUMBER,
cast(SAMPLERQUALITYDATA.QUALITYVALUE as integer) QUALITYNUMBER,
IT.SAMPLERQUALITYID, IT.INVOICEID, IT.INVENTORYID, ITTRANSPORT.TRANSPORTTYPEID,
UWOUTACTS.BEFOREQUALITYID, IT.OPERATIONID, IT.ROUTEID, IT.STORINGID, IT.UWORDERID,
IT.SILAGEID, ITTRANSPORT.SENDERQUALITYID, ITTRANSPORT.CHECKPOINTOUTTIME,
IT.RELATIONID, IT.REGISTERID, IT.STORAGEID, STORAGE.STORAGESHORTNAME
from IT
left join QUALITY SAMPLERQUALITY on (SAMPLERQUALITY.QUALITYID = IT.SAMPLERQUALITYID)
left join QUALITYDATA SAMPLERQUALITYDATA on ((SAMPLERQUALITYDATA.QUALITYID = IT.SAMPLERQUALITYID) and (SAMPLERQUALITYDATA.QUALITYTYPEID = 1))
left join QUALITY LABQUALITY on (LABQUALITY.QUALITYID = IT.LABQUALITYID)
left join QUALITYDATA LABQUALITYDATA on ((LABQUALITYDATA.QUALITYID = IT.LABQUALITYID) and (LABQUALITYDATA.QUALITYTYPEID = 1))
left join CLIENTS PROVIDER on (PROVIDER.CLIENTID = IT.PROVIDERID)
left join CLIENTS OWNER on (OWNER.CLIENTID = IT.OWNERID)
left join QUALITY_CROPFULLNAME(SAMPLERQUALITY.CROPID, SAMPLERQUALITY.CLASSID, SAMPLERQUALITY.SORTID, 0) on (0=0)
left join SILAGE on (SILAGE.SILAGEID = IT.SILAGEID)
left join USERS on (USERS.USERID = LABQUALITY.USERID)
left join UWOUTACTS on (UWOUTACTS.INVOICEID = IT.INVOICEID)
left join ITTRANSPORT on (ITTRANSPORT.INVENTORYID = IT.INVENTORYID)
left join STORAGE on (STORAGE.STORAGEID = IT.STORAGEID)
where (IT.REGDATE between :ADATEBEGIN and :ADATEEND)
and (IT.OPERATIONID in (29,32))
and ((IT.STATE > -1) or (IT.STATE = -100))
and (IT.PARENTID <= 0)
order by 1, 2, SAMPLERQUALITY.CLASSID, SAMPLERQUALITY.SORTID, IT.INVOICEID,
ITTRANSPORT.TRANSPORTTYPEID, SAMPLERQUALITYDATA.QUALITYVALUE
into :RDATE, :PROVIDERID, :WEIGHT, :LABQUALITYID,
:PROVIDERNAME, :OWNERNAME, :CROPSORTID, :CROPID, :CLASSID, :CROPNAME,
:SILAGES, :TRANSPORTNUMBER, :LABQUALITYNUMBER, :SAMPLERQUALITYNUMBER,
:SAMPLERQUALITYID, :INVOICEID, :INVENTORYID, :TRANSPORTTYPEID,
:UNDERWORKQUALITYID, :FOPERATIONID_IT, :ROUTEID, :STORINGID, :UWORDERID,
:SILAGEID, :SENDERQUALITYID, :CHECKPOINTOUTTIME, :RELATIONID, :REGISTERID,
:STORAGEID, :STORAGENAME
do begin
if (:FOPERATIONID_IT = 32) then
PROVIDERNAME = 'из под сепаратора';
else begin
select SILAGEPACKS.NAME
from SILAGEPACKS
where (SILAGEPACKS.SILAGEPACKID = :ROUTEID)
into :PROVIDERNAME;
PROVIDERNAME = 'из ' || :PROVIDERNAME;
end
PROVIDERID = :SILAGEID;
if ((:G_DATE <> :RDATE) or (:G_PROVIDERID <> :PROVIDERID)
or (coalesce(:G_CLASSID, -1) <> coalesce(:CLASSID, -1))
or (coalesce(:G_SORTID, -1) <> coalesce(:CROPSORTID, -1))) then
GROUPTYPE = 1 - :GROUPTYPE;
G_CLASSID = :CLASSID;
G_DATE = :RDATE;
G_PROVIDERID = :PROVIDERID;
G_SORTID = :CROPSORTID;
suspend;
end
end
/* shipmentmill - отпуск на мельзавод*/
if (:AOPERATION = 7) then begin
INVOICEID = -1;
for
select
IT.REGDATE, IT.INVOICEID, IT.ROUTEID, RECIPES.RECIPEN, STORAGE.STORAGENAME,
LQUALITYDATA.QUALITYVALUE QUALITYNUMBER, CROP.CROPNAME,
CLIENTS.CLIENTNAME, SILAGE.NAME, SQUALITYDATA.QUALITYVALUE QUALITYNUMBER,
CROP.CROPID, CLIENTS.CLIENTID,
UWOUTACTS.AFTERQUALITYID, UWOUTACTS.BEFOREQUALITYID, UWOUTACTS.WEIGHT,
IT.STORINGID, IT.UWORDERID, IT.RELATIONID, IT.REGISTERID, IT.STORAGEID
from IT
left join UWOUTACTS on (UWOUTACTS.INVOICEID = IT.INVOICEID)
left join SILAGE on (SILAGE.SILAGEID = IT.SILAGEID)
left join QUALITY SQUALITY on (SQUALITY.QUALITYID = UWOUTACTS.BEFOREQUALITYID)
left join QUALITYDATA SQUALITYDATA on ((SQUALITYDATA.QUALITYID = UWOUTACTS.BEFOREQUALITYID) and (SQUALITYDATA.QUALITYTYPEID = 1))
left join CROP on (CROP.CROPID = SQUALITY.CROPID)
left join QUALITY LQUALITY on (LQUALITY.QUALITYID = UWOUTACTS.AFTERQUALITYID)
left join QUALITYDATA LQUALITYDATA on ((LQUALITYDATA.QUALITYID = UWOUTACTS.AFTERQUALITYID) and (LQUALITYDATA.QUALITYTYPEID = 1))
left join CLIENTS on (CLIENTS.CLIENTID = IT.PROVIDERID)
left join RECIPES on (RECIPES.RECIPEID = IT.RELATIONID)
left join STORAGE on (STORAGE.STORAGEID = RECIPES.STORAGEID)
where (IT.REGDATE between :ADATEBEGIN and :ADATEEND)
and (IT.OPERATIONID = :AOPERATION)
and (IT.STATE > -1) and (IT.PARENTID <= 0)
order by IT.REGDATE, IT.INVOICEID
into :ADATE, :AINVOICEID, :ROUTEID, :RECIPEN, :MILLNAME, :ANUMBERANALYSIS,
:ACROPNAME, :ASUPLIERNAME, :ASILAGEONE, :ALABANALYSISNUMBER,
:ACROPID, :APROVIDERID, :ALABANALYSISID, :ASAMPLERQUALITYID, :AWEIGHT,
:ASTORINGID, :AUWORDERID, :RELATIONID, :REGISTERID, :STORAGEID
do begin
GROUPTYPE = 1 - :GROUPTYPE;
if (:AINVOICEID <> :INVOICEID) then begin
if (:INVOICEID <> -1) then
suspend;
RDATE = :ADATE;
INVOICEID = :AINVOICEID;
LABQUALITYNUMBER = :ANUMBERANALYSIS;
CROPNAME = :ACROPNAME;
PROVIDERNAME = :PROVIDERNAME;
SAMPLERQUALITYNUMBER = :ALABANALYSISNUMBER;
CROPID = :ACROPID;
PROVIDERID = :APROVIDERID;
LABQUALITYID = :ALABANALYSISID;
STORINGID = :ASTORINGID;
UWORDERID = :AUWORDERID;
SAMPLERQUALITYID = :ASAMPLERQUALITYID;
WEIGHT = :AWEIGHT;
SILAGES = '';
end
PROVIDERNAME = '№' || :RECIPEN || ' на ' || :MILLNAME;
if (ROUTEID is not null) then begin
for
select SILAGEPACKS.NAME
from SILAGEPACKS
where (SILAGEPACKS.SILAGEPACKID = :ROUTEID)
into :ASILAGEONE
do
if (SILAGES = '') then
SILAGES = :ASILAGEONE;
else SILAGES = :SILAGES || ',' || :ASILAGEONE;
end
end
if (:INVOICEID <> -1) then
suspend;
end
end