fix(psi): refactor psi queries

This commit is contained in:
2026-04-17 16:46:44 -05:00
parent 3639c1b77c
commit a1eeadeec4
4 changed files with 77 additions and 19 deletions

1
.gitignore vendored
View File

@@ -5,6 +5,7 @@ builds
.buildNumber .buildNumber
temp temp
brunoApi brunoApi
downloads
.scriptCreds .scriptCreds
node-v24.14.0-x64.msi node-v24.14.0-x64.msi
postgresql-17.9-2-windows-x64.exe postgresql-17.9-2-windows-x64.exe

View File

@@ -13,12 +13,12 @@ r.[ArticleHumanReadableId]
,ea.JournalNummer as BOL_Number ,ea.JournalNummer as BOL_Number
,[ReleaseConfirmationState] ,[ReleaseConfirmationState]
,[PlanningState] ,[PlanningState]
--,format(r.[OrderDate], 'yyyy-MM-dd HH:mm') as OrderDate ,format(r.[OrderDate], 'yyyy-MM-dd HH:mm') as OrderDate
,r.[OrderDate] --,r.[OrderDate]
--,FORMAT(r.[DeliveryDate], 'yyyy-MM-dd HH:mm') as DeliveryDate ,FORMAT(r.[DeliveryDate], 'yyyy-MM-dd HH:mm') as DeliveryDate
,r.[DeliveryDate] --,r.[DeliveryDate]
--,FORMAT(r.[LoadingDate], 'yyyy-MM-dd HH:mm') as LoadingDate ,FORMAT(r.[LoadingDate], 'yyyy-MM-dd HH:mm') as LoadingDate
,r.[LoadingDate] --,r.[LoadingDate]
,[Quantity] ,[Quantity]
,[DeliveredQuantity] ,[DeliveredQuantity]
,r.[AdditionalInformation1] ,r.[AdditionalInformation1]
@@ -66,9 +66,9 @@ ROW_NUMBER() OVER (PARTITION BY IdJournal ORDER BY add_date DESC) AS RowNum
zz.IdLieferschein = ea.IdJournal zz.IdLieferschein = ea.IdJournal
where where
--r.ArticleHumanReadableId in ([articles])
--r.ReleaseNumber = 1452 --r.ReleaseNumber = 1452
r.DeliveryDate between @StartDate AND @EndDate r.DeliveryDate between @StartDate AND @EndDate
and DeliveredQuantity > 0 and DeliveredQuantity > 0
--and r.ArticleHumanReadableId in ([articles])
--and Journalnummer = 169386 --and Journalnummer = 169386

View File

@@ -5,19 +5,75 @@ move this over to the delivery date range query once we have the shift data mapp
update the psi stuff on this as well. update the psi stuff on this as well.
**/ **/
declare @start_date nvarchar(30) = '[startDate]' --'2025-01-01' DECLARE @StartDate DATE = '[startDate]' -- 2025-1-1
declare @end_date nvarchar(30) = '[endDate]' --'2025-08-09' DECLARE @EndDate DATE = '[endDate]' -- 2025-1-31
SELECT
r.[ArticleHumanReadableId]
,[ReleaseNumber]
,h.CustomerOrderNumber
,x.CustomerLineItemNumber
,[CustomerReleaseNumber]
,[ReleaseState]
,[DeliveryState]
,ea.JournalNummer as BOL_Number
,[ReleaseConfirmationState]
,[PlanningState]
--,format(r.[OrderDate], 'yyyy-MM-dd HH:mm') as OrderDate
,r.[OrderDate]
--,FORMAT(r.[DeliveryDate], 'yyyy-MM-dd HH:mm') as DeliveryDate
,r.[DeliveryDate]
--,FORMAT(r.[LoadingDate], 'yyyy-MM-dd HH:mm') as LoadingDate
,r.[LoadingDate]
,[Quantity]
,[DeliveredQuantity]
,r.[AdditionalInformation1]
,r.[AdditionalInformation2]
,[TradeUnits]
,[LoadingUnits]
,[Trucks]
,[LoadingToleranceType]
,[SalesPrice]
,[Currency]
,[QuantityUnit]
,[SalesPriceRemark]
,r.[Remark]
,[Irradiated]
,r.[CreatedByEdi]
,[DeliveryAddressHumanReadableId]
,DeliveryAddressDescription
,[CustomerArtNo]
,[TotalPrice]
,r.[ArticleAlias]
FROM [order].[Release] (nolock) as r
select IdArtikelVarianten, left join
ArtikelVariantenBez, [order].LineItem as x on
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) r.LineItemId = x.id
where upd_date between CONVERT(datetime, @start_date + ' 7:00') and CONVERT(datetime, @end_date + ' 7:00') left join
and IdArtikelVarianten in ([articles]) [order].Header as h on
x.HeaderId = h.id
group by IdArtikelVarianten, upd_date, --bol stuff
ArtikelVariantenBez left join
AlplaPROD_test1.dbo.V_LadePlanungenLadeAuftragAbruf (nolock) as zz
on zz.AbrufIdAuftragsAbruf = r.ReleaseNumber
left join
(select * from (SELECT
ROW_NUMBER() OVER (PARTITION BY IdJournal ORDER BY add_date DESC) AS RowNum
,*
FROM [AlplaPROD_test1].[dbo].[T_Lieferungen] (nolock)) x
where RowNum = 1) as ea on
zz.IdLieferschein = ea.IdJournal
where
r.ArticleHumanReadableId in ([articles])
--r.ReleaseNumber = 1452
and r.DeliveryDate between @StartDate AND @EndDate
--and DeliveredQuantity > 0
--and Journalnummer = 169386

View File

@@ -24,7 +24,8 @@
"version": "changeset version", "version": "changeset version",
"specCheck": "node scripts/check-route-specs.mjs", "specCheck": "node scripts/check-route-specs.mjs",
"commit": "cz", "commit": "cz",
"release": "commit-and-tag-version" "release": "commit-and-tag-version",
"build:apk": "cd lstMobile && expo prebuild --clean && cd android && gradlew.bat assembleRelease "
}, },
"repository": { "repository": {
"type": "git", "type": "git",