2021-09-15 17.46.sql 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. USE [befri_Goldhoo]
  2. GO
  3. /****** Object: View [basedata].[V_Inventory] Script Date: 2021/9/15 17:46:09 ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. ALTER VIEW [basedata].[V_Inventory]
  9. AS
  10. SELECT DISTINCT
  11. CASE WHEN Cu.CustomItemId IS NOT NULL THEN 2
  12. WHEN Co.CombtItemId IS NOT NULL THEN 1
  13. ELSE 0
  14. END AS CombType ,
  15. CASE WHEN Cu.CustomItemId IS NOT NULL THEN '¶¨ÖÆ×éºÏ'
  16. WHEN Co.CombtItemId IS NOT NULL THEN '°åʽ×éºÏ'
  17. ELSE '·ñ'
  18. END AS CombTypeName ,
  19. i.InventoryId ,
  20. i.InventoryTypeId ,
  21. it.TypeName AS InventoryTypeName ,
  22. i.InventoryCategoryId ,
  23. ic.CategoryNumber AS InventoryCategoryNumber ,
  24. ic.CategoryName AS InventoryCategoryName ,
  25. i.UomId ,
  26. u.UomName ,
  27. i.InventorySourceId ,
  28. i.UsedSpaceId ,
  29. i.DecorationStyleId ,
  30. i.MaterialId ,
  31. i.ForPeopleId ,
  32. i.InventoryStateId ,
  33. i.InventoryColorId ,
  34. i.FactoryId ,
  35. i.VendorId ,
  36. i.InventoryNumber ,
  37. i.InventoryName ,
  38. i.Spec ,
  39. i.AliasName ,
  40. i.SearchCode ,
  41. i.Abc ,
  42. i.Weight ,
  43. i.GrossWeight ,
  44. i.WeightUom ,
  45. i.Volume ,
  46. i.PackagedValume ,
  47. i.VolumeUom ,
  48. i.Length ,
  49. i.Width ,
  50. i.Height ,
  51. i.LengthUom ,
  52. i.Light ,
  53. i.Crafts ,
  54. i.PackageQty ,
  55. i.ShelfLife ,
  56. i.SafetyInvtQty ,
  57. i.SafetyPercentage ,
  58. i.MaxInvtQty ,
  59. i.MinInvtQty ,
  60. i.AcquisitionCycle ,
  61. i.DeliveryCycle ,
  62. i.AcquisitionCost ,
  63. i.IsMaintainable ,
  64. i.IsSalable ,
  65. i.IsHot ,
  66. i.IsPromo ,
  67. i.IsGift ,
  68. i.IsSpecialOffer ,
  69. i.IsNew ,
  70. i.IsRecommend ,
  71. i.IsClearance ,
  72. i.IsCustomizable ,
  73. i.IsDiscount ,
  74. i.Dynamic ,
  75. i.CapacityConsume ,
  76. i.Barcode ,
  77. i.CostPrice ,
  78. i.SalesPrice ,
  79. i.Added ,
  80. i.AddedBy ,
  81. i.AddedOn ,
  82. i.ServiceStoped ,
  83. i.ServiceStopedOn ,
  84. i.Closed ,
  85. i.ClosedBy ,
  86. i.ClosedOn ,
  87. i.Status ,
  88. i.VersionNumber ,
  89. i.CreatedBy ,
  90. i.CreatedOn ,
  91. i.ModifiedBy ,
  92. i.ModifiedOn ,
  93. i.Description ,
  94. i.PriceType ,
  95. i.U8CategoryName ,
  96. i.U8Category ,
  97. vtm.Text AS PriceTypeText ,
  98. vimi.ThumbnailUrl ,
  99. vimi.HandledUrl ,
  100. i.DeliveryCycleStr ,
  101. i.ProductionProperty,
  102. vtmp.Text AS ProductionPropertyText,
  103. i.Price
  104. FROM basedata.Inventory AS i
  105. LEFT OUTER JOIN basedata.InventoryCategory AS ic ON ic.InventoryCategoryId = i.InventoryCategoryId
  106. LEFT OUTER JOIN basedata.Uom AS u ON u.UomId = i.UomId
  107. INNER JOIN basedata.InventoryType AS it ON it.InventoryTypeId = i.InventoryTypeId
  108. INNER JOIN dbo.ValueTextMap AS vtm ON vtm.Value = i.PriceType
  109. AND vtm.TableName = 'basedata.Inventory'
  110. AND vtm.FieldName = 'PriceType'
  111. LEFT OUTER JOIN basedata.CombtItemMember AS Co ON i.InventoryId = Co.SuitId
  112. LEFT OUTER JOIN basedata.CustomItemMember AS Cu ON i.InventoryId = Cu.MemberItemId
  113. LEFT OUTER JOIN basedata.V_InventoryMasterImage AS vimi ON i.InventoryId = vimi.InventoryId
  114. LEFT OUTER JOIN dbo.ValueTextMap AS vtmp ON i.ProductionProperty = vtmp.Value
  115. AND vtmp.TableName = 'basedata.Inventory'
  116. AND vtmp.FieldName = 'ProductionProperty'
  117. GO