feat(psi): psi querys added and av grab right now
This commit is contained in:
40
server/services/sqlServer/querys/psiReport/articleData.ts
Normal file
40
server/services/sqlServer/querys/psiReport/articleData.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
export const articleInfo = `
|
||||
use [test1_AlplaPROD2.0_Read]
|
||||
|
||||
select a.Id,
|
||||
a.HumanReadableId as av,
|
||||
a.Alias as alias,
|
||||
p.LoadingUnitsPerTruck as loadingUnitsPerTruck,
|
||||
p.LoadingUnitsPerTruck * p.LoadingUnitPieces as qtyPerTruck,
|
||||
p.LoadingUnitPieces,
|
||||
case when i.MinQuantity IS NOT NULL then round(cast(i.MinQuantity as float), 2) else 0 end as min,
|
||||
case when i.MaxQuantity IS NOT NULL then round(cast(i.MaxQuantity as float),2) else 0 end as max
|
||||
from masterData.Article (nolock) as a
|
||||
|
||||
/* sales price */
|
||||
left join
|
||||
(select *
|
||||
from (select
|
||||
id,
|
||||
PackagingId,
|
||||
ArticleId,
|
||||
DefaultCustomer,
|
||||
ROW_NUMBER() OVER (PARTITION BY ArticleId ORDER BY ValidAfter DESC) AS RowNum
|
||||
from masterData.SalesPrice (nolock)
|
||||
where DefaultCustomer = 1) as x
|
||||
where RowNum = 1
|
||||
) as s
|
||||
on a.id = s.ArticleId
|
||||
|
||||
/* pkg instuctions */
|
||||
left join
|
||||
masterData.PackagingInstruction (nolock) as p
|
||||
on s.PackagingId = p.id
|
||||
|
||||
/* stock limits */
|
||||
left join
|
||||
masterData.StockLimit (nolock) as i
|
||||
on a.id = i.ArticleId
|
||||
|
||||
where a.active = 1 and a.HumanReadableId in ([articles])
|
||||
`;
|
||||
19
server/services/sqlServer/querys/psiReport/deliveredData.ts
Normal file
19
server/services/sqlServer/querys/psiReport/deliveredData.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
export const psiDeliveredData = `
|
||||
use AlplaPROD_test1
|
||||
|
||||
declare @start_date nvarchar(30) = [startDate] --'2025-01-01'
|
||||
declare @end_date nvarchar(30) = [endDate] --'2025-08-09'
|
||||
|
||||
|
||||
select IdArtikelVarianten,
|
||||
ArtikelVariantenBez,
|
||||
sum(Menge) totalDelivered,
|
||||
case when convert(time, upd_date) between '00:00' and '07:00' then convert(date, upd_date - 1) else convert(date, upd_date) end as ShippingDate
|
||||
|
||||
from dbo.V_LadePlanungenLadeAuftragAbruf (nolock)
|
||||
|
||||
where upd_date between CONVERT(datetime, @start_date + ' 7:00') and CONVERT(datetime, @end_date + ' 7:00') and IdArtikelVarianten in ([articles])
|
||||
|
||||
group by IdArtikelVarianten, upd_date,
|
||||
ArtikelVariantenBez
|
||||
`;
|
||||
27
server/services/sqlServer/querys/psiReport/deliveryData.ts
Normal file
27
server/services/sqlServer/querys/psiReport/deliveryData.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
export const psiDeliveredData = `
|
||||
|
||||
use [test1_AlplaPROD2.0_Read]
|
||||
|
||||
declare @start_date nvarchar(30) = [startDate] --'2025-01-01'
|
||||
declare @end_date nvarchar(30) = [endDate] --'2025-08-09'
|
||||
|
||||
select
|
||||
ArticleHumanReadableId,
|
||||
ArticleAlias,
|
||||
cast(Quantity as int) Quantity,
|
||||
--cast(DeliveryDate as time) as deliveryTime,
|
||||
--cast(DeliveryDate as date) as originalDeliveryDate,
|
||||
case when cast(DeliveryDate as time) between '00:00' and '07:00'
|
||||
then DATEADD(DAY, -1, CONVERT(DATE, DeliveryDate))
|
||||
else cast(DeliveryDate as date)
|
||||
end as ShippingDate
|
||||
--,*
|
||||
from [order].[Release]
|
||||
|
||||
where case when cast(DeliveryDate as time) between '00:00' and '07:00'
|
||||
then DATEADD(DAY, -1, CONVERT(DATE, DeliveryDate))
|
||||
else cast(DeliveryDate as date)
|
||||
end between @start_date and @end_date
|
||||
and ArticleHumanReadableId in ([articles])
|
||||
|
||||
order by DeliveryDate`;
|
||||
@@ -0,0 +1,33 @@
|
||||
export const planningNumbersByAVDate = `
|
||||
use AlplaPROD_test1
|
||||
declare @start_date nvarchar(30) = [startDate] --'2025-01-01'
|
||||
declare @end_date nvarchar(30) = [endDate] --'2025-08-09'
|
||||
/*
|
||||
articles will need to be passed over as well as the date structure we want to see
|
||||
*/
|
||||
|
||||
-- planned lots in planning
|
||||
|
||||
select V_ProdLosProduktionJeProdTag_PLANNING.IdArtikelvarianten As Article,
|
||||
ProduktionAlias as Description,
|
||||
standort as MachineId,
|
||||
MaschinenBezeichnung as MachineName,
|
||||
--MaschZyklus as PlanningCycleTime,
|
||||
V_ProdLosProduktionJeProdTag_PLANNING.IdProdPlanung as LotNumber,
|
||||
FORMAT(ProdTag, 'MM/dd/yyyy') as ProductionDay,
|
||||
V_ProdLosProduktionJeProdTag_PLANNING.planMenge as TotalPlanned,
|
||||
ProduktionMenge as QTYPerDay,
|
||||
round(ProduktionMengeVPK, 2) PalDay,
|
||||
Status as finished
|
||||
--MaschStdAuslastung as nee
|
||||
|
||||
from dbo.V_ProdLosProduktionJeProdTag_PLANNING (nolock)
|
||||
|
||||
left join
|
||||
dbo.V_ProdPlanung (nolock) on
|
||||
V_ProdLosProduktionJeProdTag_PLANNING .IdProdPlanung = V_ProdPlanung.IdProdPlanung
|
||||
|
||||
where V_ProdLosProduktionJeProdTag_PLANNING.IdArtikelvarianten in ([articles]) and ProdTag between @start_date and @end_date --and IdProdPlanung = 18442
|
||||
|
||||
order by ProdTag
|
||||
`;
|
||||
@@ -0,0 +1,21 @@
|
||||
export const productionNumbers = `
|
||||
use [test1_AlplaPROD2.0_Reporting]
|
||||
|
||||
declare @startDate nvarchar(30) = [startDate] --'2024-12-30'
|
||||
declare @endDate nvarchar(30) = [endDate] --'2025-08-09'
|
||||
|
||||
select MachineLocation,
|
||||
ArticleHumanReadableId as article,
|
||||
sum(Quantity) as Produced,
|
||||
count(Quantity) as palletsProdued,
|
||||
FORMAT(convert(date, ProductionDay), 'M/d/yyyy') as ProductionDay,
|
||||
ProductionLotHumanReadableId as productionLot
|
||||
|
||||
from [reporting_productionControlling].[ScannedUnit] (nolock)
|
||||
|
||||
where convert(date, ProductionDay) between @startDate and @endDate and ArticleHumanReadableId in ([articles]) and BookedOut is null
|
||||
|
||||
group by MachineLocation, ArticleHumanReadableId,ProductionDay, ProductionLotHumanReadableId
|
||||
|
||||
order by ProductionDay
|
||||
`;
|
||||
Reference in New Issue
Block a user