/// <summary> /// after Delete /// </summary> protected override void OnDeleted() { using (ISession session = Session.Open()) { if (this.OriginalData.ShipPlan != null && this.OriginalData.ShipLine != null) { ShipCostForecastBE.ShipCostForecast.EntityList lineList = ShipCostForecastBE.ShipCostForecast.Finder.FindAll("ShipLine=" + this.OriginalData.ShipLine.ID + ""); ShipPlanDetailBE.ShipPlanDetailLine line = ShipPlanDetailBE.ShipPlanDetailLine.Finder.FindByID(this.OriginalData.ShipLine.ID); if (line != null) { if (lineList == null || lineList.Count == 0) { line.ForecastStateEnum = AllEnumBE.ForecastStateEnum.N; } else { line.ForecastStateEnum = AllEnumBE.ForecastStateEnum.Y; } } } session.Commit(); } base.OnDeleted(); // TO DO: write your business code here... }
/// <summary> /// after Delete /// </summary> protected override void OnDeleted() { using (ISession sessoin = Session.Open()) { ShipPlanDetailBE.ShipPlanDetailLine line = null; if (this.OriginalData.SrcShipLine > 0) { line = ShipPlanDetailBE.ShipPlanDetailLine.Finder.FindByID(this.OriginalData.SrcShipLine); //写所有出运明细单行.已预装柜=false; if (line != null) { line.IsShipping = false; //反写出运明细单行装柜数量 line.InstalledArkQty = line.InstalledArkQty - this.OriginalData.InstalledArkNumber; line.IsShipping = false; //删除出运差异信息 ShipPlanDifference shipDiffe = ShipPlanDifference.Finder.Find("ShipLine=" + line.ID); if (shipDiffe != null) { shipDiffe.Remove(); } } } sessoin.Commit(); } base.OnDeleted(); // TO DO: write your business code here... }
/// <summary> /// after Insert /// </summary> protected override void OnInserted() { using (ISession session = Session.Open()) { if (this.ShipLine != null) { ShipPlanDetailBE.ShipPlanDetailLine line = ShipPlanDetailBE.ShipPlanDetailLine.Finder.FindByID(this.ShipLine.ID); if (line != null) { line.ForecastStateEnum = AllEnumBE.ForecastStateEnum.Y; } } session.Commit(); } base.OnInserted(); // TO DO: write your business code here... }
/// <summary> /// after Update /// </summary> protected override void OnUpdated() { using (ISession sessoin = Session.Open()) { ShipPlanDetailBE.ShipPlanDetailLine line = null; if (this.SrcShipLine > 0) { line = ShipPlanDetailBE.ShipPlanDetailLine.Finder.FindByID(this.SrcShipLine); //反写出运明细单行装柜数量 if (line != null) { line.InstalledArkQty = line.InstalledArkQty + this.OriginalData.InstalledArkNumber - this.InstalledArkNumber; line.IsShipping = true; } } sessoin.Commit(); } base.OnUpdated(); // TO DO: write your business code here... }
/// <summary> /// after Insert /// </summary> protected override void OnInserted() { using (ISession session = Session.Open()) { ShipPlanDetailBE.ShipPlanDetailLine line = null; if (this.SrcShipLine > 0) { line = ShipPlanDetailBE.ShipPlanDetailLine.Finder.FindByID(this.SrcShipLine); line.IsShipping = true; if (line != null) { //反写出运明细单行装柜数量 line.InstalledArkQty = line.InstalledArkQty + this.InstalledArkNumber; //创建出运差异信息 ShipPlanDifference shipDiffe = ShipPlanDifference.Finder.Find("ShipLine=" + line.ID); if (shipDiffe == null) { shipDiffe = ShipPlanDifference.Create(); shipDiffe.ShipLine = line.ID; shipDiffe.ShipPlanDocNo = line.ShipPlanDetailHead.DocNo; shipDiffe.ShipPlanLineNo = line.RowNo; shipDiffe.SOLine = line.SrcLineID; shipDiffe.SODocNo = line.SrcDocNo; shipDiffe.SODocLineNo = Convert.ToInt32(line.SrcLineNo); shipDiffe.ItemCode = line.Item.Code; shipDiffe.ItemName = line.Item.Name; shipDiffe.PlanQty = line.Qty; shipDiffe.ShipUOM = line.NumberUom; shipDiffe.Status = StateEnum.NonExecution; } } } session.Commit(); } base.OnInserted(); // TO DO: write your business code here... }
private List <ShipPlanIDDTO> CreatShipPlanList(CreatShipPlan bpObj) { List <ShipPlanIDDTO> listShip = new List <ShipPlanIDDTO>(); using (ISession session = Session.Open()) { ShipPlanDetailBE.ShipPlanDetailHead shipPlan = ShipPlanDetailBE.ShipPlanDetailHead.Create(); ShipDetailTypeBE.ShipDetailType formType = ShipDetailTypeBE.ShipDetailType.Finder.Find("IsCreatedByPush=1"); if (formType == null) { throw new Exception("未设置出运明细单生单的单据类型,请设置出运明细单单据类型为“上游单据推出”"); } shipPlan.DocumnetType = formType; shipPlan.SourceDocumnetType = AllEnumBE.SourceTypeEnum.SoOrder; shipPlan.Status = AllEnumBE.DocumnetSate.OpenState; //单据状态 shipPlan.ShipPlanState = AllEnumBE.ShipPlanStateEnum.NotShipPlan; //出运状态 shipPlan.BusinessDate = DateTime.Now; //设置默认行号 GetProfileValueProxy lineNo = new GetProfileValueProxy(); lineNo.ProfileCode = "SysLineNo"; PVDTOData pVTDOData = lineNo.Do(); string row = pVTDOData.ProfileValue; //财务费率 decimal fiFeeRate = 0; GetProfileValueProxy bpObj1 = new GetProfileValueProxy(); bpObj1.ProfileCode = "FTFIFee"; bpObj1.ProfileOrg = Base.Context.LoginOrg.ID; PVDTOData pVDTOData = bpObj1.Do(); if (pVDTOData != null && pVDTOData.ProfileValue != null) { fiFeeRate = decimal.Parse(pVDTOData.ProfileValue); } string docNo = "", shipplingType = "", soLine = ""; long customer = 0, currenty = 0; int count = 1; foreach (SOLineIDDTO lineDto in bpObj.SOLineIDDTO) { UFIDA.U9.SM.SO.SOLine line = SM.SO.SOLine.Finder.FindByID(lineDto.SOLine); if (line == null) { continue; } //不同的客户、币种、装箱方式不允许拉式生成同一个出运明细单 if (count > 1) { if (customer != 0 && customer != line.SO.OrderBy.Customer.ID) { throw new Exception("销售订单" + line.SO.DocNo + "的客户与单号" + docNo + "的客户不一致,不能生成同一个出运明细单"); } if (currenty != 0 && currenty != line.SO.TC.ID) { throw new Exception("销售订单" + line.SO.DocNo + "的币种与单号" + docNo + "的币种不一致,不能生成同一个出运明细单"); } if (shipplingType != "" && shipplingType != line.DescFlexField.PubDescSeg11) { throw new Exception("销售订单" + line.SO.DocNo + "行号" + line.DocLineNo + "的装箱方式与单号" + docNo + "行号" + soLine + "装箱方式不一致,不能生成同一个出运明细单"); } } docNo = line.SO.DocNo; customer = line.SO.OrderBy.Customer.ID; currenty = line.SO.TC.ID; shipplingType = line.DescFlexField.PubDescSeg11; soLine = line.DocLineNo.ToString(); //赋值表头信息 shipPlan.SaleMan = line.SO.Seller; //业务员 shipPlan.Client = line.SO.OrderBy.Customer; //客户 if (line.SO.OrderBy.Customer != null) { // shipPlan.Consignee = line.SO.OrderBy.Customer.a //提箱港区 地区档案 从销售订单带出,从客户带出 if (line.SO.OrderBy.Customer.Territory != null) { shipPlan.CargoPort = line.SO.OrderBy.Customer.Territory;// } } if (line.SO.ShipToSite != null && line.SO.ShipToSite.CustomerSite != null)//收货位置 { //shipPlan. } shipPlan.Department = line.SO.SaleDepartment; //部门 shipPlan.Currency = line.SO.TC; //币种 shipPlan.DealMode = line.SO.BargainMode; //成交方式 //贸易国别 国家\地区档案 从销售订单带出 //shipPlan.Country = line.SO. shipPlan.Transportation = line.SO.TransMode; // if (line.SO.DescFlexField.PrivateDescSeg14 != "") { Base.Organization.Organization org = Base.Organization.Organization.FindByCode(line.SO.DescFlexField.PrivateDescSeg14); if (org != null) { shipPlan.GetOrderOrg = org; } else { throw new Exception("销售订单" + line.SO.DocNo + "接单组织为空,不能生成出运明细单"); } } else { throw new Exception("销售订单" + line.SO.DocNo + "接单组织为空,不能生成出运明细单"); } //出口口岸 港口档案 从销售订单带出 shipPlan.ExportPort = line.SO.ShippingPort; //进港区 地区档案 从销售订单带出 //shipPlan.IntoPort //目的口岸 港口档案 从销售订单带出 shipPlan.DestinationPort = line.SO.AimPort; //运输方式 shipPlan.Transportation = line.SO.TransMode; //贸易方式 shipPlan.TradeMode = line.SO.TradeMode; //收汇天数,从销售订单公共扩展字段1带出 if (line.SO.OrderBy.CustomerKey.GetEntity().DescFlexField.PubDescSeg1 == "") { shipPlan.NumberDay = 0; } else { shipPlan.NumberDay = Convert.ToInt32(line.SO.OrderBy.CustomerKey.GetEntity().DescFlexField.PubDescSeg1); } //赋值表体信息 ShipPlanDetailBE.ShipPlanDetailLine shipLine = ShipPlanDetailBE.ShipPlanDetailLine.Create(shipPlan); //包装工厂 值集值 从销售订单行带出 //Base.FlexField.ValueSet.DefineValue flexField = Base.FlexField.ValueSet.DefineValue.Finder.Find("Code='Z022'"); if (line.DescFlexField.PrivateDescSeg18 != "") { Base.FlexField.ValueSet.DefineValue flexField = Base.FlexField.ValueSet.DefineValue.Finder.Find("ValueSetDef.Code='Z002' and Code='" + line.DescFlexField.PrivateDescSeg18 + "'"); // flexField.ValueSetDef.CodeAttribute shipLine.PackingHouse = flexField; } if (line.DescFlexField.PrivateDescSeg12 != "") //验货方式直接 { Base.FlexField.ValueSet.DefineValue flexField = Base.FlexField.ValueSet.DefineValue.Finder.Find("ValueSetDef.Code='Z009' and Code='" + line.DescFlexField.PrivateDescSeg12 + "'"); shipLine.ExamineCargoMode = flexField; //shipLine.ExamineCargoMode = AllEnumBE.ExamineCargoModeEnum.GetFromValue(line.DescFlexField.PrivateDescSeg12); } //else // shipLine.ExamineCargoMode = AllEnumBE.ExamineCargoModeEnum.Empty; shipLine.RowNo = Convert.ToInt32(row); shipLine.SrcSO = line.SO; shipLine.SrcDocNo = line.SO.DocNo; shipLine.SrcLineID = line.ID; shipLine.SrcLineNo = line.DocLineNo.ToString(); //shipLine.SrcSOKey = line. if (line.ItemInfo == null || line.ItemInfo.ItemID == null) { throw new Exception("销售订单" + line.SO.DocNo + "行" + line.DocLineNo + "找不见对应料品信息,不能生成出运明细单"); } shipLine.Item = line.ItemInfo.ItemID; shipLine.Standard = line.ItemInfo.ItemID.SPECS; shipLine.NumberUom = line.TU; shipLine.Ultimately = line.FinallyPriceTC;//最终价 //外销价 十进制 销售订单带出 if (line.DescFlexField.PrivateDescSeg5 != "") { shipLine.ExportSales = decimal.Parse(line.DescFlexField.PrivateDescSeg5);//外销价 } shipLine.Qty = lineDto.ShipQty; shipPlan.FinancialCost += shipPlan.FinancialCost + (shipLine.ExportSales * shipLine.Qty * fiFeeRate / 100); //反写销售订单已出运数量 //if (line.DescFlexField.PrivateDescSeg8 != "") //{ // line.DescFlexField.PrivateDescSeg8 = (decimal.Parse(line.DescFlexField.PrivateDescSeg8) + lineDto.ShipQty).ToString();//反写销售订单行的已出运数量 //} //else // line.DescFlexField.PrivateDescSeg8 = lineDto.ShipQty.ToString(); //验货方式销售订单行私有字段12 //带出料品的总箱数、内箱数、外箱数、毛重、净重、体积、长、宽、高,体积、总体积 //料品的字表字段 ItemSubTable itemsub = ItemSubTable.Finder.Find("ItemMaster=" + line.ItemInfo.ItemID.ID); if (itemsub != null) { //string sumBoxNumber = line.ItemInfo.ItemIDKey.GetEntity().DescFlexField.PrivateDescSeg3;//料品的扩展字段;箱数 //string inBoxNumber = line.ItemInfo.ItemIDKey.GetEntity().DescFlexField.PrivateDescSeg27;//料品的扩展字段;内箱数 //string outerBoxNumber = line.ItemInfo.ItemIDKey.GetEntity().DescFlexField.PrivateDescSeg28;//料品的扩展字段;外箱数 //string grossWeight = line.ItemInfo.ItemIDKey.GetEntity().DescFlexField.PrivateDescSeg2;//料品的扩展字段:毛重 ////string netWeight = line.ItemInfo.ItemIDKey.GetEntity().DescFlexField.PrivateDescSeg3;//料品的扩展字段:净重 //string length = line.ItemInfo.ItemIDKey.GetEntity().DescFlexField.PrivateDescSeg8;//料品的扩展字段:长 //string weith = line.ItemInfo.ItemIDKey.GetEntity().DescFlexField.PrivateDescSeg9;//料品的扩展字段:宽 //string hight = line.ItemInfo.ItemIDKey.GetEntity().DescFlexField.PrivateDescSeg10;//料品的扩展字段:高 //string sumBoxNumber = itemsub.BoxNumber; ;//料品的扩展字段;箱数 //string inBoxNumber = line.ItemInfo.ItemIDKey.GetEntity().DescFlexField.PrivateDescSeg27;//料品的扩展字段;内箱数 //string outerBoxNumber = line.ItemInfo.ItemIDKey.GetEntity().DescFlexField.PrivateDescSeg28;//料品的扩展字段;外箱数 //string grossWeight = line.ItemInfo.ItemIDKey.GetEntity().DescFlexField.PrivateDescSeg2;//料品的扩展字段:毛重 ////string netWeight = line.ItemInfo.ItemIDKey.GetEntity().DescFlexField.PrivateDescSeg3;//料品的扩展字段:净重 //string length = line.ItemInfo.ItemIDKey.GetEntity().DescFlexField.PrivateDescSeg8;//料品的扩展字段:长 //string weith = line.ItemInfo.ItemIDKey.GetEntity().DescFlexField.PrivateDescSeg9;//料品的扩展字段:宽 //string hight = line.ItemInfo.ItemIDKey.GetEntity().DescFlexField.PrivateDescSeg10;//料品的扩展字段:高 shipLine.SumBoxNumber = itemsub.BoxNumber; shipLine.InBoxNumber = itemsub.InnerBoxNumber; shipLine.OuterBoxNumber = itemsub.OutBoxNumber; shipLine.GrossWeight = itemsub.GrossWeight; //毛重 shipLine.NetWeight = itemsub.NetWeight; //净重 shipLine.SumGross = shipLine.GrossWeight * shipLine.Qty; //总毛重 shipLine.Length = itemsub.BoxLong; shipLine.Weith = itemsub.BoxWidth; shipLine.Higth = itemsub.BoxHight; shipLine.Bulks = shipLine.Length * shipLine.Weith * shipLine.Higth; //体积 shipLine.SumBulk = shipLine.Bulks * shipLine.Qty; //总体积 } #region 产生佣金表,放到BE里生成 //if (line.DescFlexField.PrivateDescSeg6.ToLower() == "true") //{ // OrderLineBrokerage.EntityList brokerage = OrderLineBrokerage.Finder.FindAll("OrderLineID='" + line.ID + "'"); // if (brokerage != null && brokerage.Count > 0) // { // OrderLineBrokerage shipLineBroke = null; // foreach (OrderLineBrokerage orderBrokerage in brokerage) // { // shipLineBroke = OrderLineBrokerage.Create(); // shipLineBroke.SourceType = AllEnumBE.SourceTypeEnum.ShipPlanDoc; // shipLineBroke.ShipPlanLine = shipLine; // shipLineBroke.ShipPlanRowNo = int.Parse(row); // shipLineBroke.Client = orderBrokerage.Client; // shipLineBroke.Product = orderBrokerage.Product; // shipLineBroke.BrokerageRatio = orderBrokerage.BrokerageRatio; // shipLineBroke.Payee = orderBrokerage.Payee; // shipLineBroke.PayAmount = orderBrokerage.PayAmount; // shipLineBroke.PayCurrency = orderBrokerage.PayCurrency; // shipLineBroke.OutPayment = orderBrokerage.OutPayment; // shipLineBroke.OrderCurrency = orderBrokerage.OrderCurrency; // shipLineBroke.Rate = orderBrokerage.Rate; // } // } //} #endregion row = (int.Parse(row) + int.Parse(pVTDOData.ProfileValue)).ToString(); count++; } session.Commit(); ShipPlanIDDTO shipID = new ShipPlanIDDTO(); shipID.DocNo = shipPlan.DocNo; shipID.ShipPlan = shipPlan.ID; listShip.Add(shipID); } return(listShip); }
/// <summary> /// 为实体Dto赋值 /// </summary> /// <param name="SO">销售订单集合</param> /// <param name="SoLine">销售订单行集合与销售订单集合互斥</param> /// <param name="dotList">成本预测实体DTo</param> private List <ShipCostForecastBE.ShipCostForecastDTO> SetCostDto(List <GS.FT.ShipPlanDetailBE.ShipPlanDetailHead.EntityKey> ShiPlan, List <GS.FT.ShipPlanDetailBE.ShipPlanDetailLine.EntityKey> ShipLine) { List <ShipCostForecastBE.ShipCostForecastDTO> dtoList = new List <ShipCostForecastBE.ShipCostForecastDTO>();//订单成本预测实体集合 #region 参数声明 ShipCostForecastBE.ShipCostForecastDTO dto = null; //明细单成本预测实体dto ShipCostForecastBE.ShipCostForecastDTO dtoOne = null; //明细单成品成本预测实体dto //获取所需预置参数 CalculateDtoFieldShipExtend.GetPresetParameter(); #endregion //整单成本预测 if (ShiPlan != null && ShiPlan.Count > 0) { //从UI得到的销售订单应该是已经按照销售订单过滤了的 GS.FT.ShipPlanDetailBE.ShipPlanDetailHead shipEntity = null; using (ISession session = Session.Open()) { foreach (GS.FT.ShipPlanDetailBE.ShipPlanDetailHead.EntityKey shipKey in ShiPlan) //遍历销售订单集合 { //得到对应明细订单 shipEntity = shipKey.GetEntity(); if (shipEntity == null) { continue; } dto = new ShipCostForecastBE.ShipCostForecastDTO(); dto.ShipPlan = shipEntity; //赋值出运明细单 dto.ForecastType = AllEnumBE.CostForecastTypeEnum.AllCostForecast; //预测类型整单成本预测 dto.OceanFreight = shipEntity.OceanFreight; dto.OtherFee = shipEntity.OherFee; dto.DomesticFee = shipEntity.InlandFreight; dto.OtherDomesticFee = shipEntity.OtherInland; #region 遍历得到明细订单行 foreach (GS.FT.ShipPlanDetailBE.ShipPlanDetailLine shipLineEntity in shipEntity.ShipPlanDetailLine) //遍历出运明细单行集合 { //计算共用值 decimal rmbCost = 0; //工具人民币采购成本 decimal dollorCost = 0; //工具美元采购成本 decimal allFee = 0; //成品各项费用 dtoOne = new ShipCostForecastBE.ShipCostForecastDTO(); dtoOne.ForecastType = AllEnumBE.CostForecastTypeEnum.OneCostForecast; //预测类型 dtoOne.ShipPlan = shipEntity; //销售订单 dtoOne.ShipLine = shipLineEntity; //销售订单行 dtoOne.Brokerage = CalculateDtoFieldShipExtend.GetBrokerage(shipLineEntity); //佣金 dtoOne.Discount = CalculateDtoFieldShipExtend.GetDiscount(shipLineEntity); //折扣 dtoOne.OceanFreight = CalculateDtoFieldShipExtend.GetOceanFreight(shipLineEntity); //海运费 dtoOne.OtherFee = CalculateDtoFieldShipExtend.GetOtherOceanFreight(shipLineEntity); //其他国外费 dtoOne.DomesticFee = CalculateDtoFieldShipExtend.GetDomesticFee(shipLineEntity); //国内运费 dtoOne.OtherDomesticFee = CalculateDtoFieldShipExtend.GetOtherOceanFreight(shipLineEntity); //其他国内费 //随单BOM OrderBomBE.OrderBomHead.EntityList orderBom = OrderBomBE.OrderBomHead.Finder.FindAll("OrderLine=@SOLine", new OqlParam(shipLineEntity.SrcLineID)); dtoOne.TaxCredits = CalculateDtoFieldShipExtend.GetTaxCredits(shipLineEntity, orderBom); //退税额 dtoOne.ProcurementCost = CalculateDtoFieldShipExtend.GetProcurementCost(shipLineEntity, orderBom); //包装采购成本 dtoOne.LabourCharges = CalculateDtoFieldShipExtend.GetLabourCharges(shipLineEntity); //包装人工费用 dtoOne.ProductCost = CalculateDtoFieldShipExtend.GetProductCost(shipLineEntity, orderBom, ref rmbCost, ref dollorCost); //产品采购成本 dtoOne.RMBProductCost = rmbCost; //工具人民币采购成本 dtoOne.DollorProductCost = dollorCost; //工具美元采购成本 dtoOne.AdministrativeFee = CalculateDtoFieldShipExtend.GetAdministrativeFee(shipLineEntity); //管理费 dtoOne.Interest = CalculateDtoFieldShipExtend.GetInterest(shipLineEntity); //利息 dtoOne.MouldFee = CalculateDtoFieldShipExtend.GetMouldFee(shipLineEntity); //模具费‘ dtoOne.Labelling = CalculateDtoFieldShipExtend.GetLabelling(shipLineEntity, orderBom); //防盗标签费 dtoOne.CreditInsurance = CalculateDtoFieldShipExtend.GetCreditInsurance(shipLineEntity); //信用保险费 dtoOne.BankCharge = CalculateDtoFieldShipExtend.GetBankCharge(shipLineEntity); //银行费用 dtoOne.ForecastTime = DateTime.Now; dtoOne.ForecastMan = UFIDA.U9.Base.Context.LoginUser; //成品预测利润:各中类成品外销额-成品各项费用+成品退税额 allFee = dtoOne.Brokerage + dtoOne.Discount + dtoOne.OceanFreight + dtoOne.OtherFee + dtoOne.DomesticFee + dtoOne.OtherDomesticFee + dtoOne.ProcurementCost + dtoOne.LabourCharges + dtoOne.ProductCost + dtoOne.AdministrativeFee + dtoOne.Interest + dtoOne.MouldFee + dto.Labelling + dtoOne.CreditInsurance + dtoOne.BankCharge; dtoOne.ProductForecastRate = shipLineEntity.TotalTax - allFee + dto.TaxCredits; dtoOne.ProductRate = dto.ProductForecastRate / shipLineEntity.TotalTax; //备注 dtoOne.Demo = ""; dtoList.Add(dtoOne); #region 汇总到整单成本预测 dto.Brokerage += dtoOne.Brokerage; dto.Discount += dtoOne.Discount; dto.OceanFreight += dtoOne.OceanFreight;//海运费 dto.TaxCredits += dtoOne.TaxCredits; dto.ProcurementCost += dtoOne.ProcurementCost; dto.LabourCharges += dtoOne.LabourCharges; dto.ProductCost += dtoOne.ProductCost; dto.RMBProductCost += dtoOne.RMBProductCost; dto.DollorProductCost += dtoOne.DollorProductCost; dto.AdministrativeFee += dtoOne.AdministrativeFee; dto.Interest += dtoOne.Interest; dto.MouldFee += dtoOne.MouldFee; dto.Labelling += dtoOne.Labelling; dto.CreditInsurance += dtoOne.CreditInsurance; dto.BankCharge += dtoOne.BankCharge; dto.ListForecastRate += dto.ProductForecastRate; //备注 dto.Demo = ","; //dto.SOLine = soLineEntity; //随单BOM #endregion //得到销售订单行soLineEntity #region 计算成本预测字段值 //根据销售订单行得到随单Bom表 OrderBomHead bomHead = OrderBomHead.Finder.Find(""); #endregion } //dto.ListRate = dto.ProductForecastRate / soEntity.TotalMoneyAC;//整单利润率 dto.ForecastTime = DateTime.Now; //预测时间 dto.ForecastMan = UFIDA.U9.Base.Context.LoginUser; //预测人 dtoList.Add(dto); shipEntity.DescFlexField.PrivateDescSeg7 = dto.OceanFreight.ToString(); #endregion } session.Commit(); } } else if (ShipLine != null && ShipLine.Count > 0) { using (Session seesion = Session.Open()) { //成品成本预测 //从UI得到的销售订单行应该是已经按照销售订单行过滤了的 foreach (GS.FT.ShipPlanDetailBE.ShipPlanDetailLine.EntityKey shipLineKey in ShipLine) //遍历出运明细单行集合 { //得到出运明细行 //if (shipLineKey.GetEntity() == null) // throw new Exception("请在列表选择出运明细行信息"); ShipPlanDetailBE.ShipPlanDetailLine line = ShipPlanDetailBE.ShipPlanDetailLine.Finder.FindByID(shipLineKey.ID); if (line == null) { throw new Exception("请在列表选择出运明细行信息"); } GS.FT.ShipPlanDetailBE.ShipPlanDetailLine shipLineEntity = line; #region 计算成本预测字段值 decimal rmbCost = 0; //工具人民币采购成本 decimal dollorCost = 0; //工具美元采购成本 decimal allFee = 0; //成品各项费用 dtoOne = new ShipCostForecastBE.ShipCostForecastDTO(); dtoOne.ForecastType = AllEnumBE.CostForecastTypeEnum.OneCostForecast; //预测类型 dtoOne.ShipPlan = shipLineEntity.ShipPlanDetailHead; //销售订单 dtoOne.ShipLine = shipLineEntity; //销售订单行 dtoOne.Brokerage = CalculateDtoFieldShipExtend.GetBrokerage(shipLineEntity); //佣金 dtoOne.Discount = CalculateDtoFieldShipExtend.GetDiscount(shipLineEntity); //折扣 dtoOne.OceanFreight = CalculateDtoFieldShipExtend.GetOceanFreight(shipLineEntity); //海运费 dtoOne.OtherFee = CalculateDtoFieldShipExtend.GetOtherOceanFreight(shipLineEntity); //其他国外费 dtoOne.DomesticFee = CalculateDtoFieldShipExtend.GetDomesticFee(shipLineEntity); //国内运费 dtoOne.OtherDomesticFee = CalculateDtoFieldShipExtend.GetOtherOceanFreight(shipLineEntity); //其他国内费 //随单BOM OrderBomBE.OrderBomHead.EntityList orderBom = OrderBomBE.OrderBomHead.Finder.FindAll("OrderLine=@SOLine", new OqlParam(shipLineEntity.SrcLineID)); dtoOne.TaxCredits = CalculateDtoFieldShipExtend.GetTaxCredits(shipLineEntity, orderBom); //退税额 dtoOne.ProcurementCost = CalculateDtoFieldShipExtend.GetProcurementCost(shipLineEntity, orderBom); //包装采购成本 dtoOne.LabourCharges = CalculateDtoFieldShipExtend.GetLabourCharges(shipLineEntity); //包装人工费用 dtoOne.ProductCost = CalculateDtoFieldShipExtend.GetProductCost(shipLineEntity, orderBom, ref rmbCost, ref dollorCost); //产品采购成本 dtoOne.RMBProductCost = rmbCost; //工具人民币采购成本 dtoOne.DollorProductCost = dollorCost; //工具美元采购成本 dtoOne.AdministrativeFee = CalculateDtoFieldShipExtend.GetAdministrativeFee(shipLineEntity); //管理费 dtoOne.Interest = CalculateDtoFieldShipExtend.GetInterest(shipLineEntity); //利息 dtoOne.MouldFee = CalculateDtoFieldShipExtend.GetMouldFee(shipLineEntity); //模具费‘ dtoOne.Labelling = CalculateDtoFieldShipExtend.GetLabelling(shipLineEntity, orderBom); //防盗标签费 dtoOne.CreditInsurance = CalculateDtoFieldShipExtend.GetCreditInsurance(shipLineEntity); //信用保险费 dtoOne.BankCharge = CalculateDtoFieldShipExtend.GetBankCharge(shipLineEntity); //银行费用 //dtoOne.OrderBomHead = orderBom;//随单Bom dtoOne.ForecastTime = DateTime.Now; dtoOne.ForecastMan = UFIDA.U9.Base.Context.LoginUser; //成品预测利润:各中类成品外销额-成品各项费用+成品退税额 allFee = dtoOne.Brokerage + dtoOne.Discount + dtoOne.OceanFreight + dtoOne.OtherFee + dtoOne.DomesticFee + dtoOne.OtherDomesticFee + dtoOne.ProcurementCost + dtoOne.LabourCharges + dtoOne.ProductCost + dtoOne.AdministrativeFee + dtoOne.Interest + dtoOne.MouldFee + dtoOne.Labelling + dtoOne.CreditInsurance + dtoOne.BankCharge; //dtoOne.ProductForecastRate = shipLineEntity.TotalTax - allFee + dto.TaxCredits; //dtoOne.ProductRate = dto.ProductForecastRate / shipLineEntity.TotalTax; //反写出运明细单预测状态 dtoList.Add(dtoOne); #endregion } seesion.Commit(); } } else { throw new Exception("未选择任何需要预测的订单"); } return(dtoList); //CreatEntity(dtoList); }