金蝶KIS/K3固定比例的多计量单位换算增强视图
--金蝶KIS专业版和K3自有的计量单位视图中,对应的计量单位组和计量单位是纵向显示与排列,这比较适合对于使用单计量单位客户,对于计量单位组中含有多个计量单位,并且它们之间需要进行换算时,这种纵向显示与排列,在进行后台二次开发调用数据时显得不太友好,因此写了这个增强型计量单位视图,可以把计量单位组和它对应的大中小计量单位实现横向显示与排列;
--约定:对于每一个计量单位组中,统一要求三级换算,不足三级的可以没有第二级计量单位,基本计量单位(也就是一级计量单位或称作最小计量单位)的编码以数字1结尾,二级计量单位或称作中间计量单位的编码以数字2结尾,三级计量单位或称作最大计量单位的编码以数字3结尾
CREATE VIEW ZVW_BMeasureUnitPlus
AS
SELECT
X2.FDeleted,--原列名:FDeleted,是否禁用,1指禁用,0指正常
x2.FZWUnitGroupID,
x2.FZWUnitGroupName,
x2.FZWUnitID1,
x2.FZWUnitCode1,
x2.FZWUnitName1,
x2.FZWUnitrate1,
x2.FZWUnitID2,
x2.FZWUnitCode2,
x2.FZWUnitName2,
x2.FZWUnitrate2,
Isnull(m3.FMeasureUnitID, 0) AS FZWUnitID3,
Isnull(m3.FNumber, 0) AS FZWUnitCode3,
Isnull(m3.FName, 0) AS FZWUnitName3,
Isnull(m3.FCoefficient, 0) AS FZWUnitrate3,
Isnull(x2.FZWUnitID1, 0) AS FZWMinUnitID,
Isnull(x2.FZWUnitCode1, 0) AS FZWMinUnitCode,
Isnull(x2.FZWUnitName1, 0) AS FZWMinUnitName,
Isnull(x2.FZWUnitrate1, 0) AS FZWMinUnitRate,
Isnull(x2.FZWUnitID2, 0) AS FZWMidUnitID,
Isnull(x2.FZWUnitCode2, 0) AS FZWMidUnitCode,
Isnull(x2.FZWUnitName2, 0) AS FZWMidUnitName,
Isnull(x2.FZWUnitrate2, 0) AS FZWMidUnitRate,
Isnull(m3.FMeasureUnitID, 0) AS FZWMaxUnitID,
Isnull(m3.FNumber, 0) AS FZWMaxUnitCode,
Isnull(m3.FCoefficient, 0) AS FZWMaxUnitRate,
Isnull(m3.FName, 0) AS FZWMaxUnitName
FROM (SELECT X1.FDeleted,--原列名:FDeleted,是否禁用,1指禁用,0指正常
x1.FZWUnitGroupID,
x1.FZWUnitGroupName,
x1.FZWUnitID1,
x1.FZWUnitCode1,
x1.FZWUnitName1,
x1.FZWUnitrate1,
Isnull(m2.FMeasureUnitID, 0) AS FZWUnitID2,
Isnull(m2.FNumber, 0) AS FZWUnitCode2,
Isnull(m2.FName, 0) AS FZWUnitName2,
Isnull(m2.FCoefficient, 0) AS FZWUnitrate2
FROM (SELECT Isnull(M1.FDeleted, 0) AS FDeleted,--原列名:FDeleted,是否禁用,1指禁用,0指正常
u.FUnitGroupID AS FZWUnitGroupID,
u.FName AS FZWUnitGroupName,
M1.FMeasureUnitID AS FZWUnitID1,
M1.FNumber AS FZWUnitCode1,
M1.FName AS FZWUnitName1,
M1.FCoefficient AS FZWUnitrate1
FROM t_UnitGroup U
LEFT OUTER JOIN t_MeasureUnit M1
ON u.FUnitGroupID = M1.FUnitGroupID
AND RIGHT (M1.FNumber, 1) = '1'
AND M1.FCoefficient = 1) AS x1
LEFT OUTER JOIN t_MeasureUnit m2
ON x1.FZWUnitGroupID = m2.FUnitGroupID
AND RIGHT (m2.FNumber, 1) = '2'
AND m2.FCoefficient >= 1) AS x2
LEFT OUTER JOIN t_MeasureUnit m3
ON x2.FZWUnitGroupID = m3.FUnitGroupID
AND RIGHT (m3.FNumber, 1) = '3'
AND m3.FCoefficient >= 1
--***本文档到此结束***
金蝶KIS/K3固定比例的多计量单位换算增强视图
本文2024-09-16 16:25:21发表“k3wise知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3wise-9127.html