vault backup: 2023-11-10 11:44:21
This commit is contained in:
parent
12b963b22f
commit
16be2ad264
@ -36,13 +36,14 @@ BEGIN
|
||||
|
||||
----------------base product--------------------------------
|
||||
|
||||
|
||||
SELECT
|
||||
m.part_group
|
||||
,min(i.item) item
|
||||
,i.stlc
|
||||
,i.v1ds
|
||||
,i.v0ds
|
||||
,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
|
||||
part_group
|
||||
,item
|
||||
,stlc
|
||||
,v1ds
|
||||
,v0ds
|
||||
,idxk
|
||||
INTO
|
||||
_mold
|
||||
,_item
|
||||
@ -50,20 +51,34 @@ BEGIN
|
||||
,_v1ds
|
||||
,_v0ds
|
||||
,_iidx
|
||||
FROM
|
||||
"CMS.CUSLG".itemmv i
|
||||
INNER JOIN rlarp.molds m ON
|
||||
m.stlc = i.stlc
|
||||
WHERE
|
||||
i.stlc = _stlc
|
||||
AND i.v1ds = _dseg
|
||||
GROUP BY
|
||||
m.part_group
|
||||
,i.stlc
|
||||
,i.v1ds
|
||||
,i.v0ds
|
||||
,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));
|
||||
_rslt := jsonb_build_object('mold',_mold,'v1ds',_v1ds,'v0ds',_v0ds,'stlc',_stlc)||_iidx;
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
m.part_group
|
||||
,min(i.item) item
|
||||
,i.stlc
|
||||
,i.v1ds
|
||||
,i.v0ds
|
||||
,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 1 ELSE 0 END prefer
|
||||
FROM
|
||||
"CMS.CUSLG".itemmv i
|
||||
INNER JOIN rlarp.molds m ON
|
||||
m.stlc = i.stlc
|
||||
WHERE
|
||||
i.stlc = _stlc
|
||||
GROUP BY
|
||||
m.part_group
|
||||
,i.stlc
|
||||
,i.v1ds
|
||||
,i.v0ds
|
||||
,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 1 ELSE 0 END
|
||||
) best
|
||||
ORDER BY
|
||||
prefer DESC
|
||||
LIMIT 1;
|
||||
_rslt := jsonb_build_object('mold',_mold,'v1ds',_v1ds,'v0ds',_v0ds,'stlc',_stlc,'item',_item,'desg',_dseg)||_iidx;
|
||||
RAISE NOTICE 'item data %', _iidx;
|
||||
|
||||
----------------channel-------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user