point to itemm

This commit is contained in:
Paul Trowbridge 2024-02-29 13:07:03 -05:00
parent 5234516dee
commit de9ecd5033
2 changed files with 21 additions and 18 deletions

View File

@ -42,7 +42,7 @@ BEGIN
INTO INTO
_mold,_stlc,_v1ds , _v0ds, _iidx _mold,_stlc,_v1ds , _v0ds, _iidx
FROM FROM
"CMS.CUSLG".itemmv i "CMS.CUSLG".itemm i
INNER JOIN rlarp.molds m ON INNER JOIN rlarp.molds m ON
m.stlc = i.stlc m.stlc = i.stlc
WHERE WHERE

View File

@ -67,8 +67,8 @@ BEGIN
,idxk ,idxk
,prefer ,prefer
,pltq ,pltq
,fstd_usd ,futstdus
,fstd_usd_ina ,futstdus_ina
INTO INTO
_mold _mold
,_item ,_item
@ -80,30 +80,33 @@ BEGIN
FROM FROM
( (
SELECT SELECT
m.part_group i.partgroup part_group
,min(i.item) item ,min(i.item) item
,i.stlc ,i.stlc
,i.v1ds ,i.v1ds
,i.v0ds ,_ds.dataseg v0ds
,i.pltq ,i.mpck pltq
,avg(i.fstd_usd) FILTER (WHERE aplnt <> 'I') fstd_usd ,avg(i.futstdus) FILTER (WHERE aplnt <> 'I') futstdus
,avg(i.fstd_usd) fstd_usd_ina ,avg(i.futstdus) futstdus_ina
,jsonb_strip_nulls(jsonb_build_object('assc',CASE WHEN i.assc <> '' THEN i.assc ELSE null::text END,'majg',i.majg::int,'coltier',i.coltier)) idxk ,jsonb_strip_nulls(jsonb_build_object('assc',CASE WHEN i.assc <> '' THEN i.assc ELSE null::text END,'majg',i.majg::int,'coltier',i.coltier)) idxk
,CASE WHEN i.v1ds = _v1ds THEN 2 ELSE CASE WHEN i.v0ds = _v0ds THEN 1 ELSE 0 END END prefer ,CASE WHEN i.v1ds = _v1ds THEN 2 ELSE CASE WHEN _ds.dataseg = _v0ds THEN 1 ELSE 0 END END prefer
FROM FROM
"CMS.CUSLG".itemmv i "CMS.CUSLG".itemm i
INNER JOIN rlarp.molds m ON LEFT OUTER JOIN _ds ON
m.stlc = i.stlc _ds.colgrp = i.colgrp
AND _ds.brand = SUBSTRING(i.branding,1,1)
--INNER JOIN rlarp.molds m ON
-- m.stlc = i.stlc
WHERE WHERE
i.stlc = _stlc i.stlc = _stlc
GROUP BY GROUP BY
m.part_group i.partgroup
,i.stlc ,i.stlc
,i.v1ds ,i.v1ds
,i.v0ds ,_ds.dataseg
,i.pltq ,i.mpck
,jsonb_strip_nulls(jsonb_build_object('assc',CASE WHEN i.assc <> '' THEN i.assc ELSE null::text END,'majg',i.majg::int,'coltier',i.coltier)) ,jsonb_strip_nulls(jsonb_build_object('assc',CASE WHEN i.assc <> '' THEN i.assc ELSE null::text END,'majg',i.majg::int,'coltier',i.coltier))
,CASE WHEN i.v1ds = _v1ds THEN 2 ELSE CASE WHEN i.v0ds = _v0ds THEN 1 ELSE 0 END END ,CASE WHEN i.v1ds = _v1ds THEN 2 ELSE CASE WHEN _ds.dataseg = _v0ds THEN 1 ELSE 0 END END
) best ) best
ORDER BY ORDER BY
prefer DESC prefer DESC
@ -117,8 +120,8 @@ BEGIN
,'itemrel',_itemr ,'itemrel',_itemr
,'iidx',_iidx ,'iidx',_iidx
,'pltq',_pltq ,'pltq',_pltq
,'fstd_usd',_fstd ,'futstdus',_fstd
,'fstd_usd_ina',_fstdina ,'futstdus_ina',_fstdina
) )
); );
--RAISE NOTICE 'item data %', jsonb_pretty(_product||_input); --RAISE NOTICE 'item data %', jsonb_pretty(_product||_input);