代码实现类似按BOM正向展开,但实际数量总是为0
金蝶云社区-唱诗的驴
唱诗的驴
0人赞赏了该文章 1,523次浏览 未经作者许可,禁止转载编辑于2018年03月12日 08:47:25

代码如下,实现类似bom正向展开,能够获取到正确的bom,但是实际数量没有按照bom用量一层层算出来,总是为0.请大神帮忙看一下


private QueryBom()
{
DynamicObject bomDynamic = (DynamicObject)this.Model.GetValue("Fbom");
List lstExpandSoucrce = new List();
BomForwardSourceDynamicRow bomExpandSourceRowView = BomForwardSourceDynamicRow.CreateInstance();
long materialId = Convert.ToInt64(bomDynamic["MaterialId_Id"]);
DynamicObject material = bomDynamic["MaterialId"] as DynamicObject;
long unitId = Convert.ToInt64(bomDynamic["FUNITID_ID"]);
long baseUnitId = Convert.ToInt64(bomDynamic["BaseUnitId_Id"]);
decimal qty = Convert.ToDecimal(bomDynamic["Qty"]);
UnitConvert rate = UnitConvertServiceHelper.GetUnitConvertRate(this.Context, new GetUnitConvertRateArgs()
{
MaterialId = Convert.ToInt64(bomDynamic["MaterialId_Id"]),
MasterId = material == null ? 0 : Convert.ToInt64(material["msterId"]),
SourceUnitId = unitId,
DestUnitId = baseUnitId
});
if (rate != null)
{
qty = rate.ConvertQty(qty);
}
bomExpandSourceRowView.NeedQty = qty;
bomExpandSourceRowView.ProdQty = qty;
bomExpandSourceRowView.MaterialId_Id = materialId;
bomExpandSourceRowView.BomId_Id = Convert.ToInt64(bomDynamic["Id"]);
bomExpandSourceRowView.UnitId_Id = unitId;
bomExpandSourceRowView.BaseUnitId_Id = baseUnitId;
bomExpandSourceRowView.SupplyOrgId_Id = Convert.ToInt64(bomDynamic["UseOrgId_Id"]);
bomExpandSourceRowView.TimeUnit = ((int)Kingdee.K3.Core.MFG.EnumConst.Enums.Enu_TimeUnit.KdDay).ToString();

lstExpandSoucrce.Add(bomExpandSourceRowView.DataEntity);

List result = BomQueryServiceHelper.GetBomQueryForwardResult(this.Context, lstExpandSoucrce, BuildExpandOption_ForPSV());

}

private MemBomExpandOption_ForPSV BuildExpandOption_ForPSV()
{
MemBomExpandOption_ForPSV option = new MemBomExpandOption_ForPSV();
//option.ExpandLevelTo = 0;
//option.DeleteSkipRow = false;
//option.ExpandSkipRow = false;
//option.DeleteVirtualMaterial = false;
//option.ExpandVirtualMaterial = false;
//option.CsdSubstitution = false;
//option.IsExpandForbidden = false;
//option.BomExpandId = SequentialGuid.NewGuid().ToString();
return MemBomExpandOption_ForPSV.GetDefault();
}

您的鼓励与嘉奖将成为创作者们前进的动力,如果觉得本文还不错,可以给予作者创作打赏哦!

请选择打赏金币数 *

10金币20金币30金币40金币50金币60金币
可用金币: 0