使用以下查询,我发现对于具有库存位置的项,有多个行从精确在线的REST返回:
select spn.item_code_attr || '-' || spn.warehouse_code_attr || '-' || stn.code key
, itm.itemgroupcode
, itm.itemgroupdescription
, spn.item_code_attr
, spn.item_description
, spn.currentquantity
, spn.planning_in
, spn.planning_out
, spn.currentquantity + spn.planning_in - spn.planning_out plannedquantity
, -1 bestelniveau /* out of scope */
, itm.costpricestandard costprijs
, itm.costpricestandard * spn.currentquantity stockvalue
, spn.warehouse_code_attr
, stn.code locatie
, itm.unitcode UOM
, itm.id
, whe.id
, sln.stock
, sln.itemid
, sln.warehouse
, stn.id
from exactonlinexml..StockPositions spn
join exactonlinerest..items itm
on itm.code = spn.item_code_attr
and itm.code = 'LE-10242'
and itm.isstockitem = 1
join exactonlinerest..warehouses whe
on whe.code = spn.warehouse_code_attr
left
outer
join exactonlinerest..stocklocations sln
on sln.itemid = itm.id
and sln.stock != 0
and sln.warehouse = whe.id
left
outer
join storagelocations stn
on stn.id = sln.storagelocation
and stn.warehouse = sln.warehouse
--
-- Filter out no stock nor planned.
--
where ( spn.currentquantity !=0
or
spn.planning_in != 0
or
spn.planning_out != 0
)
and spn.item_code_attr = 'LE-10242'
order
by key例如,对于这个项目,有10个StockLocations。当我对字段股进行求和时,它返回在StockPositions中找到的库存量。但是,似乎每个事务都会创建一个额外的StockLocation条目。
我希望StockLocation能够包含库存中的每个位置--总数量。
编辑
StockLocations API在https://start.exactonline.nl/api/v1/{division}/logistics/$metadata中描述为:
<EntityType Name="StockLocation">
<Key>
<PropertyRef Name="ItemID"/>
</Key>
<Property Name="ItemID" Type="Edm.Guid" Nullable="false"/>
<Property Name="Warehouse" Type="Edm.Guid" Nullable="true"/>
<Property Name="WarehouseCode" Type="Edm.String" Nullable="true"/>
<Property Name="WarehouseDescription" Type="Edm.String" Nullable="true"/>
<Property Name="Stock" Type="Edm.Double" Nullable="true"/>
<Property Name="StorageLocation" Type="Edm.Guid" Nullable="true"/>
<Property Name="StorageLocationCode" Type="Edm.String" Nullable="true"/>
<Property Name="StorageLocationDescription" Type="Edm.String" Nullable="true"/>
</EntityType>不知怎么的,它没有在https://start.exactonline.nl/docs/HlpRestAPIResources.aspx上记录下来。
我做错了什么?
发布于 2016-11-18 15:57:28
与工程师讨论了关于黑客马拉松的问题。这是因为StockLocation API的工作原理;命名并不能最优地反映内容,但这是预期的行为。
使用select field, sum(stock) from stocklocations group by field,您可以获得正确的信息。
为了提高连接性能,建议为此(如select ... from table1 join table2 ... join ( select field, sum(stock) from stocklocations group by field) )使用内联视图。
https://stackoverflow.com/questions/40469360
复制相似问题